Skip to content

Commit

Permalink
fix: Missing model information in llm span of Langfuse langgenius#9029 (
Browse files Browse the repository at this point in the history
langgenius#9030)

Co-authored-by: corel <corelchen@qq.com>
  • Loading branch information
2 people authored and cuiks committed Oct 8, 2024
1 parent 922c292 commit 2c49251
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion api/core/ops/langfuse_trace/langfuse_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ def workflow_trace(self, trace_info: WorkflowTraceInfo):
"status": status,
}
)
process_data = json.loads(node_execution.process_data) if node_execution.process_data else {}
model_provider = process_data.get("model_provider", None)
model_name = process_data.get("model_name", None)
if model_provider is not None and model_name is not None:
metadata.update(
{
"model_provider": model_provider,
"model_name": model_name,
}
)

# add span
if trace_info.message_id:
Expand Down Expand Up @@ -191,7 +201,6 @@ def workflow_trace(self, trace_info: WorkflowTraceInfo):

self.add_span(langfuse_span_data=span_data)

process_data = json.loads(node_execution.process_data) if node_execution.process_data else {}
if process_data and process_data.get("model_mode") == "chat":
total_token = metadata.get("total_tokens", 0)
# add generation
Expand Down

0 comments on commit 2c49251

Please sign in to comment.