Skip to content

mike-prog-lab/aibot-nestjs

Repository files navigation

aibot

A NestJS package for AI bot functionality with OpenAI integration.

Features

  • 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

Installation

npm install aibot

Usage

import { 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;
  }
}

Configuration

The package requires the following dependencies to be installed in your project:

  • @nestjs/common
  • @nestjs/core
  • openai

API Documentation

AiBotService

The main service class that handles AI bot functionality.

Methods

  • 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

TODO

Command Handlers

The package includes several built-in command handlers:

  • CompleteSearchHandler: Handles search functionality
  • FetchLocationsHandler: Manages location data
  • FetchUserHandler: Handles user-related operations

License

ISC

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published