Spaces:
Running
Running
File size: 703 Bytes
1c0e6cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
from fastapi import FastAPI, Request
from pydantic import BaseModel
app = FastAPI()
# Определяем модель для запроса
class Message(BaseModel):
role: str
content: str
class RequestBody(BaseModel):
model: str
messages: list[Message]
temperature: float
top_p: float
max_tokens: int
@app.post("/api/v1")
async def generate_response(request_body: RequestBody):
# Извлечение и подготовка сообщений
input_text = "\n".join([f"{msg.role}: {msg.content}" for msg in request_body.messages])
response = input_text
# Возвращаем ответ в формате JSON
return {"response": response} |