File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
- from typing import List , Optional
2
- from pydantic import BaseModel , ConfigDict
1
+ from typing import List , Union , Optional
2
+ from pydantic import BaseModel , RootModel , ConfigDict
3
3
4
+ class ImageContent (BaseModel ):
5
+ type : str
6
+ image_url : dict
7
+
8
+ class TextContent (BaseModel ):
9
+ type : str
10
+ text : str
11
+
12
+ class MessageContent (RootModel ):
13
+ root : Union [TextContent , ImageContent ]
4
14
5
15
class OpenAIChatMessage (BaseModel ):
6
16
role : str
7
- content : str | List
17
+ content : Union [ str , List [ MessageContent ]]
8
18
9
19
model_config = ConfigDict (extra = "allow" )
10
20
11
-
12
21
class OpenAIChatCompletionForm (BaseModel ):
13
22
stream : bool = True
14
23
model : str
15
24
messages : List [OpenAIChatMessage ]
16
25
17
26
model_config = ConfigDict (extra = "allow" )
18
27
19
-
20
28
class FilterForm (BaseModel ):
21
29
body : dict
22
30
user : Optional [dict ] = None
23
- model_config = ConfigDict (extra = "allow" )
31
+ model_config = ConfigDict (extra = "allow" )
You can’t perform that action at this time.
0 commit comments