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

@@ -15,6 +15,7 @@ from schemas import (
)
from services.auth import require_admin
from services.knowledge import create_document, delete_storage_object, process_document, search
from services.node_specs import graph_references
import settings
from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
@@ -123,6 +124,14 @@ async def delete_knowledge_base(
)).scalar_one_or_none()
if referenced:
raise HTTPException(409, "知识库正被助手引用,无法删除")
workflows = (
await session.execute(select(Assistant).where(Assistant.type == "workflow"))
).scalars().all()
if any(
kb_id in graph_references(assistant.graph or {})["knowledge_bases"]
for assistant in workflows
):
raise HTTPException(409, "知识库正被 Workflow 节点引用,无法删除")
documents = (await session.execute(
select(KnowledgeDocument).where(KnowledgeDocument.knowledge_base_id == kb_id)
)).scalars().all()