[Frontend] add json_schema support from OpenAI protocol (#7654)
This commit is contained in:
@@ -85,9 +85,19 @@ class UsageInfo(OpenAIBaseModel):
|
||||
completion_tokens: Optional[int] = 0
|
||||
|
||||
|
||||
class JsonSchemaResponseFormat(OpenAIBaseModel):
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
# schema is the field in openai but that causes conflicts with pydantic so
|
||||
# instead use json_schema with an alias
|
||||
json_schema: Optional[Dict[str, Any]] = Field(default=None, alias='schema')
|
||||
strict: Optional[bool] = None
|
||||
|
||||
|
||||
class ResponseFormat(OpenAIBaseModel):
|
||||
# type must be "json_object" or "text"
|
||||
type: Literal["text", "json_object"]
|
||||
# type must be "json_schema", "json_object" or "text"
|
||||
type: Literal["text", "json_object", "json_schema"]
|
||||
json_schema: Optional[JsonSchemaResponseFormat] = None
|
||||
|
||||
|
||||
class StreamOptions(OpenAIBaseModel):
|
||||
|
||||
Reference in New Issue
Block a user