Files
ds_zagres_ai/DEPLOYMENT.md
T
2025-05-09 15:41:16 +01:00

2.8 KiB

Deployment Instructions

This document provides instructions for deploying the chatbot application with Ollama and OpenWebUI integration.

Prerequisites

Deployment Steps

  1. Clone the repository

    git clone <repository-url>
    cd <repository-directory>
    
  2. Create and activate a virtual environment

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

    pip install -r requirements.txt
    pip install python-dotenv langchain-text-splitters
    
  4. Create a .env file

    Copy the .env.example file to .env and update the values:

    cp ai_service/.env.example ai_service/.env
    # Edit the .env file with appropriate values
    

    Make sure to include the OpenWebUI configuration:

    # OpenWebUI configuration
    OPENWEBUI_URL=http://104.225.217.215:8080
    OPENWEBUI_API_KEY=GdCU4ieYDqHsLfH2
    
    # Ollama configuration
    OLLAMA_API_URL=http://104.225.217.215:8080/ollama
    DEFAULT_MODEL=llama3.1
    
  5. Run the deployment script

    For local deployment:

    python -m ai_service.run
    

    For server deployment:

    ./ai_service/deploy.sh
    

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

    For remote deployment from your local machine:

    ./remote_deploy.sh 157.157.221.29 user 22 /home/user/ds_zagres_ai
    
  6. Verify the application is running

    curl http://localhost:5251/api/health
    

    You should see a response like:

    {
      "status": "healthy"
    }
    

Managing the Deployed Application

  • View logs

    tail -f app.log
    
  • Stop the application

    ps aux | grep uvicorn  # Find the process ID (PID)
    kill <PID>             # Replace <PID> with the actual process ID
    
  • Restart the application

    ./deploy.sh
    

API Endpoints

  • GET /health - Health check endpoint
  • POST /chats - Create a new chat
  • POST /chats/{chat_id}/messages - Send a message to the chatbot
  • GET /chats/{chat_id} - Get chat history

Ollama and OpenWebUI Integration

The chatbot now uses Ollama models via OpenWebUI. The following models are available:

  • gemma3: Google Gemma 3 model
  • llama3.3: Meta Llama 3 70B model
  • llama3.1: Meta Llama 3 8B model
  • mistral: Mistral AI model
  • deepseek: DeepSeek model

Document Training

To use RAG with your documents:

  1. Go to the OpenWebUI interface at http://104.225.217.215:8080/
  2. Navigate to the Knowledge section
  3. Upload your documents
  4. OpenWebUI will automatically process them for RAG

When using the chatbot API, set use_rag=True in your chat requests to enable RAG.