Files
ds_zagres_ai/ai_service
2025-05-09 15:41:16 +01:00
..
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00
2025-05-09 15:41:16 +01:00

AI Service for Chatbot Application

This is the AI service component for the chatbot application. It provides APIs for document processing, embeddings, and chat functionality.

Features

  • Document processing and embedding
  • Retrieval-augmented generation (RAG)
  • Chat functionality with model switching
  • Team chat support

Project Structure

ai_service/
├── embeddings/       # Embedding and document processing services
├── models/           # Model and chat services
├── utils/            # Utility functions
├── data/             # Data storage
├── config.py         # Configuration settings
├── api.py            # FastAPI application
└── run.py            # Script to run the service

Setup Instructions

  1. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Copy .env.example to .env and update the values:

    cp .env.example .env
    # Edit the .env file with appropriate values
    
  4. Run the service:

    python run.py
    

API Documentation

Once the service is running, you can access the API documentation at:

Deployment

To deploy the service:

  1. Make the deployment script executable:

    chmod +x deploy.sh
    
  2. Run the deployment script:

    ./deploy.sh
    

This will start the service on port 5251 using uvicorn with nohup.

API Endpoints

Document Endpoints

  • POST /documents - Process a document for embedding
  • GET /documents - Get all documents
  • GET /documents/{doc_id} - Get a document by ID
  • DELETE /documents/{doc_id} - Delete a document
  • POST /documents/search - Search for documents

Model Endpoints

  • GET /models - Get available models
  • GET /models/{model_id} - Get information about a model

Chat Endpoints

  • POST /chats - Create a new chat
  • GET /chats/user/{user_id} - Get all chats for a user
  • GET /chats/{chat_id} - Get a chat by ID
  • POST /chats/{chat_id}/messages - Send a message to a chat
  • POST /chats/{chat_id}/members/{user_id} - Add a user to a team chat
  • DELETE /chats/{chat_id}/members/{user_id} - Remove a user from a team chat
  • DELETE /chats/{chat_id} - Delete a chat