Add workflow support and enhance runtime configuration in models and services

- Introduce RuntimeModelResource and RuntimeKnowledgeBase classes to manage workflow resources.
- Update AssistantConfig to include workflow_model_resources and workflow_knowledge_bases for better integration.
- Refactor validation and processing logic in routes and services to accommodate workflow types.
- Implement dynamic variable support for workflow assistants and enhance graph normalization.
- Add ToolExecutor for reusable tool execution across different assistant types.
- Update various services to ensure compatibility with new workflow features and improve error handling.
This commit is contained in:
Xin Wang
2026-07-13 16:13:27 +08:00
parent 6108b00007
commit 32aef14ddb
27 changed files with 2563 additions and 910 deletions

View File

@@ -175,9 +175,9 @@ def prepare_dynamic_config(
trusted_values: dict[str, Any] | None = None,
) -> AssistantConfig:
"""Validate and merge one call's values without mutating stored config."""
if cfg.type != "prompt":
if cfg.type not in {"prompt", "workflow"}:
if client_values:
raise DynamicVariableError("动态变量目前仅支持 prompt 助手")
raise DynamicVariableError("动态变量仅支持 prompt 和 workflow 助手")
return cfg
supplied = _validate_public(client_values)
@@ -214,9 +214,13 @@ def prepare_dynamic_config(
prepared = cfg.model_copy(deep=True)
prepared.dynamic_variables = merged
prepared.conversation_id = conversation_id
# Validate prompt and greeting before media resources are allocated.
# Validate top-level prompt/greeting before media resources are allocated.
# Workflow node templates are rendered lazily as their nodes become active.
store = DynamicVariableStore.from_config(prepared)
store.render(prepared.prompt)
if prepared.type == "prompt":
store.render(prepared.prompt)
elif prepared.type == "workflow":
store.render_data(prepared.graph)
store.render(prepared.greeting)
return prepared