Spaces:
Running
Running
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 | |
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} |