Skip to content

Commit ea1d459

Browse files
authored
Revert "feat: add langfuse llm node input and output" (langgenius#16947)
1 parent 377d11d commit ea1d459

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

api/core/ops/langfuse_trace/langfuse_trace.py

+1-24
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
)
3030
from core.ops.utils import filter_none_values
3131
from extensions.ext_database import db
32-
from models.model import EndUser, Message
32+
from models.model import EndUser
3333
from models.workflow import WorkflowNodeExecution
3434

3535
logger = logging.getLogger(__name__)
@@ -213,32 +213,9 @@ def workflow_trace(self, trace_info: WorkflowTraceInfo):
213213

214214
if process_data and process_data.get("model_mode") == "chat":
215215
total_token = metadata.get("total_tokens", 0)
216-
217-
# through workflow_run_id get message data
218-
message_data = (
219-
db.session.query(
220-
Message.answer_tokens, # input
221-
Message.message_tokens, # output
222-
)
223-
.filter(Message.workflow_run_id == trace_info.workflow_run_id)
224-
.first()
225-
)
226-
227-
if message_data:
228-
# chatflow data
229-
input_tokens = message_data.message_tokens
230-
output_tokens = message_data.answer_tokens
231-
else:
232-
# workflow data
233-
input_tokens = json.loads(node_execution.outputs).get("usage", {}).get("prompt_tokens", 0)
234-
output_tokens = json.loads(node_execution.outputs).get("usage", {}).get("completion_tokens", 0)
235-
236216
# add generation
237217
generation_usage = GenerationUsage(
238218
total=total_token,
239-
input=input_tokens,
240-
output=output_tokens,
241-
unit=UnitEnum.TOKENS,
242219
)
243220

244221
node_generation_data = LangfuseGeneration(

api/tasks/ops_trace_task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ def process_trace_tasks(file_info):
4949
except Exception:
5050
failed_key = f"{OPS_TRACE_FAILED_KEY}_{app_id}"
5151
redis_client.incr(failed_key)
52-
logging.exception(f"Processing trace tasks failed, app_id: {app_id}")
52+
logging.info(f"Processing trace tasks failed, app_id: {app_id}")
5353
finally:
5454
storage.delete(file_path)

0 commit comments

Comments
 (0)