Skip to content

Commit df8ff8e

Browse files
committed
cleanup
1 parent 7f71789 commit df8ff8e

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

langfuse/_client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ def start_as_current_generation(
667667
),
668668
)
669669

670-
def _get_span_class(self, as_type: str):
670+
def _get_span_class(self, as_type: Literal["span", "generation", "event", "AGENT", "TOOL", "CHAIN", "RETRIEVER", "EMBEDDING"]):
671671
"""Get the appropriate span class based on as_type."""
672672
# TODO: make it case insensitive
673673
if as_type == "AGENT":

langfuse/_client/span.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,10 @@ def __init__(
152152
observation_type=as_type,
153153
)
154154

155-
# Keep OBSERVATION_TYPE in attributes - don't remove it
156-
# attributes.pop(LangfuseOtelSpanAttributes.OBSERVATION_TYPE, None)
155+
attributes.pop(LangfuseOtelSpanAttributes.OBSERVATION_TYPE, None)
157156

158-
final_attributes = {k: v for k, v in attributes.items() if v is not None}
159-
self._otel_span.set_attributes(final_attributes)
160-
161-
# Check what actually got set
162-
actual_attributes = dict(self._otel_span.attributes)
163-
obs_type_value = actual_attributes.get(
164-
"langfuse.observation.type", "NOT_FOUND"
157+
self._otel_span.set_attributes(
158+
{k: v for k, v in attributes.items() if v is not None}
165159
)
166160

167161
def end(self, *, end_time: Optional[int] = None) -> "LangfuseSpanWrapper":
@@ -552,11 +546,9 @@ def __init__(
552546
level: Importance level of the span (info, warning, error)
553547
status_message: Optional status message for the span
554548
"""
555-
# Default to span if not provided mimicing previous behavior
556-
final_as_type = as_type or "span"
557549
super().__init__(
558550
otel_span=otel_span,
559-
as_type=final_as_type,
551+
as_type="span",
560552
langfuse_client=langfuse_client,
561553
input=input,
562554
output=output,

langfuse/openai.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,7 @@ def _extract_streamed_openai_response(resource: Any, chunks: Any) -> Any:
570570
)
571571
curr["arguments"] += getattr(tool_call_chunk, "arguments", "")
572572

573-
elif (
574-
delta.get("tool_calls", None) is not None
575-
and len(delta.get("tool_calls")) > 0
576-
):
573+
elif delta.get("tool_calls", None) is not None and len(delta.get("tool_calls")) > 0:
577574
curr = completion["tool_calls"]
578575
tool_call_chunk = getattr(
579576
delta.get("tool_calls", None)[0], "function", None

0 commit comments

Comments
 (0)