Skip to content

Commit 6da68c9

Browse files
committed
fix tests
1 parent bb4cfab commit 6da68c9

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

langfuse/_client/constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
ObservationTypeSpanLike,
3131
]
3232

33-
ObservationTypeLiteral: TypeAlias = Union[
34-
ObservationTypeLiteralNoEvent, Literal["event"]
35-
]
3633
"""Enumeration of valid observation types for Langfuse tracing.
3734
3835
This Literal defines all available observation types that can be used with the @observe
3936
decorator and other Langfuse SDK methods.
4037
"""
38+
ObservationTypeLiteral: TypeAlias = Union[
39+
ObservationTypeLiteralNoEvent, Literal["event"]
40+
]
4141

4242

4343
def get_observation_types_list(

langfuse/_client/observe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def observe(
110110
as_type (Optional[Literal]): Set the observation type. Supported values:
111111
"generation", "span", "agent", "tool", "chain", "retriever", "embedding", "evaluator", "guardrail".
112112
Observation types are highlighted in the Langfuse UI for filtering and visualization.
113-
The types "generation", "agent", "tool", "chain", "retriever", "embedding", "evaluator" create a span which
114-
allows to set additional attributes such as model metrics..
113+
The types "generation" and "embedding" create a span on which additional attributes such as model metrics
114+
can be set.
115115
116116
Returns:
117117
Callable: A wrapped version of the original function that automatically creates and manages Langfuse spans.

tests/test_core_sdk.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,7 @@ def test_start_as_current_observation_types():
19311931
assert len(observations) == 1, f"Expected one {obs_type.upper()} observation"
19321932

19331933

1934+
@pytest.mark.skip(reason="Works after OSS release 3.102")
19341935
def test_that_generation_like_properties_are_actually_created():
19351936
"""Test that generation-like observation types properly support generation properties."""
19361937
from langfuse._client.constants import (
@@ -1943,7 +1944,7 @@ def test_that_generation_like_properties_are_actually_created():
19431944

19441945
test_model = "test-model"
19451946
test_completion_start_time = datetime.now(timezone.utc)
1946-
test_model_parameters = {"temperature": 0.7, "max_tokens": 100}
1947+
test_model_parameters = {"temperature": "0.7", "max_tokens": "100"}
19471948
test_usage_details = {"prompt_tokens": 10, "completion_tokens": 20}
19481949
test_cost_details = {"input": 0.01, "output": 0.02, "total": 0.03}
19491950

@@ -2012,8 +2013,11 @@ def test_that_generation_like_properties_are_actually_created():
20122013
test_usage_details, total=30
20132014
), f"{obs_type} should persist usage_details" # API adds total
20142015

2015-
# completion_start_time
2016-
if obs.completion_start_time is not None:
2017-
assert (
2018-
obs.completion_start_time is not None
2019-
), f"{obs_type} should persist completion_start_time property"
2016+
assert (
2017+
obs.cost_details == test_cost_details
2018+
), f"{obs_type} should persist cost_details"
2019+
2020+
# completion_start_time, because of time skew not asserting time
2021+
assert (
2022+
obs.completion_start_time is not None
2023+
), f"{obs_type} should persist completion_start_time property"

0 commit comments

Comments
 (0)