Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from llama_cpp import Llama | |
app = FastAPI() | |
# Загрузка модели Hugging Face | |
llm = Llama.from_pretrained( | |
repo_id="bartowski/Phi-3.5-mini-instruct-GGUF", | |
filename="Phi-3.5-mini-instruct-IQ2_M.gguf", | |
) | |
async def predict(text: str): | |
# Генерация ответа с помощью модели | |
response = llm.create_chat_completion( | |
messages = [ | |
{ | |
"role": "user", | |
"content": text | |
} | |
] | |
) | |
return {"response": result[0]["generated_text"]} |