Skip to content

Commit 6228fbc

Browse files
authored
add: usage_details instead usage (#2481)
1 parent 4c4d94b commit 6228fbc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def handle(self, span: LangfuseSpan, component_type: Optional[str]) -> None:
328328
if component_type in _SUPPORTED_GENERATORS:
329329
meta = span.get_data().get(_COMPONENT_OUTPUT_KEY, {}).get("meta")
330330
if meta:
331-
span.raw_span().update(usage=meta[0].get("usage") or None, model=meta[0].get("model"))
331+
span.raw_span().update(usage_details=meta[0].get("usage") or None, model=meta[0].get("model"))
332332

333333
if component_type in _SUPPORTED_CHAT_GENERATORS:
334334
replies = span.get_data().get(_COMPONENT_OUTPUT_KEY, {}).get("replies")
@@ -342,7 +342,7 @@ def handle(self, span: LangfuseSpan, component_type: Optional[str]) -> None:
342342
logger.error(f"Failed to parse completion_start_time: {completion_start_time}")
343343
completion_start_time = None
344344
span.raw_span().update(
345-
usage=meta.get("usage") or None,
345+
usage_details=meta.get("usage") or None,
346346
model=meta.get("model"),
347347
completion_start_time=completion_start_time,
348348
)

integrations/langfuse/tests/test_tracer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def test_handle_generator(self):
203203
handler.handle(mock_span, component_type="OpenAIGenerator")
204204

205205
assert mock_span.update.call_count == 1
206-
assert mock_span.update.call_args_list[0][1] == {"usage": None, "model": "test_model"}
206+
assert mock_span.update.call_args_list[0][1] == {"usage_details": None, "model": "test_model"}
207207

208208
def test_handle_chat_generator(self):
209209
mock_span = Mock()
@@ -225,7 +225,7 @@ def test_handle_chat_generator(self):
225225

226226
assert mock_span.update.call_count == 1
227227
assert mock_span.update.call_args_list[0][1] == {
228-
"usage": None,
228+
"usage_details": None,
229229
"model": "test_model",
230230
"completion_start_time": datetime.datetime( # noqa: DTZ001
231231
2021, 7, 27, 16, 2, 8, 12345
@@ -254,7 +254,7 @@ def test_handle_bad_completion_start_time(self, caplog):
254254

255255
assert mock_span.update.call_count == 1
256256
assert mock_span.update.call_args_list[0][1] == {
257-
"usage": None,
257+
"usage_details": None,
258258
"model": "test_model",
259259
"completion_start_time": None,
260260
}
@@ -348,7 +348,7 @@ def test_trace_generation(self):
348348
}
349349
with tracer.trace(operation_name="operation_name", tags=tags) as span:
350350
...
351-
assert span.raw_span()._data["usage"] is None
351+
assert span.raw_span()._data["usage_details"] is None
352352
assert span.raw_span()._data["model"] == "test_model"
353353
assert span.raw_span()._data["completion_start_time"] == datetime.datetime(2021, 7, 27, 16, 2, 8, 12345) # noqa: DTZ001
354354

@@ -415,7 +415,7 @@ def test_trace_generation_invalid_start_time(self):
415415
}
416416
with tracer.trace(operation_name="operation_name", tags=tags) as span:
417417
...
418-
assert span.raw_span()._data["usage"] is None
418+
assert span.raw_span()._data["usage_details"] is None
419419
assert span.raw_span()._data["model"] == "test_model"
420420
assert span.raw_span()._data["completion_start_time"] is None
421421

0 commit comments

Comments
 (0)