lalashechka commited on
Commit
1c0e6cc
·
verified ·
1 Parent(s): 762701c

Create app.py

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