This project is part of the KI-4-KMU initiative developed at FHNW, which provides SMEs with practical AI tools and methodologies.
It acts as a proxy server that exposes OpenAI-compatible endpoints, automatically injecting retrieved context from the KI4KMU-IngestionLayer into your prompts. This enables document-grounded question answering (RAG) using domain-specific knowledge. The system also launches an integrated Open WebUI container, providing a professional chat interface accessible at http://localhost:3000 immediately after startup.
- OpenAI-compatible API: Implements
/v1/chat/completionsand/v1/modelsendpoints. - Context Injection: Automatically queries the Ingestion Layer and injects results as a
contextrole message. - Integrated UI: Starts a pre-configured Open WebUI instance for a turnkey chat experience.
- Local Model Support: Fully compatible with LM Studio for secure, local inference.
- Streaming support: Pass-through streaming for real-time, low-latency responses.
knowledgeplatform-demo.mp4
Create a .env file based on .env.example:
BASE_URL="https://openrouter.ai/api/v1"
API_KEY="your-api-key-here"
RETRIEVAL_URL="http://localhost:8001/v1"
| Variable | Description | Default |
|---|---|---|
BASE_URL |
Upstream OpenAI-compatible API endpoint | [https://openrouter.ai/api/v1](https://openrouter.ai/api/v1) |
API_KEY |
API key for authentication | (empty) |
RETRIEVAL_URL |
Retrieval engine API endpoint (Ingestion Layer) | http://localhost:8001/v1 |
Due to specific container image requirements and the multi-service architecture (Proxy + Open WebUI), this project must be managed exclusively via Docker Compose.
To use local models, ensure LM Studio is running its Local Server. Update your .env to point to the Docker host gateway:
BASE_URL="[http://host.docker.internal:1234/v1](http://host.docker.internal:1234/v1)"
docker-compose up --build
Once the containers are running:
- API Proxy:
http://localhost:8000 - Open WebUI:
http://localhost:3000(Access this in your browser to start chatting)
Create a chat completion with retrieval-augmented context.
Request:
{
"model": "openai/gpt-4o",
"messages": [
{"role": "user", "content": "What is the compression ratio of the engine?"}
]
}
List available models from the upstream API.
app/
├── main.py # FastAPI entry point
├── api/
│ ├── chat.py # Chat completions & Context Injection
│ └── models.py # Models listing router
├── core/
│ ├── config.py # Configuration management
│ └── client.py # API Client
├── models/
│ ├── schemas.py # API models
│ └── retrieval.py # Retrieval API models
└── utils/
└── context_injector.py # Logic for merging context into messages
docker-compose run --rm app pytest tests/ -v