Skip to content

Commit bdb8147

Browse files
committed
cleanup
1 parent 8af5b67 commit bdb8147

3 files changed

Lines changed: 7 additions & 15 deletions

File tree

langfuse/_client/client.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,11 @@ def _get_span_class(
707707
return LangfuseRetriever
708708
elif as_type == "embedding":
709709
return LangfuseEmbedding
710-
elif as_type in ("generation"):
710+
elif as_type == "generation":
711711
return LangfuseGeneration
712-
elif as_type in ("event"):
712+
elif as_type == "event":
713713
return LangfuseEvent
714-
elif as_type in ("span"):
715-
return LangfuseSpan
716-
else:
714+
elif as_type == "span":
717715
return LangfuseSpan
718716

719717
@_agnosticcontextmanager
@@ -825,6 +823,7 @@ def _start_as_current_otel_span_with_processed_media(
825823
}
826824
)
827825
elif span_class in [
826+
LangfuseSpan,
828827
LangfuseAgent,
829828
LangfuseTool,
830829
LangfuseChain,
@@ -833,9 +832,6 @@ def _start_as_current_otel_span_with_processed_media(
833832
]:
834833
# set their type internally in the class
835834
pass
836-
else:
837-
if as_type is not None:
838-
common_args["as_type"] = as_type
839835

840836
yield span_class(**common_args)
841837

langfuse/_client/observe.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,9 @@ def sub_process():
190190
raise ValueError(
191191
f"Invalid observation type '{type}'. Valid types are: {', '.join(sorted(VALID_OBSERVATION_TYPES))}"
192192
)
193-
if as_type is not None and as_type.upper() not in VALID_OBSERVATION_TYPES:
194-
valid_values = sorted(
195-
list(VALID_OBSERVATION_TYPES)
196-
+ [t.lower() for t in VALID_OBSERVATION_TYPES]
197-
)
193+
if as_type is not None and as_type not in VALID_OBSERVATION_TYPES:
198194
raise ValueError(
199-
f"Invalid as_type '{as_type}'. Valid values are: {', '.join(valid_values)}"
195+
f"Invalid as_type '{as_type}'. Valid types are: {', '.join(sorted(VALID_OBSERVATION_TYPES))}"
200196
)
201197

202198
function_io_capture_enabled = os.environ.get(

tests/test_manual_graph_instrumentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def end_agent():
6666
agent_observations = [
6767
obs
6868
for obs in all_observations
69-
if obs.type in ["agent", "tool", "retriever", "chain", "embedding"]
69+
if obs.type in ["agent", "tool", "retriever", "chain", "embedding", "AGENT", "TOOL", "RETRIEVER", "CHAIN", "EMBEDDING", "GENERATION", "generation"]
7070
]
7171

7272
assert (

0 commit comments

Comments
 (0)