mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-05 08:07:05 +00:00
Merge 7c71f575a9 into e52f05566d
This commit is contained in:
commit
48df116a10
2 changed files with 34 additions and 0 deletions
|
|
@ -174,6 +174,13 @@ class LangfuseOtelLogger(OpenTelemetry):
|
|||
safe_dumps(output_data),
|
||||
)
|
||||
|
||||
results: Final = response_obj.get("results", [])
|
||||
if results:
|
||||
safe_set_attribute(
|
||||
span,
|
||||
LangfuseSpanAttributes.OBSERVATION_OUTPUT.value,
|
||||
safe_dumps(results),
|
||||
)
|
||||
output: Final = response_obj.get("output", [])
|
||||
if output:
|
||||
output_items_data: Final[list[dict]] = []
|
||||
|
|
|
|||
|
|
@ -336,6 +336,33 @@ class TestLangfuseOtelIntegration:
|
|||
actual == expect_output
|
||||
), "Mismatch in observation input/output OTEL attributes."
|
||||
|
||||
def test_set_langfuse_specific_attributes_with_rerank_results(self):
|
||||
from litellm.types.integrations.langfuse_otel import LangfuseSpanAttributes
|
||||
from litellm.types.rerank import RerankResponse
|
||||
|
||||
response_obj = RerankResponse(
|
||||
id="rerank-test",
|
||||
results=[
|
||||
{"index": 2, "relevance_score": 0.98},
|
||||
{"index": 0, "relevance_score": 0.41},
|
||||
],
|
||||
)
|
||||
|
||||
with patch(
|
||||
"litellm.integrations.arize._utils.safe_set_attribute"
|
||||
) as mock_safe_set_attribute:
|
||||
LangfuseOtelLogger._set_langfuse_specific_attributes(
|
||||
MagicMock(), {}, response_obj
|
||||
)
|
||||
|
||||
output_calls = [
|
||||
call
|
||||
for call in mock_safe_set_attribute.call_args_list
|
||||
if call.args[1] == LangfuseSpanAttributes.OBSERVATION_OUTPUT.value
|
||||
]
|
||||
assert len(output_calls) == 1
|
||||
assert json.loads(output_calls[0].args[2]) == response_obj.results
|
||||
|
||||
def test_set_langfuse_specific_attributes_with_tool_calls(self):
|
||||
"""Test that _set_langfuse_specific_attributes correctly sets observation.output with tool calls in Langfuse format."""
|
||||
from litellm.types.integrations.langfuse_otel import LangfuseSpanAttributes
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue