update:增加误用function_call的提示

This commit is contained in:
hrz
2025-05-10 21:52:31 +08:00
parent 474eeb9e68
commit 7f331690a0
@@ -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}")
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)