mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
Merge f4dfc37609 into 26ba02d3ce
This commit is contained in:
commit
16645c1fcf
2 changed files with 8 additions and 1 deletions
|
|
@ -688,6 +688,7 @@ def _output_items(item: object) -> tuple[dict[str, object], ...]:
|
|||
"call_id": _attr(item, "call_id", ""),
|
||||
"type": "function_call",
|
||||
"arguments": safe_json_loads(arguments, default={}) if isinstance(arguments, str) else arguments,
|
||||
**({"namespace": namespace} if (namespace := _attr(item, "namespace")) is not None else {}),
|
||||
},
|
||||
)
|
||||
return ()
|
||||
|
|
|
|||
|
|
@ -976,7 +976,8 @@ class TestLangfuseOtelResponsesAPI:
|
|||
assert len(trace_output_calls) > 0, "trace.output should be set"
|
||||
assert trace_output_calls[0].args[2] == output_json
|
||||
|
||||
def test_responses_api_with_function_calls(self):
|
||||
@pytest.mark.parametrize("namespace", (None, "weather", ""))
|
||||
def test_responses_api_with_function_calls(self, namespace: str | None):
|
||||
"""Test Langfuse OTEL logger with Responses API function_call output."""
|
||||
from litellm.types.integrations.langfuse_otel import LangfuseSpanAttributes
|
||||
from openai.types.responses import ResponseFunctionToolCall
|
||||
|
|
@ -990,6 +991,7 @@ class TestLangfuseOtelResponsesAPI:
|
|||
id="fc-123",
|
||||
type="function_call",
|
||||
name="get_weather",
|
||||
namespace=namespace,
|
||||
call_id="call-abc",
|
||||
arguments='{"location": "San Francisco", "unit": "celsius"}',
|
||||
status="completed",
|
||||
|
|
@ -1037,6 +1039,10 @@ class TestLangfuseOtelResponsesAPI:
|
|||
assert output_data[0]["call_id"] == "call-abc"
|
||||
assert output_data[0]["arguments"]["location"] == "San Francisco"
|
||||
assert output_data[0]["arguments"]["unit"] == "celsius"
|
||||
if namespace is None:
|
||||
assert "namespace" not in output_data[0]
|
||||
else:
|
||||
assert output_data[0]["namespace"] == namespace
|
||||
|
||||
def test_responses_api_function_call_with_redacted_arguments(self):
|
||||
"""Sentinel arguments (invalid JSON) must not kill the whole observation output."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue