mirror of https://github.com/Mai-with-u/MaiBot.git
feat: add dedicated tts_instruct task for auto-instruct
parent
24e434eb3a
commit
c354be1f49
|
|
@ -25,7 +25,7 @@ dependencies = [
|
|||
"pypinyin>=0.54.0",
|
||||
"python-dotenv>=1.1.1",
|
||||
"python-multipart>=0.0.20",
|
||||
"quick-algo>=0.1.3",
|
||||
"quick-algo @ file:///Users/xenon/MaiM-with-u/MaiMBot-LPMM/lib/quick_algo",
|
||||
"rich>=14.0.0",
|
||||
"ruff>=0.12.2",
|
||||
"setuptools>=80.9.0",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pydantic>=2.11.7
|
|||
pypinyin>=0.54.0
|
||||
python-dotenv>=1.1.1
|
||||
python-multipart>=0.0.20
|
||||
quick-algo>=0.1.3
|
||||
quick-algo @ file:///Users/xenon/MaiM-with-u/MaiMBot-LPMM/lib/quick_algo
|
||||
rich>=14.0.0
|
||||
ruff>=0.12.2
|
||||
setuptools>=80.9.0
|
||||
|
|
@ -28,4 +28,4 @@ tomlkit>=0.13.3
|
|||
urllib3>=2.5.0
|
||||
uvicorn>=0.35.0
|
||||
msgpack
|
||||
zstandard
|
||||
zstandard
|
||||
|
|
|
|||
|
|
@ -132,6 +132,9 @@ class ModelTaskConfig(ConfigBase):
|
|||
lpmm_rdf_build: TaskConfig
|
||||
"""LPMM RDF构建模型配置"""
|
||||
|
||||
tts_instruct: TaskConfig = field(default_factory=TaskConfig)
|
||||
"""TTS instruct 生成模型配置(用于生成情绪/语速/停顿指令)"""
|
||||
|
||||
def get_task(self, task_name: str) -> TaskConfig:
|
||||
"""获取指定任务的配置"""
|
||||
if hasattr(self, task_name):
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ from src.chat.utils.utils import process_llm_response
|
|||
from src.chat.replyer.replyer_manager import replyer_manager
|
||||
from src.plugin_system.base.component_types import ActionInfo
|
||||
from src.chat.logger.plan_reply_logger import PlanReplyLogger
|
||||
from src.config.config import model_config
|
||||
from src.llm_models.utils_model import LLMRequest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.common.data_models.info_data_model import ActionPlannerInfo
|
||||
|
|
@ -324,3 +326,34 @@ async def generate_response_custom(
|
|||
except Exception as e:
|
||||
logger.error(f"[GeneratorAPI] 生成自定义回复时出错: {e}")
|
||||
return None
|
||||
|
||||
|
||||
async def generate_tts_instruct(
|
||||
prompt: str,
|
||||
request_type: str = "tts_instruct",
|
||||
temperature: Optional[float] = None,
|
||||
max_tokens: Optional[int] = None,
|
||||
) -> Optional[str]:
|
||||
"""
|
||||
生成 TTS 表演指令(instruct),使用独立的 model_task_config.tts_instruct 模型组。
|
||||
|
||||
设计目标:
|
||||
- 不走 replyer(避免上下文/人设污染)
|
||||
- 仅基于 prompt 生成短文本,便于在 WebUI 的 model_config.toml 单独配置模型
|
||||
"""
|
||||
try:
|
||||
task_cfg = model_config.model_task_config.get_task("tts_instruct")
|
||||
if not task_cfg.model_list:
|
||||
logger.error("[GeneratorAPI] tts_instruct 的 model_list 为空,请在 model_config.toml 配置 [model_task_config.tts_instruct]")
|
||||
return None
|
||||
|
||||
llm = LLMRequest(model_set=task_cfg, request_type=request_type)
|
||||
content, _meta = await llm.generate_response_async(
|
||||
prompt=prompt,
|
||||
temperature=temperature if temperature is not None else task_cfg.temperature,
|
||||
max_tokens=max_tokens if max_tokens is not None else task_cfg.max_tokens,
|
||||
)
|
||||
return content.strip() if content else None
|
||||
except Exception as e:
|
||||
logger.error(f"[GeneratorAPI] 生成 tts_instruct 失败: {e}", exc_info=True)
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -156,6 +156,13 @@ max_tokens = 2048
|
|||
slow_threshold = 25.0
|
||||
selection_strategy = "random" # 模型选择策略:balance(负载均衡)或 random(随机选择)
|
||||
|
||||
[model_task_config.tts_instruct] # 生成 TTS 表演指令(情绪/语速/停顿)用的模型(独立于 replyer)
|
||||
model_list = ["qwen3-30b","qwen3-next-80b"]
|
||||
temperature = 0.2
|
||||
max_tokens = 128
|
||||
slow_threshold = 10.0
|
||||
selection_strategy = "random"
|
||||
|
||||
[model_task_config.planner] #决策:负责决定麦麦该什么时候回复的模型
|
||||
model_list = ["siliconflow-deepseek-v3.2"]
|
||||
temperature = 0.3
|
||||
|
|
@ -194,4 +201,4 @@ model_list = ["siliconflow-deepseek-v3.2"]
|
|||
temperature = 0.2
|
||||
max_tokens = 800
|
||||
slow_threshold = 20.0
|
||||
selection_strategy = "random" # 模型选择策略:balance(负载均衡)或 random(随机选择)
|
||||
selection_strategy = "random" # 模型选择策略:balance(负载均衡)或 random(随机选择)
|
||||
|
|
|
|||
Loading…
Reference in New Issue