Spaces:
Sleeping
Sleeping
Commit ·
f46e2fc
1
Parent(s): 832a92e
fix : agent return out
Browse files- services/linebot.py +3 -3
services/linebot.py
CHANGED
|
@@ -139,9 +139,9 @@ def handle_message(event):
|
|
| 139 |
try:
|
| 140 |
# 運行 LangChain 代理人
|
| 141 |
response = run_agent(agent_input)
|
| 142 |
-
|
| 143 |
# Agent 的輸出是 JSON 字串 (無論成功或失敗)
|
| 144 |
-
out_str = response["
|
| 145 |
# 2. 嘗試解析 JSON 輸出
|
| 146 |
result = json.loads(out_str)
|
| 147 |
|
|
@@ -182,7 +182,7 @@ def handle_message(event):
|
|
| 182 |
event.reply_token,
|
| 183 |
TextSendMessage(text="代理人回覆格式無法識別,請聯繫管理員。")
|
| 184 |
)
|
| 185 |
-
|
| 186 |
except json.JSONDecodeError:
|
| 187 |
# 4. 處理 Agent 返回了無法解析的純文字 (非 JSON)
|
| 188 |
# 這通常發生在 Agent 決定不使用工具,直接回覆純文字,或者推理過程出錯。
|
|
|
|
| 139 |
try:
|
| 140 |
# 運行 LangChain 代理人
|
| 141 |
response = run_agent(agent_input)
|
| 142 |
+
print( response )
|
| 143 |
# Agent 的輸出是 JSON 字串 (無論成功或失敗)
|
| 144 |
+
out_str = response["structured_response"]
|
| 145 |
# 2. 嘗試解析 JSON 輸出
|
| 146 |
result = json.loads(out_str)
|
| 147 |
|
|
|
|
| 182 |
event.reply_token,
|
| 183 |
TextSendMessage(text="代理人回覆格式無法識別,請聯繫管理員。")
|
| 184 |
)
|
| 185 |
+
|
| 186 |
except json.JSONDecodeError:
|
| 187 |
# 4. 處理 Agent 返回了無法解析的純文字 (非 JSON)
|
| 188 |
# 這通常發生在 Agent 決定不使用工具,直接回覆純文字,或者推理過程出錯。
|