Sanya2025 commited on
Commit
4c679bb
·
verified ·
1 Parent(s): ddbe49d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_cpp import Llama
2
+ from fastapi import FastAPI
3
+ from huggingface_hub import hf_hub_download
4
+ import os
5
+
6
+ app = FastAPI()
7
+
8
+ # Скачиваем GGUF при первом старте (или добавьте в образ через Dockerfile)
9
+ model_path = hf_hub_download(
10
+ repo_id="Sanya2025/Proxima_B-instruct",
11
+ filename="proxima-b-instruct-q4_k_m.gguf"
12
+ )
13
+
14
+ llm = Llama(
15
+ model_path=model_path,
16
+ n_ctx=4096,
17
+ n_threads=4,
18
+ verbose=False
19
+ )
20
+
21
+ @app.post("/v1/chat/completions")
22
+ async def chat(request: dict):
23
+ messages = request.get("messages", [])
24
+ response = llm.create_chat_completion(messages=messages)
25
+ return response
26
+
27
+ @app.get("/")
28
+ async def health():
29
+ return {"status": "ok", "model": "proxima-b-instruct"}