Niansuh commited on
Commit
ea3d3c5
·
verified ·
1 Parent(s): 7937c8d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -3
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": "chatcmpl-1234", # Example ID, generate as needed
201
  "object": "chat.completion",
202
- "created": 1690000000, # Replace with actual timestamp
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
+ }