本地模型不重复创建,共用一个

This commit is contained in:
玄凤科技 2025-02-18 09:19:31 +08:00
parent 511c26d8a4
commit 874340f396
2 changed files with 3 additions and 14 deletions

View file

@ -172,21 +172,12 @@ class PrivateConfig:
# 判断存在私有配置,并且self.device_id在私有配置中 # 判断存在私有配置,并且self.device_id在私有配置中
if not self.private_config: if not self.private_config:
self.logger.bind(tag=TAG).error("Private config not found for device_id: {}", self.device_id) self.logger.bind(tag=TAG).error("Private config not found for device_id: {}", self.device_id)
return None, None, None, None return None, None
"""创建私有处理模块实例""" """创建私有处理模块实例"""
config = self.private_config config = self.private_config
selected_modules = config['selected_module'] selected_modules = config['selected_module']
return ( return (
vad.create_instance(
selected_modules["VAD"],
config["VAD"][selected_modules["VAD"]]
),
asr.create_instance(
selected_modules["ASR"],
config["ASR"][selected_modules["ASR"]],
self.default_config.get("delete_audio", True) # Using default_config for global settings
),
llm.create_instance( llm.create_instance(
selected_modules["LLM"] selected_modules["LLM"]
if not 'type' in config["LLM"][selected_modules["LLM"]] if not 'type' in config["LLM"][selected_modules["LLM"]]

View file

@ -108,10 +108,8 @@ class ConnectionHandler:
if self.is_device_verified: if self.is_device_verified:
await self.private_config.update_last_chat_time() await self.private_config.update_last_chat_time()
vad, asr, llm, tts = self.private_config.create_private_instances() llm, tts = self.private_config.create_private_instances()
if all([vad, asr, llm, tts]): if all([llm, tts]):
self.vad = vad
self.asr = asr
self.llm = llm self.llm = llm
self.tts = tts self.tts = tts
self.logger.bind(tag=TAG).info(f"Loaded private config and instances for device {device_id}") self.logger.bind(tag=TAG).info(f"Loaded private config and instances for device {device_id}")