mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fix(file_search): serialize first_response output items to dicts for follow-up input
Pydantic model instances (ResponseFunctionToolCall, etc.) from first_response.output were included raw in follow_up_input; the transformation layer expects plain dicts and called .get() on them, raising AttributeError. Serialize via model_dump(exclude_none=True). Made-with: Cursor
This commit is contained in:
parent
dc7b7f852d
commit
1ff7c70011
1 changed files with 9 additions and 1 deletions
|
|
@ -479,8 +479,16 @@ async def aresponses_with_emulated_file_search(
|
|||
# 5. Build follow-up input: original messages + ALL first-response output items + tool results
|
||||
# Including all output items (text blocks, reasoning, non-file-search calls) ensures providers
|
||||
# like Anthropic that emit text before the tool call have complete conversation context.
|
||||
# Serialize Pydantic model instances to plain dicts so the transformation layer can call .get().
|
||||
original_input_items = list(input) if isinstance(input, (list, tuple)) else [{"role": "user", "content": str(input)}]
|
||||
first_response_output_items = list(first_response.output)
|
||||
first_response_output_items: List[Any] = []
|
||||
for _item in first_response.output:
|
||||
if isinstance(_item, dict):
|
||||
first_response_output_items.append(_item)
|
||||
elif hasattr(_item, "model_dump"):
|
||||
first_response_output_items.append(_item.model_dump(exclude_none=True)) # type: ignore[union-attr]
|
||||
else:
|
||||
first_response_output_items.append(_item)
|
||||
|
||||
follow_up_input = (
|
||||
original_input_items
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue