A NestJS package for AI bot functionality with OpenAI integration.
- OpenAI integration for chat completions
- Command handler system for custom AI bot commands
- Built-in search functionality
- User and location management
- Extensible architecture for adding new commands
npm install aibotimport { Module } from '@nestjs/common';
import { AiBotModule } from 'aibot';
@Module({
imports: [
AiBotModule,
// ... other modules
],
})
export class AppModule {}
// In your service
import { Injectable } from '@nestjs/common';
import { AiBotService } from 'aibot';
@Injectable()
export class YourService {
constructor(private readonly aiBotService: AiBotService) {}
async handleUserMessage(userId: string, message: string) {
const response = await this.aiBotService.run(message, userId);
return response;
}
}The package requires the following dependencies to be installed in your project:
- @nestjs/common
- @nestjs/core
- openai
The main service class that handles AI bot functionality.
run(input: string | null, userId: string, prev?: ChatCompletionMessageParam[], processedToolCallIds?: string[]): Promise<ChatCompletionMessageParam[]>- Processes user input and returns AI responses
- Handles tool calls and command execution
The package includes several built-in command handlers:
CompleteSearchHandler: Handles search functionalityFetchLocationsHandler: Manages location dataFetchUserHandler: Handles user-related operations
ISC