File size: 728 Bytes
74b1bac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from typing import List, Union, Optional
from pydantic import BaseModel, RootModel, ConfigDict
class ImageContent(BaseModel):
type: str
image_url: dict
class TextContent(BaseModel):
type: str
text: str
class MessageContent(RootModel):
root: Union[TextContent, ImageContent]
class OpenAIChatMessage(BaseModel):
role: str
content: Union[str, List[MessageContent]]
model_config = ConfigDict(extra="allow")
class OpenAIChatCompletionForm(BaseModel):
stream: bool = True
model: str
messages: List[OpenAIChatMessage]
model_config = ConfigDict(extra="allow")
class FilterForm(BaseModel):
body: dict
user: Optional[dict] = None
model_config = ConfigDict(extra="allow") |