-
Notifications
You must be signed in to change notification settings - Fork 181
Feat/mock #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Feat/mock #348
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM python:3.11-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY requirements.txt ./ | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY app.py ./ | ||
|
||
EXPOSE 8000 | ||
|
||
# Environment variables for configuration | ||
ENV MODEL=Qwen/Qwen2-0.5B-Instruct | ||
ENV SERVED_MODEL_NAME=Qwen/Qwen2-0.5B-Instruct | ||
ENV LLM_KATAN_URL=http://localhost:8001 | ||
|
||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# LLM Katan Server | ||
|
||
A FastAPI wrapper around [llm-katan](https://pypi.org/project/llm-katan/) that provides the same API design as mock-vllm but uses real LLM functionality. | ||
|
||
## Architecture | ||
|
||
This server acts as a proxy that: | ||
|
||
1. Receives OpenAI-compatible API requests | ||
2. Forwards them to a running `llm-katan` instance | ||
3. Returns the responses with proper model name mapping | ||
4. Falls back to echo behavior if `llm-katan` is unavailable | ||
|
||
## Features | ||
|
||
- Same API design as mock-vllm (FastAPI-based) | ||
- Proxies requests to real `llm-katan` backend | ||
- OpenAI-compatible API endpoints: | ||
- GET /health | ||
- GET /v1/models | ||
- POST /v1/chat/completions | ||
- Fallback behavior when backend is unavailable | ||
- Configurable via environment variables | ||
|
||
## Environment Variables | ||
|
||
- `MODEL`: HuggingFace model name for llm-katan (default: `Qwen/Qwen2-0.5B-Instruct`) | ||
- `SERVED_MODEL_NAME`: Model name to expose in API (default: same as MODEL) | ||
- `LLM_KATAN_URL`: URL of the llm-katan backend (default: `http://localhost:8001`) | ||
- `HUGGINGFACE_HUB_TOKEN`: HuggingFace authentication token | ||
|
||
## Setup | ||
|
||
### 1. Start llm-katan backend | ||
|
||
```bash | ||
# Install llm-katan | ||
pip install llm-katan | ||
|
||
# Start llm-katan server on port 8001 | ||
llm-katan --model Qwen/Qwen2-0.5B-Instruct --port 8001 | ||
``` | ||
|
||
### 2. Start this FastAPI server | ||
|
||
```bash | ||
# Using Docker | ||
docker run -p 8000:8000 llm-katan-server | ||
|
||
# Or directly with Python | ||
pip install -r requirements.txt | ||
python app.py | ||
``` | ||
|
||
## Usage | ||
|
||
### Docker Compose (Recommended) | ||
|
||
```yaml | ||
services: | ||
llm-katan-backend: | ||
image: python:3.11-slim | ||
command: > | ||
sh -c "pip install llm-katan && | ||
llm-katan --model Qwen/Qwen2-0.5B-Instruct --port 8001 --host 0.0.0.0" | ||
ports: | ||
- "8001:8001" | ||
environment: | ||
- HUGGINGFACE_HUB_TOKEN=${HUGGINGFACE_HUB_TOKEN} | ||
|
||
llm-katan-server: | ||
build: . | ||
ports: | ||
- "8000:8000" | ||
environment: | ||
- MODEL=Qwen/Qwen2-0.5B-Instruct | ||
- SERVED_MODEL_NAME=Qwen/Qwen2-0.5B-Instruct | ||
- LLM_KATAN_URL=http://llm-katan-backend:8001 | ||
depends_on: | ||
- llm-katan-backend | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes to the candle binding go to feat-candle-refactoring