Skip to content

Commit e4bcc7b

Browse files
committed
rearrange spans
1 parent a09044a commit e4bcc7b

4 files changed

Lines changed: 349 additions & 273 deletions

File tree

langfuse/_client/attributes.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def create_span_attributes(
9393
level: Optional[SpanLevel] = None,
9494
status_message: Optional[str] = None,
9595
version: Optional[str] = None,
96-
observation_type: Optional[str] = None,
96+
observation_type: Optional[Literal["span", "guardrail"]] = "span",
9797
) -> dict:
9898
attributes = {
99-
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: observation_type or "span",
99+
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: observation_type,
100100
LangfuseOtelSpanAttributes.OBSERVATION_LEVEL: level,
101101
LangfuseOtelSpanAttributes.OBSERVATION_STATUS_MESSAGE: status_message,
102102
LangfuseOtelSpanAttributes.VERSION: version,
@@ -123,9 +123,20 @@ def create_generation_attributes(
123123
usage_details: Optional[Dict[str, int]] = None,
124124
cost_details: Optional[Dict[str, float]] = None,
125125
prompt: Optional[PromptClient] = None,
126+
observation_type: Optional[
127+
Literal[
128+
"generation",
129+
"agent",
130+
"tool",
131+
"chain",
132+
"retriever",
133+
"evaluator",
134+
"embedding",
135+
]
136+
] = "generation",
126137
) -> dict:
127138
attributes = {
128-
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: "generation",
139+
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: observation_type,
129140
LangfuseOtelSpanAttributes.OBSERVATION_LEVEL: level,
130141
LangfuseOtelSpanAttributes.OBSERVATION_STATUS_MESSAGE: status_message,
131142
LangfuseOtelSpanAttributes.VERSION: version,

langfuse/_client/client.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -848,22 +848,22 @@ def start_as_current_observation(
848848

849849
if as_type == "generation":
850850
return self.start_as_current_generation(
851-
trace_context=trace_context,
852-
name=name,
853-
input=input,
854-
output=output,
855-
metadata=metadata,
856-
version=version,
857-
level=level,
858-
status_message=status_message,
859-
completion_start_time=completion_start_time,
860-
model=model,
861-
model_parameters=model_parameters,
862-
usage_details=usage_details,
863-
cost_details=cost_details,
864-
prompt=prompt,
865-
end_on_exit=end_on_exit,
866-
)
851+
trace_context=trace_context,
852+
name=name,
853+
input=input,
854+
output=output,
855+
metadata=metadata,
856+
version=version,
857+
level=level,
858+
status_message=status_message,
859+
completion_start_time=completion_start_time,
860+
model=model,
861+
model_parameters=model_parameters,
862+
usage_details=usage_details,
863+
cost_details=cost_details,
864+
prompt=prompt,
865+
end_on_exit=end_on_exit,
866+
)
867867

868868
if trace_context:
869869
trace_id = trace_context.get("trace_id", None)

0 commit comments

Comments
 (0)