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)