From 7f331690a014728f8264fb948e7c4eae73c49ca1 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sat, 10 May 2025 21:52:31 +0800 Subject: [PATCH] =?UTF-8?q?update:=E5=A2=9E=E5=8A=A0=E8=AF=AF=E7=94=A8func?= =?UTF-8?q?tion=5Fcall=E7=9A=84=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../llm/homeassistant/homeassistant.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/main/xiaozhi-server/core/providers/llm/homeassistant/homeassistant.py b/main/xiaozhi-server/core/providers/llm/homeassistant/homeassistant.py index 44ef0ed0..6e53695f 100644 --- a/main/xiaozhi-server/core/providers/llm/homeassistant/homeassistant.py +++ b/main/xiaozhi-server/core/providers/llm/homeassistant/homeassistant.py @@ -31,12 +31,12 @@ class LLMProvider(LLMProviderBase): payload = { "text": input_text, "agent_id": self.agent_id, - "conversation_id": session_id # 使用 session_id 作为 conversation_id + "conversation_id": session_id, # 使用 session_id 作为 conversation_id } # 设置请求头 headers = { "Authorization": f"Bearer {self.api_key}", - "Content-Type": "application/json" + "Content-Type": "application/json", } # 发起 POST 请求 @@ -47,7 +47,12 @@ class LLMProvider(LLMProviderBase): # 解析返回数据 data = response.json() - speech = data.get("response", {}).get("speech", {}).get("plain", {}).get("speech", "") + speech = ( + data.get("response", {}) + .get("speech", {}) + .get("plain", {}) + .get("speech", "") + ) # 返回生成的内容 if speech: @@ -58,4 +63,10 @@ class LLMProvider(LLMProviderBase): except RequestException as e: logger.bind(tag=TAG).error(f"HTTP 请求错误: {e}") except Exception as e: - logger.bind(tag=TAG).error(f"生成响应时出错: {e}") \ No newline at end of file + logger.bind(tag=TAG).error(f"生成响应时出错: {e}") + + def response_with_functions(self, session_id, dialogue, functions=None): + logger.bind(tag=TAG).info( + f"homeassistant不支持(function call),建议使用意图识别使用:nointent" + ) + return self.response(session_id, dialogue)