feat: workflow和chat分离
1,增加了创建workflow的页面 2.删除了event
This commit is contained in:
@@ -12,9 +12,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from kilostar.core.postgres_database.model.user import User
|
||||
from kilostar.core.postgres_database.model.provider import Provider
|
||||
from kilostar.core.postgres_database.model.individual import WorkerIndividual
|
||||
from kilostar.core.postgres_database.model.user import User, UserAuthority
|
||||
from kilostar.core.postgres_database.model.provider import ProviderModel
|
||||
from kilostar.core.postgres_database.model.individual import (
|
||||
BaseIndividualModel,
|
||||
SpecialistIndividualModel,
|
||||
OrdinaryIndividualModel,
|
||||
SpecialIndividualModel,
|
||||
)
|
||||
from kilostar.core.postgres_database.model.workflow import (
|
||||
Workflow,
|
||||
WorkflowContextModel,
|
||||
@@ -23,13 +28,30 @@ from kilostar.core.postgres_database.model.chat_history import (
|
||||
ChatHistoryRegister,
|
||||
ChatHistoryMessage,
|
||||
)
|
||||
from kilostar.core.postgres_database.model.system_node import SystemNodeConfigModel
|
||||
|
||||
# 兼容旧代码的别名
|
||||
Provider = ProviderModel
|
||||
SystemNodeConfig = SystemNodeConfigModel
|
||||
|
||||
# AgentType: 与 BaseIndividualModel 的 polymorphic_on 保持一致
|
||||
from typing import Literal
|
||||
AgentType = Literal["base", "specialist", "ordinary", "special"]
|
||||
|
||||
__all__ = [
|
||||
"User",
|
||||
"UserAuthority",
|
||||
"ProviderModel",
|
||||
"Provider",
|
||||
"WorkerIndividual",
|
||||
"BaseIndividualModel",
|
||||
"SpecialistIndividualModel",
|
||||
"OrdinaryIndividualModel",
|
||||
"SpecialIndividualModel",
|
||||
"Workflow",
|
||||
"WorkflowContextModel",
|
||||
"ChatHistoryRegister",
|
||||
"ChatHistoryMessage",
|
||||
"SystemNodeConfigModel",
|
||||
"SystemNodeConfig",
|
||||
"AgentType",
|
||||
]
|
||||
|
||||
@@ -26,13 +26,13 @@ class ChatHistoryRegister(BaseDataModel):
|
||||
__tablename__ = "chat_history_register"
|
||||
|
||||
chat_id: Mapped[str] = mapped_column(
|
||||
String(64), primary_key=True, description="聊天会话ID"
|
||||
String(64), primary_key=True, comment="聊天会话ID"
|
||||
)
|
||||
user_id: Mapped[str] = mapped_column(
|
||||
String(64), index=True, description="归属的用户ID"
|
||||
String(64), index=True, comment="归属的用户ID"
|
||||
)
|
||||
title: Mapped[str] = mapped_column(
|
||||
String(255), default="新对话", description="对话标题"
|
||||
String(255), default="新对话", comment="对话标题"
|
||||
)
|
||||
created_at: Mapped[str] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now()
|
||||
@@ -50,15 +50,15 @@ class ChatHistoryMessage(BaseDataModel):
|
||||
__tablename__ = "chat_history_message"
|
||||
|
||||
message_id: Mapped[str] = mapped_column(
|
||||
String(64), primary_key=True, description="消息ID"
|
||||
String(64), primary_key=True, comment="消息ID"
|
||||
)
|
||||
chat_id: Mapped[str] = mapped_column(
|
||||
String(64), index=True, description="所属会话ID"
|
||||
String(64), index=True, comment="所属会话ID"
|
||||
)
|
||||
message: Mapped[str] = mapped_column(String, description="消息体内容")
|
||||
message: Mapped[str] = mapped_column(String, comment="消息体内容")
|
||||
message_owner: Mapped[str] = mapped_column(
|
||||
String(50),
|
||||
description="消息发送方,例如 'user', 'regulatory_node', 'consciousness_node' 等",
|
||||
comment="消息发送方,例如 'user', 'regulatory_node', 'consciousness_node' 等",
|
||||
)
|
||||
created_at: Mapped[str] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
from enum import Enum
|
||||
from typing import List, Optional, Dict, Any
|
||||
from sqlalchemy import String, Text, text, ForeignKey
|
||||
from sqlalchemy import String, Text, text, ForeignKey, Enum as SAEnum
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
@@ -119,7 +119,8 @@ class SpecialIndividualModel(BaseIndividualModel):
|
||||
ForeignKey("base_individual.agent_id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
modality_type: Mapped[ModalityType] = mapped_column(
|
||||
default=ModalityType.MULTIMODAL, server_default=text("'multimodal'")
|
||||
SAEnum(ModalityType),
|
||||
default=ModalityType.MULTIMODAL,
|
||||
)
|
||||
multimodal_config: Mapped[Optional[Dict[str, Any]]] = mapped_column(JSONB)
|
||||
|
||||
|
||||
@@ -22,22 +22,22 @@ class Workflow(BaseDataModel):
|
||||
__tablename__ = "workflow"
|
||||
|
||||
trace_id: Mapped[str] = mapped_column(
|
||||
String(64), primary_key=True, description="工作流唯一ID (Trace ID)"
|
||||
String(64), primary_key=True, comment="工作流唯一ID (Trace ID)"
|
||||
)
|
||||
user_id: Mapped[str] = mapped_column(
|
||||
String(64), index=True, description="创建该工作流的用户ID"
|
||||
String(64), index=True, comment="创建该工作流的用户ID"
|
||||
)
|
||||
title: Mapped[str] = mapped_column(String(255), description="工作流标题/简短描述")
|
||||
title: Mapped[str] = mapped_column(String(255), comment="工作流标题/简短描述")
|
||||
command: Mapped[str] = mapped_column(
|
||||
String, description="创建工作流的原始用户命令文本"
|
||||
String, comment="创建工作流的原始用户命令文本"
|
||||
)
|
||||
status: Mapped[str] = mapped_column(
|
||||
String(50),
|
||||
default="creating",
|
||||
description="工作流的总体状态 (例如: creating, running, pending, completed, failed等)",
|
||||
comment="工作流的总体状态 (例如: creating, running, pending, completed, failed等)",
|
||||
)
|
||||
version: Mapped[str] = mapped_column(
|
||||
String(50), default="v1.0", description="系统协议版本号"
|
||||
String(50), default="v1.0", comment="系统协议版本号"
|
||||
)
|
||||
created_at: Mapped[str] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now()
|
||||
@@ -51,27 +51,27 @@ class WorkflowContextModel(BaseDataModel):
|
||||
__tablename__ = "workflow_context"
|
||||
|
||||
trace_id: Mapped[str] = mapped_column(
|
||||
String(64), primary_key=True, description="对应的工作流 Trace ID"
|
||||
String(64), primary_key=True, comment="对应的工作流 Trace ID"
|
||||
)
|
||||
workflow_status: Mapped[dict] = mapped_column(
|
||||
JSONB, default=dict, description="工作流状态变更历史"
|
||||
JSONB, default=dict, comment="工作流状态变更历史"
|
||||
)
|
||||
blackboard: Mapped[dict] = mapped_column(
|
||||
JSONB, default=dict, description="大模型输出的存储区 (共享黑板)"
|
||||
JSONB, default=dict, comment="大模型输出的存储区 (共享黑板)"
|
||||
)
|
||||
work_step_status: Mapped[dict] = mapped_column(
|
||||
JSONB, nullable=True, description="工作流运行步骤状态"
|
||||
JSONB, nullable=True, comment="工作流运行步骤状态"
|
||||
)
|
||||
workflow_pointer: Mapped[int] = mapped_column(
|
||||
nullable=True, description="工作流指针,指向具体运行步骤位置"
|
||||
nullable=True, comment="工作流指针,指向具体运行步骤位置"
|
||||
)
|
||||
workflow_log: Mapped[list] = mapped_column(
|
||||
JSONB, default=list, description="工作流运行日志"
|
||||
JSONB, default=list, comment="工作流运行日志"
|
||||
)
|
||||
work_link: Mapped[list] = mapped_column(
|
||||
JSONB,
|
||||
default=list,
|
||||
description="工作链(即 WorkflowStep 的定义列表,包含图结构和原子动作)",
|
||||
comment="工作链(即 WorkflowStep 的定义列表,包含图结构和原子动作)",
|
||||
)
|
||||
created_at: Mapped[str] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now()
|
||||
|
||||
Reference in New Issue
Block a user