Enhance workflow routing and agent configuration management
- Introduce WorkflowLLMRouter for pre-response LLM routing, allowing agents to determine the appropriate function to call based on user input. - Implement UserTurnRoutingProcessor to manage user turns before reaching the LLM, ensuring proper routing and handling of user messages. - Refactor WorkflowBrain to integrate new routing logic and enhance agent stage configuration, including entry modes and resource management. - Update service factory to support dynamic LLM resource configuration based on workflow settings. - Add tests for new routing functionality and ensure proper handling of user messages in various scenarios.
This commit is contained in:
@@ -29,11 +29,18 @@ TTS_STOP_FRAME_TIMEOUT_S = 1.0
|
||||
def config_with_resource(
|
||||
cfg: AssistantConfig, resource: RuntimeModelResource
|
||||
) -> AssistantConfig:
|
||||
"""Return a call-local config view for one workflow ASR/TTS resource."""
|
||||
"""Return a call-local config view for one workflow model resource."""
|
||||
result = cfg.model_copy(deep=True)
|
||||
values = resource.values or {}
|
||||
secrets = resource.secrets or {}
|
||||
if resource.capability == "ASR":
|
||||
if resource.capability == "LLM":
|
||||
result.model = str(values.get("modelId") or "")
|
||||
result.llm_interface_type = resource.interface_type
|
||||
result.llm_values = values
|
||||
result.llm_secrets = secrets
|
||||
result.llm_api_key = str(secrets.get("apiKey") or "")
|
||||
result.llm_base_url = str(values.get("apiUrl") or "")
|
||||
elif resource.capability == "ASR":
|
||||
result.asr = str(values.get("modelId") or "")
|
||||
result.stt_language = str(values.get("language") or "")
|
||||
result.stt_interface_type = resource.interface_type
|
||||
@@ -51,7 +58,7 @@ def config_with_resource(
|
||||
result.tts_api_key = str(secrets.get("apiKey") or "")
|
||||
result.tts_base_url = str(values.get("apiUrl") or "")
|
||||
else:
|
||||
raise ValueError(f"工作流语音资源能力无效:{resource.capability}")
|
||||
raise ValueError(f"工作流模型资源能力无效:{resource.capability}")
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user