Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,26 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
-
from
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
6 |
# Загрузка модели Hugging Face
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
@app.post("/predict")
|
10 |
async def predict(text: str):
|
11 |
# Генерация ответа с помощью модели
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
return {"response": result[0]["generated_text"]}
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from llama_cpp import Llama
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
6 |
# Загрузка модели Hugging Face
|
7 |
+
|
8 |
+
|
9 |
+
llm = Llama.from_pretrained(
|
10 |
+
repo_id="bartowski/Phi-3.5-mini-instruct-GGUF",
|
11 |
+
filename="Phi-3.5-mini-instruct-IQ2_M.gguf",
|
12 |
+
)
|
13 |
+
|
14 |
|
15 |
@app.post("/predict")
|
16 |
async def predict(text: str):
|
17 |
# Генерация ответа с помощью модели
|
18 |
+
response = llm.create_chat_completion(
|
19 |
+
messages = [
|
20 |
+
{
|
21 |
+
"role": "user",
|
22 |
+
"content": text
|
23 |
+
}
|
24 |
+
]
|
25 |
+
)
|
26 |
return {"response": result[0]["generated_text"]}
|