Skip to content

Commit 81b255a

Browse files
committed
lower case
1 parent ab0cbf3 commit 81b255a

5 files changed

Lines changed: 101 additions & 96 deletions

File tree

langfuse/_client/client.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,12 @@ def start_as_current_span(
359359
Literal[
360360
"generation",
361361
"span",
362-
"GENERATION",
363-
"EVENT",
364-
"SPAN",
365-
"AGENT",
366-
"TOOL",
367-
"CHAIN",
368-
"RETRIEVER",
369-
"EMBEDDING",
362+
"event",
363+
"agent",
364+
"tool",
365+
"chain",
366+
"retriever",
367+
"embedding",
370368
]
371369
],
372370
) -> _AgnosticContextManager[LangfuseSpan]:
@@ -691,30 +689,30 @@ def _get_span_class(
691689
"span",
692690
"generation",
693691
"event",
694-
"AGENT",
695-
"TOOL",
696-
"CHAIN",
697-
"RETRIEVER",
698-
"EMBEDDING",
692+
"agent",
693+
"tool",
694+
"chain",
695+
"retriever",
696+
"embedding",
699697
],
700698
):
701699
"""Get the appropriate span class based on as_type."""
702700
# TODO: make it case insensitive
703-
if as_type == "AGENT":
701+
if as_type == "agent":
704702
return LangfuseAgent
705-
elif as_type == "TOOL":
703+
elif as_type == "tool":
706704
return LangfuseTool
707-
elif as_type == "CHAIN":
705+
elif as_type == "chain":
708706
return LangfuseChain
709-
elif as_type == "RETRIEVER":
707+
elif as_type == "retriever":
710708
return LangfuseRetriever
711-
elif as_type == "EMBEDDING":
709+
elif as_type == "embedding":
712710
return LangfuseEmbedding
713-
elif as_type in ("generation", "GENERATION"):
711+
elif as_type in ("generation"):
714712
return LangfuseGeneration
715-
elif as_type in ("event", "EVENT"):
713+
elif as_type in ("event"):
716714
return LangfuseEvent
717-
elif as_type in ("span", "SPAN"):
715+
elif as_type in ("span"):
718716
return LangfuseSpan
719717
else:
720718
return LangfuseSpan
@@ -775,7 +773,14 @@ def _start_as_current_otel_span_with_processed_media(
775773
name: str,
776774
as_type: Optional[
777775
Literal[
778-
"generation", "span", "event", "AGENT", "TOOL", "CHAIN", "RETRIEVER"
776+
"generation",
777+
"span",
778+
"event",
779+
"agent",
780+
"tool",
781+
"chain",
782+
"retriever",
783+
"embedding",
779784
]
780785
] = None,
781786
end_on_exit: Optional[bool] = None,

langfuse/_client/constants.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
# Valid observation types for the @observe decorator
99
VALID_OBSERVATION_TYPES = {
10-
"SPAN",
11-
"EVENT",
12-
"GENERATION",
13-
"AGENT",
14-
"TOOL",
15-
"CHAIN",
16-
"RETRIEVER",
17-
"EMBEDDING",
10+
"span",
11+
"event",
12+
"generation",
13+
"agent",
14+
"tool",
15+
"chain",
16+
"retriever",
17+
"embedding",
1818
}

langfuse/_client/observe.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ def observe(
7070
as_type: Optional[Literal["generation"]] = None,
7171
type: Optional[
7272
Literal[
73-
"SPAN",
74-
"EVENT",
75-
"GENERATION",
76-
"AGENT",
77-
"TOOL",
78-
"CHAIN",
79-
"RETRIEVER",
80-
"EMBEDDING",
73+
"span",
74+
"event",
75+
"generation",
76+
"agent",
77+
"tool",
78+
"chain",
79+
"retriever",
80+
"embedding",
8181
]
8282
] = None,
8383
capture_input: Optional[bool] = None,
@@ -93,14 +93,14 @@ def observe(
9393
as_type: Optional[Literal["generation"]] = None,
9494
type: Optional[
9595
Literal[
96-
"SPAN",
97-
"EVENT",
98-
"GENERATION",
99-
"AGENT",
100-
"TOOL",
101-
"CHAIN",
102-
"RETRIEVER",
103-
"EMBEDDING",
96+
"span",
97+
"event",
98+
"generation",
99+
"agent",
100+
"tool",
101+
"chain",
102+
"retriever",
103+
"embedding",
104104
]
105105
] = None,
106106
capture_input: Optional[bool] = None,
@@ -122,7 +122,7 @@ def observe(
122122
as_type (Optional[Literal["generation"]]): Set to "generation" to create a specialized LLM generation span
123123
with model metrics support, suitable for tracking language model outputs.
124124
type (Optional[Literal]): Set the observation type for agentic workflows. Supported values:
125-
"GENERATION", "AGENT", "TOOL", "CHAIN", "RETRIEVER", "EMBEDDING". When specified, creates spans with
125+
"generation", "agent", "tool", "chain", "retriever", "embedding". When specified, creates spans with
126126
the specified type for graph visualization and filtering in the Langfuse UI.
127127
128128
Returns:
@@ -151,7 +151,7 @@ async def generate_answer(query):
151151
152152
For automatic graph instrumentation with agent workflows:
153153
```python
154-
@observe(type="AGENT")
154+
@observe(type="agent")
155155
def planning_agent():
156156
return create_plan()
157157
```
@@ -259,15 +259,14 @@ def _async_observe(
259259
name: Optional[str],
260260
as_type: Optional[
261261
Literal[
262+
"span",
262263
"generation",
263-
"GENERATION",
264-
"EVENT",
265-
"SPAN",
266-
"AGENT",
267-
"TOOL",
268-
"CHAIN",
269-
"RETRIEVER",
270-
"EMBEDDING",
264+
"event",
265+
"agent",
266+
"tool",
267+
"chain",
268+
"retriever",
269+
"embedding",
271270
]
272271
],
273272
capture_input: bool,

langfuse/_client/span.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ class LangfuseGraphObservation(LangfuseSpanWrapper):
12241224
"""Base class for agentic workflow observations.
12251225
12261226
This class provides a common foundation for specialized observation types
1227-
used in agentic workflows: AGENT, TOOL, CHAIN, RETRIEVER, and EMBEDDING.
1227+
used in agentic workflows: agent, tool, chain, retriever, and embedding.
12281228
All graph observations use span-type attributes but with specific observation types.
12291229
"""
12301230

@@ -1245,7 +1245,7 @@ def __init__(
12451245
"""Initialize a new graph observation span.
12461246
12471247
Args:
1248-
observation_type: The specific observation type (e.g., "AGENT", "TOOL")
1248+
observation_type: The specific observation type (e.g., "agent", "tool", ...)
12491249
otel_span: The OpenTelemetry span to wrap
12501250
langfuse_client: Reference to the parent Langfuse client
12511251
input: Input data for the observation
@@ -1331,45 +1331,45 @@ def update(
13311331

13321332

13331333
class LangfuseAgent(LangfuseGraphObservation):
1334-
"""Specialized span for AGENT observations in agentic workflows."""
1334+
"""Specialized span for agent observations in agentic workflows."""
13351335

13361336
def __init__(self, **kwargs):
13371337
"""Initialize a new LangfuseAgent span."""
1338-
kwargs["observation_type"] = "AGENT"
1338+
kwargs["observation_type"] = "agent"
13391339
super().__init__(**kwargs)
13401340

13411341

13421342
class LangfuseTool(LangfuseGraphObservation):
1343-
"""Specialized span for TOOL observations in agentic workflows."""
1343+
"""Specialized span for tool observations in agentic workflows."""
13441344

13451345
def __init__(self, **kwargs):
13461346
"""Initialize a new LangfuseTool span."""
1347-
kwargs["observation_type"] = "TOOL"
1347+
kwargs["observation_type"] = "tool"
13481348
super().__init__(**kwargs)
13491349

13501350

13511351
class LangfuseChain(LangfuseGraphObservation):
1352-
"""Specialized span for CHAIN observations in agentic workflows."""
1352+
"""Specialized span for chain observations in agentic workflows."""
13531353

13541354
def __init__(self, **kwargs):
13551355
"""Initialize a new LangfuseChain span."""
1356-
kwargs["observation_type"] = "CHAIN"
1356+
kwargs["observation_type"] = "chain"
13571357
super().__init__(**kwargs)
13581358

13591359

13601360
class LangfuseRetriever(LangfuseGraphObservation):
1361-
"""Specialized span for RETRIEVER observations in agentic workflows."""
1361+
"""Specialized span for retriever observations in agentic workflows."""
13621362

13631363
def __init__(self, **kwargs):
13641364
"""Initialize a new LangfuseRetriever span."""
1365-
kwargs["observation_type"] = "RETRIEVER"
1365+
kwargs["observation_type"] = "retriever"
13661366
super().__init__(**kwargs)
13671367

13681368

13691369
class LangfuseEmbedding(LangfuseGraphObservation):
1370-
"""Specialized span for EMBEDDING observations in agentic workflows."""
1370+
"""Specialized span for embedding observations in agentic workflows."""
13711371

13721372
def __init__(self, **kwargs):
13731373
"""Initialize a new LangfuseEmbedding span."""
1374-
kwargs["observation_type"] = "EMBEDDING"
1374+
kwargs["observation_type"] = "embedding"
13751375
super().__init__(**kwargs)

0 commit comments

Comments
 (0)