Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,13 @@
|
|
1 |
-
from
|
|
|
2 |
|
3 |
-
|
4 |
-
repo_id="microsoft/Phi-3-mini-4k-instruct-gguf",
|
5 |
-
filename="Phi-3-mini-4k-instruct-fp16.gguf",
|
6 |
-
)
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
max_tokens=512,
|
11 |
-
echo=True
|
12 |
-
)
|
13 |
-
print(output)
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
app = FastAPI()
|
|
|
|
|
|
|
5 |
|
6 |
+
# Загрузка модели Hugging Face
|
7 |
+
model = pipeline("text-generation", model="bartowski/Phi-3.5-mini-instruct-GGUF")
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
@app.post("/predict")
|
10 |
+
async def predict(text: str):
|
11 |
+
# Генерация ответа с помощью модели
|
12 |
+
result = model(text, max_length=50, num_return_sequences=1)
|
13 |
+
return {"response": result[0]["generated_text"]}
|