730009ae87e3b94843f504deb375ae9ac26dbc41
OpenWebUI Backend Service
A backend service for OpenWebUI that provides OpenWebUI-compatible API endpoints for chat functionality and model switching.
Features
- OpenWebUI-compatible API endpoints
- Ollama API proxy
- Chat functionality with model switching
- Support for multiple LLM models (gemma3, llama3.3, llama3.1, mistral, deepseek)
- Team chat integration with OpenWebUI channels
Technology Stack
- Backend: FastAPI
- Chat Models: Ollama models via OpenWebUI
Project Structure
ai_service/
├── models/ # Model and chat services
│ ├── model_service.py
│ ├── chat_service.py
│ └── model_parameters.py
├── embeddings/ # Document processing for RAG
│ └── document_service.py
├── openwebui_api.py # OpenWebUI-compatible API endpoints
├── openwebui_channels.py # OpenWebUI channels integration
├── config.py # Configuration settings
├── api.py # FastAPI application
└── deploy.sh # Deployment script
run_ai_service.py # Script to run the service
deploy_ai_service.sh # Local deployment script
remote_deploy.sh # Remote deployment script
Setup Instructions
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Copy
.env.exampleto.envand update the values:cp ai_service/.env.example ai_service/.env # Edit the .env file with appropriate values -
Run the service:
python run_ai_service.py
Deployment
To deploy the service:
-
Local deployment:
./deploy_ai_service.sh -
Remote deployment:
./remote_deploy.sh [server_ip] [user] [port] [remote_dir]
API Documentation
Once the service is running, you can access the API documentation at:
- Swagger UI: http://localhost:5252/docs
- ReDoc: http://localhost:5252/redoc
OpenWebUI Configuration
To configure OpenWebUI to use this service as its backend:
-
Set the following environment variables in OpenWebUI:
OLLAMA_API_BASE_URL=http://your-server-ip:5252/ollama OPENAI_API_BASE_URL=http://your-server-ip:5252/api -
Restart OpenWebUI to apply the changes.
Team Chat Feature
The service now integrates with OpenWebUI's channels feature to provide team chat functionality. See TEAM_CHAT_GUIDE.md for detailed instructions on how to use team chats.
Description
Languages
Python
92%
Shell
8%