mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-25 05:54:53 +00:00
Merge 1619f7be92 into 2e427c6247
This commit is contained in:
commit
8440d6bbbe
2 changed files with 10 additions and 0 deletions
|
|
@ -815,6 +815,7 @@ def _output_choices(response: Mapping[str, object]) -> tuple[Mapping[str, object
|
|||
or _search_choices(response)
|
||||
or _image_choices(response)
|
||||
or _binary_choices(response)
|
||||
or _passthrough_choices(response)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -924,6 +925,13 @@ def _image_location(item: Mapping[str, object]) -> str | None:
|
|||
return f"b64_json image ({len(encoded) * 3 // 4 - encoded[-2:].count('=')} bytes)"
|
||||
|
||||
|
||||
def _passthrough_choices(response: Mapping[str, object]) -> tuple[_Choice, ...]:
|
||||
body: Final = response.get("response")
|
||||
mapping: Final = as_str_mapping(body)
|
||||
text: Final = json.dumps(dict(mapping)) if mapping is not None else as_str(body)
|
||||
return (_text_choice(text),) if text else ()
|
||||
|
||||
|
||||
def _binary_choices(response: Mapping[str, object]) -> tuple[_Choice, ...]:
|
||||
size: Final = as_int(response.get("num_bytes"))
|
||||
if size is None:
|
||||
|
|
|
|||
|
|
@ -702,6 +702,8 @@ def test_langfuse_mapper_renders_an_ocr_call_with_the_page_markdown_as_output():
|
|||
("amoderation", {"results": [{"flagged": True, "categories": {"violence": True}}]}, "flagged: violence"),
|
||||
("aimage_generation", {"data": [{"b64_json": "QUJDRA=="}]}, "b64_json image (4 bytes)"),
|
||||
("aspeech", {"object": "binary", "content_type": "audio/mpeg", "num_bytes": 9}, "audio/mpeg (9 bytes)"),
|
||||
("pass_through_endpoint", {"response": '{"answers": {"q": 0.9}}'}, '{"answers": {"q": 0.9}}'),
|
||||
("pass_through_endpoint", {"response": {"answers": {"q": 0.9}}}, '{"answers": {"q": 0.9}}'),
|
||||
],
|
||||
)
|
||||
def test_langfuse_mapper_renders_every_non_chat_route_output_as_an_assistant_message(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue