mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-28 10:03:54 +08:00
update:iot设备多指令适配
This commit is contained in:
@@ -61,6 +61,16 @@ class FunctionHandler:
|
||||
return self.function_registry.get_function(name)
|
||||
|
||||
def handle_llm_function_call(self, conn, function_call_data):
|
||||
# 多函数调用处理
|
||||
if "function_calls" in function_call_data:
|
||||
responses = []
|
||||
for call in function_call_data["function_calls"]:
|
||||
func = self.get_function(call["name"])
|
||||
if func:
|
||||
# 执行函数并收集响应
|
||||
response = func(conn, **call.get("arguments", {}))
|
||||
responses.append(response)
|
||||
return self._combine_responses(responses) # 合并响应
|
||||
try:
|
||||
function_name = function_call_data["name"]
|
||||
funcItem = self.get_function(function_name)
|
||||
|
||||
@@ -82,7 +82,11 @@ def create_iot_function(device_name, method_name, method_info):
|
||||
response = response.replace("{value}", str(param_value))
|
||||
break
|
||||
|
||||
return ActionResponse(Action.RESPONSE, result, response)
|
||||
return ActionResponse(
|
||||
Action.REQLLM,
|
||||
result=f"{device_name}操作执行成功,请继续处理剩余指令",
|
||||
response=response_success # 保留成功提示
|
||||
)
|
||||
except Exception as e:
|
||||
conn.logger.bind(tag=TAG).error(
|
||||
f"执行{device_name}的{method_name}操作失败: {e}"
|
||||
|
||||
Reference in New Issue
Block a user