mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 12:53:55 +08:00
Merge branch 'py_test_typing' into feature/python-typing
This commit is contained in:
@@ -5,11 +5,14 @@ if TYPE_CHECKING:
|
||||
from ..base import IntentProviderBase
|
||||
from plugins_func.functions.play_music import initialize_music_handler
|
||||
from config.logger import setup_logging
|
||||
from core.utils.util import get_system_error_response
|
||||
import re
|
||||
import json
|
||||
import hashlib
|
||||
import time
|
||||
|
||||
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
@@ -118,12 +121,16 @@ class IntentProvider(IntentProviderBase):
|
||||
return prompt
|
||||
|
||||
def replyResult(self, text: str, original_text: str):
|
||||
llm_result = self.llm.response_no_stream(
|
||||
system_prompt=text,
|
||||
user_prompt="请根据以上内容,像人类一样说话的口吻回复用户,要求简洁,请直接返回结果。用户现在说:"
|
||||
+ original_text,
|
||||
)
|
||||
return llm_result
|
||||
try:
|
||||
llm_result = self.llm.response_no_stream(
|
||||
system_prompt=text,
|
||||
user_prompt="请根据以上内容,像人类一样说话的口吻回复用户,要求简洁,请直接返回结果。用户现在说:"
|
||||
+ original_text,
|
||||
)
|
||||
return llm_result
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error in generating reply result: {e}")
|
||||
return get_system_error_response(self.config)
|
||||
|
||||
async def detect_intent(
|
||||
self, conn: "ConnectionHandler", dialogue_history: List[Dict], text: str
|
||||
@@ -199,9 +206,13 @@ class IntentProvider(IntentProviderBase):
|
||||
llm_start_time = time.time()
|
||||
logger.bind(tag=TAG).debug(f"开始LLM意图识别调用, 模型: {model_info}")
|
||||
|
||||
intent = self.llm.response_no_stream(
|
||||
system_prompt=prompt_music, user_prompt=user_prompt
|
||||
)
|
||||
try:
|
||||
intent = self.llm.response_no_stream(
|
||||
system_prompt=prompt_music, user_prompt=user_prompt
|
||||
)
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error in intent detection LLM call: {e}")
|
||||
return '{"function_call": {"name": "continue_chat"}}'
|
||||
|
||||
# 记录LLM调用完成时间
|
||||
llm_time = time.time() - llm_start_time
|
||||
|
||||
Reference in New Issue
Block a user