File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
pydantic_ai_slim/pydantic_ai/ui Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,17 @@ class MessagesBuilder:
1111
1212 messages : list [ModelMessage ] = field (default_factory = list )
1313
14- def add (self , part : ModelRequest | ModelResponse | ModelRequestPart | ModelResponsePart ) -> None :
14+ def add (self , part : ModelRequestPart | ModelResponsePart ) -> None :
1515 """Add a new part, creating a new request or response message if necessary."""
1616 last_message = self .messages [- 1 ] if self .messages else None
1717 if isinstance (part , get_union_args (ModelRequestPart )):
18+ part = cast (ModelRequestPart , part )
1819 if isinstance (last_message , ModelRequest ):
19- last_message .parts = [* last_message .parts , cast ( ModelRequestPart , part ) ]
20+ last_message .parts = [* last_message .parts , part ]
2021 else :
2122 self .messages .append (ModelRequest (parts = [part ]))
2223 else :
24+ part = cast (ModelResponsePart , part )
2325 if isinstance (last_message , ModelResponse ):
2426 last_message .parts = [* last_message .parts , part ]
2527 else :
You can’t perform that action at this time.
0 commit comments