mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
update: Add logging for Dify LLM request and response details
This commit is contained in:
parent
5afb59cb7a
commit
c2a607ff27
1 changed files with 9 additions and 1 deletions
|
|
@ -101,8 +101,14 @@ class DifyLLM(LLM):
|
||||||
try:
|
try:
|
||||||
# 取最后一条用户消息
|
# 取最后一条用户消息
|
||||||
last_msg = next(m for m in reversed(dialogue) if m["role"] == "user")
|
last_msg = next(m for m in reversed(dialogue) if m["role"] == "user")
|
||||||
|
#
|
||||||
|
logger.info(f"Base URL: {self.base_url}")
|
||||||
|
logger.info(f"API Key: {self.api_key}")
|
||||||
|
logger.info(f"Session ID: {session_id}")
|
||||||
|
logger.info(f"Last Message: {last_msg}")
|
||||||
|
|
||||||
# 发起流式请求
|
# 发起流式请求
|
||||||
|
response_content = []
|
||||||
with requests.post(
|
with requests.post(
|
||||||
f"{self.base_url}/chat-messages",
|
f"{self.base_url}/chat-messages",
|
||||||
headers={"Authorization": f"Bearer {self.api_key}"},
|
headers={"Authorization": f"Bearer {self.api_key}"},
|
||||||
|
|
@ -119,6 +125,8 @@ class DifyLLM(LLM):
|
||||||
event = json.loads(line[6:])
|
event = json.loads(line[6:])
|
||||||
if event.get('answer'):
|
if event.get('answer'):
|
||||||
yield event['answer']
|
yield event['answer']
|
||||||
|
response_content.append(event['answer'])
|
||||||
|
logger.info(f"Response Content: {response_content}")
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
yield "【服务响应异常】"
|
yield "【服务响应异常】"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue