Download app.py from raiden456/slut: direct link, hf CLI and curl.
- Browser
- Download file 905 Bytes
-
https://huggingface.co/spaces/raiden456/slut/resolve/main/app.py
- Command line
-
hf download hf://spaces/raiden456/slut/app.py
-
curl -L -o app.py https://huggingface.co/spaces/raiden456/slut/resolve/main/app.py
905 Bytes
| from huggingface_hub import hf_hub_download | |
| from llama_cpp import Llama | |
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import uvicorn | |
| MODEL_PATH = hf_hub_download( | |
| repo_id="bartowski/Qwen2.5-Coder-3B-Instruct-abliterated-GGUF", | |
| filename="Qwen2.5-Coder-3B-Instruct-abliterated-Q4_K_M.gguf" | |
| ) | |
| llm = Llama(model_path=MODEL_PATH, n_ctx=2048, n_threads=2, chat_format="chatml") | |
| app = FastAPI() | |
| class ChatRequest(BaseModel): | |
| model: str = "local" | |
| messages: list | |
| temperature: float = 0.7 | |
| max_tokens: int = 1024 | |
| def health(): | |
| return {"status": "ok"} | |
| def chat(req: ChatRequest): | |
| out = llm.create_chat_completion( | |
| messages=req.messages, | |
| temperature=req.temperature, | |
| max_tokens=req.max_tokens | |
| ) | |
| return out | |
| if __name__ == "__main__": | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |