Skip to content

Commit c07a95a

Browse files
committed
simplify
1 parent df71a69 commit c07a95a

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

langfuse/_client/constants.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,6 @@ class ObservationType(str, enum.Enum):
2727
EVALUATOR = "EVALUATOR"
2828
GUARDRAIL = "GUARDRAIL"
2929

30-
31-
# Valid observation types for the @observe decorator (lowercase user interface)
32-
VALID_OBSERVATION_TYPES = {
33-
"span",
34-
"event",
35-
"generation",
36-
"agent",
37-
"tool",
38-
"chain",
39-
"retriever",
40-
"evaluator",
41-
"embedding",
42-
"guardrail",
43-
}
44-
4530
ObservationTypeLiteralNoEvent: TypeAlias = Literal[
4631
"span",
4732
"generation",

langfuse/_client/observe.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Union,
1717
cast,
1818
overload,
19+
get_args,
1920
)
2021

2122
from opentelemetry.util._decorator import _AgnosticContextManager
@@ -26,7 +27,6 @@
2627
)
2728

2829
from langfuse._client.constants import (
29-
VALID_OBSERVATION_TYPES,
3030
ObservationTypeLiteralNoEvent,
3131
)
3232
from langfuse._client.get_client import _set_current_public_key, get_client
@@ -169,9 +169,10 @@ def sub_process():
169169
- For async functions, the decorator returns an async function wrapper.
170170
- For sync functions, the decorator returns a synchronous wrapper.
171171
"""
172-
if as_type is not None and as_type not in VALID_OBSERVATION_TYPES:
172+
valid_types = set(get_args(ObservationTypeLiteralNoEvent))
173+
if as_type is not None and as_type not in valid_types:
173174
self._log.warning(
174-
f"Invalid as_type '{as_type}'. Valid types are: {', '.join(sorted(VALID_OBSERVATION_TYPES))}. Defaulting to 'span'."
175+
f"Invalid as_type '{as_type}'. Valid types are: {', '.join(sorted(valid_types))}. Defaulting to 'span'."
175176
)
176177
as_type = "span"
177178

0 commit comments

Comments
 (0)