mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(caching): pick the Responses text field without a Final inside a loop
Some checks failed
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Some checks failed
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
7c1390c836
commit
1c4a69bfbe
1 changed files with 10 additions and 8 deletions
|
|
@ -297,14 +297,16 @@ def _responses_text_parts(value: object, positions: Mapping[str, int]) -> Iterat
|
|||
|
||||
|
||||
def _responses_first_text_field(item: object, positions: Mapping[str, int]) -> Iterator[str]:
|
||||
for key in ("text", "output", "input_text", "output_text"):
|
||||
text: Final = _field(item, key)
|
||||
if isinstance(text, (list, tuple)):
|
||||
yield from _responses_text_parts(text, positions)
|
||||
return
|
||||
if isinstance(text, str) and text.strip():
|
||||
yield text.strip()
|
||||
return
|
||||
fields: Final = (_field(item, key) for key in ("text", "output", "input_text", "output_text"))
|
||||
text: Final = next((field for field in fields if _is_text_field(field)), None)
|
||||
if isinstance(text, (list, tuple)):
|
||||
yield from _responses_text_parts(text, positions)
|
||||
elif isinstance(text, str):
|
||||
yield text.strip()
|
||||
|
||||
|
||||
def _is_text_field(field: object) -> bool:
|
||||
return isinstance(field, (list, tuple)) or (isinstance(field, str) and bool(field.strip()))
|
||||
|
||||
|
||||
def _tool_call_text(name: object, arguments: object) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue