JasonFinley0821 commited on
Commit
1eb4ba5
·
1 Parent(s): b82a60c

feat : add return consolelog

Browse files
Files changed (1) hide show
  1. services/linebot.py +5 -0
services/linebot.py CHANGED
@@ -136,13 +136,18 @@ def handle_message(event):
136
  # 如果上一則不是圖片 (或沒有上一則),代表這是一般的文字提問 (可能是要求生成圖片)
137
  agent_input = user_text
138
 
 
 
139
  try:
140
  # 運行 LangChain 代理人
141
  response = run_agent(agent_input)
142
  # Agent 的輸出是 JSON 字串 (無論成功或失敗)
143
  out_str = response["output"]
 
144
  tool_result = out_str.get("tool_result", {})
 
145
  final_response = out_str.get("final_response")
 
146
 
147
  if "error" in tool_result:
148
  # 3A. 處理錯誤情況 (例如:圖片下載失敗、API 錯誤)
 
136
  # 如果上一則不是圖片 (或沒有上一則),代表這是一般的文字提問 (可能是要求生成圖片)
137
  agent_input = user_text
138
 
139
+ out_str = ""
140
+
141
  try:
142
  # 運行 LangChain 代理人
143
  response = run_agent(agent_input)
144
  # Agent 的輸出是 JSON 字串 (無論成功或失敗)
145
  out_str = response["output"]
146
+ print(f"out_str:{out_str}")
147
  tool_result = out_str.get("tool_result", {})
148
+ print(f"out_str:{tool_result}")
149
  final_response = out_str.get("final_response")
150
+ print(f"out_str:{final_response}")
151
 
152
  if "error" in tool_result:
153
  # 3A. 處理錯誤情況 (例如:圖片下載失敗、API 錯誤)