update:优化工具目录结构

This commit is contained in:
hrz
2025-06-26 09:28:29 +08:00
parent 2348d9ceb3
commit 9412a26bfc
23 changed files with 14 additions and 12 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ from core.utils.util import (
filter_sensitive_info,
)
from typing import Dict, Any
from core.tools.base import ToolAction
from core.providers.tools.base import ToolAction
from core.utils.modules_initialize import (
initialize_modules,
initialize_tts,
@@ -29,7 +29,7 @@ from concurrent.futures import ThreadPoolExecutor
from core.utils.dialogue import Message, Dialogue
from core.providers.asr.dto.dto import InterfaceType
from core.handle.textHandle import handleTextMessage
from core.tools.unified_tool_handler import UnifiedToolHandler
from core.providers.tools.unified_tool_handler import UnifiedToolHandler
from plugins_func.loadplugins import auto_import_modules
from plugins_func.register import Action, ActionResponse
from core.auth import AuthMiddleware, AuthenticationError
@@ -7,7 +7,7 @@ from core.utils.util import audio_to_data
from core.handle.sendAudioHandle import sendAudioMessage, send_stt_message
from core.utils.util import remove_punctuation_and_length, opus_datas_to_wav_bytes
from core.providers.tts.dto.dto import ContentType, SentenceType
from core.tools.device_mcp import (
from core.providers.tools.device_mcp import (
MCPClient,
send_mcp_initialize_message,
send_mcp_tools_list_request,
@@ -6,7 +6,7 @@ from core.handle.helloHandle import checkWakeupWords
from core.utils.util import remove_punctuation_and_length
from core.providers.tts.dto.dto import ContentType
from core.utils.dialogue import Message
from core.tools.device_mcp import call_mcp_tool
from core.providers.tools.device_mcp import call_mcp_tool
from plugins_func.register import Action, ActionResponse
from loguru import logger
@@ -109,10 +109,12 @@ async def process_intent_result(conn, intent_result, original_text):
# 使用统一工具处理器处理所有工具调用
try:
tool_result = asyncio.run_coroutine_threadsafe(
conn.func_handler.handle_llm_function_call(conn, function_call_data),
conn.func_handler.handle_llm_function_call(
conn, function_call_data
),
conn.loop,
).result()
# 转换ToolResult为ActionResponse
result = conn._convert_tool_result_to_action_response(tool_result)
except Exception as e:
@@ -1,11 +1,11 @@
import json
from core.handle.abortHandle import handleAbortMessage
from core.handle.helloHandle import handleHelloMessage
from core.tools.device_mcp import handle_mcp_message
from core.providers.tools.device_mcp import handle_mcp_message
from core.utils.util import remove_punctuation_and_length, filter_sensitive_info
from core.handle.receiveAudioHandle import startToChat, handleAudioMessage
from core.handle.sendAudioHandle import send_stt_message, send_tts_message
from core.tools.device_iot import handleIotDescriptors, handleIotStatus
from core.providers.tools.device_iot import handleIotDescriptors, handleIotStatus
from core.handle.reportHandle import enqueue_asr_report
import asyncio
@@ -118,12 +118,12 @@ class DeviceIoTExecutor(ToolExecutor):
):
"""发送IoT控制命令"""
for key, value in self.conn.iot_descriptors.items():
if key == device_name:
if key.lower() == device_name.lower():
for method in value.methods:
if method["name"] == method_name:
if method["name"].lower() == method_name.lower():
command = {
"name": device_name,
"method": method_name,
"name": key,
"method": method["name"],
}
if parameters: