s-nestjs-module-llm
v1.0.0
Published
A submodule for nestjs, with features like a llm
Downloads
329
Readme
S-NestJS-Module-LLM
Moduł NestJS do integracji z OpenAI API.
Dokumentacja
Pełna dokumentacja modułu jest dostępna w katalogu docs.
Funkcje
- Integracja z API OpenAI
- Konwersja mowy na tekst
- Generowanie tekstu na podstawie promptów
- Analiza obrazów
- Obsługa JSON-owych odpowiedzi
Instalacja
npm install s-nestjs-module-llmPrzykład użycia
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { LLMModule } from 's-nestjs-module-llm';
@Module({
imports: [
ConfigModule.forRoot(),
LLMModule.forRootAsync({
useFactory: (configService: ConfigService) => ({
apiKey: configService.get('OPENAI_API_KEY'),
logPrompts: configService.get('LOG_PROMPTS') === 'true',
logPath: configService.get('LOG_PATH'),
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}Important Links
Remove before final release
A submodule for nestjs, with features like a llm
Swagger
Go to localhost:3000/docs
Example API
Po uruchomieniu aplikacji, możesz przetestować API używając poniższych endpointów:
GET /api/start- Zwraca dane startowe, w tym listę użytkownikówGET /api/user/:id- Zwraca dane pojedynczego użytkownika
Przykłady użycia
Pobieranie danych startowych:
curl http://localhost:3000/api/startPobieranie danych użytkownika:
curl http://localhost:3000/api/user/9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6dGenerowanie schematów dla frontendu
Aby wygenerować schematy dla aplikacji frontendowej:
npm run zod:generateSchematy zostaną wygenerowane w katalogu ../frontend/types/zod-schemas.
Integrated features
Don't worry, with this template you will anyways get all the awesomeness you need:
- 📦 s-update-manager - Manage your dependencies with centralized repozystory
- 🎨 s-customize - Customize your repozytory with one command
- 🌐 ngrok - For local development with remote services
- ✨ ESlint and Prettier - For clean, consistent, and error-free code
- 🛠️ Extremely strict TypeScript - With
ts-resetlibrary for ultimate type safety - 🚀 GitHub Actions - Pre-configured actions for smooth workflows, including Bundle Size and performance stats
- Jest - For rock-solid unit and integration tests
- Smoke Testing and Acceptance Tests - For confidence in your deployments
- Conventional commits git hook - Keep your commit history neat and tidy
- Absolute imports - No more spaghetti imports
- Patch-package - Fix external dependencies without losing your mind
- Components coupling and cohesion graph - A tool for managing component relationships
- Semantic Release - for automatic changelog
- Husky - Git hooks made easy (see Git Hooks Documentation)
🎯 Getting Started
To get started with this boilerplate, follow these steps:
- Install the dependencies:
yarn install- Run the update witch s-update-manager:
yarn s-update-manager- Set up your repository
Replace variable in the ./tools/customize/customize.config.ts script with your own details to personalize your new package:
export const config: CustomizeConfig = {
replacements: [
{
placeholder: "{{PLACEHOLDER_FULL_NAME_EXAMPLE}}",
value: "Sebastian Wesolowski",
files: [
"package.json",
"README.md",
"./docs/HowToAutoDeploy.md",
".github/FUNDING.yml",
],
},
{
placeholder: "{{PLACEHOLDER_PAGE_AUTHOR_EXAMPLE}}",
value: "www.wesolowski.dev",
files: [".github/FUNDING.yml", "package.json", "LICENSE"],
},
...You can look on example in ./tools/customize/customize.example.config.ts
Run script with:
yarn customizeor
tsx tools/customize/customize.ts- Optional
4.1. Add ngrok token in .env file for local development
NGROK_AUTH_TOKEN=your_ngrok_tokenafter that you can run ngrok to expose your local server to the internet:
yarn dev:tunnel
- Run the development server:
Deployment
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:covWhen you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ npm install -g mau
$ mau deployWith Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
yarn dev🔗 Coupling Graph
The coupling-graph script is a useful tool that helps visualize the coupling and connections between your project's internal modules. It's built using the Madge library. To generate the graph, simply run the following command:
yarn coupling-graphThis will create a graph.svg file, which contains a graphical representation of the connections between your components. You can open the file with any SVG-compatible viewer.


