11import time
22
3- from pydantic import BaseModel , Field
3+ from pydantic import BaseModel , Field , field_validator
44from typing import Dict , List , Optional , Union , Literal
55import uuid
66
@@ -9,7 +9,7 @@ class ChatCompletionRequest(BaseModel):
99 # The openai api native parameters
1010 model : str
1111 messages : List [Dict [str , str ]]
12- function_call : Optional [str ] = ' none'
12+ function_call : Optional [str ] = " none"
1313 temperature : Optional [float ] = 1
1414 top_p : Optional [float ] = 1.0
1515 n : Optional [int ] = 1
@@ -52,6 +52,10 @@ class ChatCompletionResponse(BaseModel):
5252 choices : List [ChatCompletionResponseChoice ]
5353 usage : UsageInfo
5454
55+ @field_validator ("id" , mode = "before" )
56+ def ensure_id_is_str (cls , v ):
57+ return str (v )
58+
5559
5660class DeltaMessage (BaseModel ):
5761 role : Optional [str ] = None
@@ -70,3 +74,7 @@ class ChatCompletionStreamResponse(BaseModel):
7074 created : int = Field (default_factory = lambda : int (time .time ()))
7175 model : str
7276 choices : List [ChatCompletionStreamResponseChoice ]
77+
78+ @field_validator ("id" , mode = "before" )
79+ def ensure_id_is_str (cls , v ):
80+ return str (v )
0 commit comments