Update main.py
Browse files
main.py
CHANGED
@@ -7,6 +7,8 @@ from aiohttp import ClientSession
|
|
7 |
from fastapi import FastAPI, HTTPException
|
8 |
from pydantic import BaseModel
|
9 |
from typing import List, Dict, Any, Optional
|
|
|
|
|
10 |
|
11 |
# Mock implementations for ImageResponse and to_data_uri
|
12 |
class ImageResponse:
|
@@ -196,10 +198,14 @@ async def chat_completions(request: ChatRequest):
|
|
196 |
async for chunk in async_generator:
|
197 |
response_content += chunk if isinstance(chunk, str) else chunk.content # Concatenate response
|
198 |
|
|
|
|
|
|
|
|
|
199 |
return {
|
200 |
-
"id":
|
201 |
"object": "chat.completion",
|
202 |
-
"created":
|
203 |
"model": request.model,
|
204 |
"choices": [
|
205 |
{
|
@@ -211,4 +217,4 @@ async def chat_completions(request: ChatRequest):
|
|
211 |
"index": 0
|
212 |
}
|
213 |
]
|
214 |
-
}
|
|
|
7 |
from fastapi import FastAPI, HTTPException
|
8 |
from pydantic import BaseModel
|
9 |
from typing import List, Dict, Any, Optional
|
10 |
+
import time
|
11 |
+
import uuid
|
12 |
|
13 |
# Mock implementations for ImageResponse and to_data_uri
|
14 |
class ImageResponse:
|
|
|
198 |
async for chunk in async_generator:
|
199 |
response_content += chunk if isinstance(chunk, str) else chunk.content # Concatenate response
|
200 |
|
201 |
+
# Generate a unique ID and use the current timestamp
|
202 |
+
response_id = f"chatcmpl-{uuid.uuid4()}"
|
203 |
+
created_timestamp = int(time.time())
|
204 |
+
|
205 |
return {
|
206 |
+
"id": response_id,
|
207 |
"object": "chat.completion",
|
208 |
+
"created": created_timestamp,
|
209 |
"model": request.model,
|
210 |
"choices": [
|
211 |
{
|
|
|
217 |
"index": 0
|
218 |
}
|
219 |
]
|
220 |
+
}
|