F1: add reusable task backend resources and migrate task tools
This commit is contained in:
+27
-2
@@ -177,6 +177,7 @@ class Assistant(Base):
|
||||
prompt: Mapped[str] = mapped_column(Text, default="") # prompt
|
||||
dynamic_variable_definitions: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
built_in_tools: Mapped[dict] = mapped_column(JSONB, default=dict)
|
||||
task_backend: Mapped[dict | None] = mapped_column(JSONB, nullable=True)
|
||||
analysis_config: Mapped[dict] = mapped_column(JSONB, default=dict)
|
||||
api_url: Mapped[str] = mapped_column(String(512), default="") # dify / fastgpt
|
||||
api_key: Mapped[str] = mapped_column(String(512), default="") # dify / fastgpt(打码/哨兵)
|
||||
@@ -237,6 +238,27 @@ class McpServer(Base):
|
||||
)
|
||||
|
||||
|
||||
class TaskBackendResource(Base):
|
||||
"""Reusable connection and execution policy, separate from ordinary tools."""
|
||||
|
||||
__tablename__ = "task_backend_resources"
|
||||
__table_args__ = (
|
||||
CheckConstraint("type IN ('reasoner', 'opencode')", name="ck_task_backend_type"),
|
||||
)
|
||||
|
||||
id: Mapped[str] = mapped_column(String(40), primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128))
|
||||
type: Mapped[str] = mapped_column(String(16))
|
||||
description: Mapped[str] = mapped_column(String(2048), default="")
|
||||
config: Mapped[dict] = mapped_column(JSONB, default=dict)
|
||||
secrets: Mapped[dict] = mapped_column(JSONB, default=dict)
|
||||
enabled: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
|
||||
)
|
||||
|
||||
|
||||
class Tool(Base):
|
||||
"""Reusable LLM tool definition; supported types are executed at runtime."""
|
||||
|
||||
@@ -248,7 +270,7 @@ class Tool(Base):
|
||||
name="uq_tools_mcp_server_remote_name",
|
||||
),
|
||||
CheckConstraint(
|
||||
"type IN ('http', 'mcp', 'client', 'task')",
|
||||
"type IN ('http', 'mcp', 'client')",
|
||||
name="ck_tools_external_type",
|
||||
),
|
||||
)
|
||||
@@ -655,7 +677,10 @@ class BackgroundTask(Base):
|
||||
id: Mapped[str] = mapped_column(String(40), primary_key=True)
|
||||
assistant_id: Mapped[str] = mapped_column(String(40), index=True)
|
||||
conversation_id: Mapped[str] = mapped_column(String(80), index=True)
|
||||
tool_id: Mapped[str] = mapped_column(String(40))
|
||||
tool_id: Mapped[str] = mapped_column(String(40), default="")
|
||||
backend_id: Mapped[str] = mapped_column(String(40), default="")
|
||||
backend_type: Mapped[str] = mapped_column(String(16), default="opencode")
|
||||
deadline_at: Mapped[str | None] = mapped_column(String(40), nullable=True)
|
||||
instruction: Mapped[str] = mapped_column(Text)
|
||||
origin_key: Mapped[str] = mapped_column(String(256), unique=True)
|
||||
connection: Mapped[dict] = mapped_column(JSONB)
|
||||
|
||||
Reference in New Issue
Block a user