Refactor Workflow and Chat Architecture (#68)
* refactor: overhaul workflow and chat architecture - Separate Chat and Workflow API endpoints and database models - Use JSONB to store workflow execution context in Postgres - Convert workflow engine to use pydantic-ai execution graphs inside a Ray task - Update frontend React components to support standalone workflow creation - Remove obsolete and broken workflow runner tests Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com> * refactor: overhaul workflow and chat architecture - Separate Chat and Workflow API endpoints and database models - Use JSONB to store workflow execution context in Postgres - Convert workflow engine to use pydantic-ai execution graphs inside a Ray task - Update frontend React components to support standalone workflow creation - Remove obsolete and broken workflow runner tests Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com> * refactor: overhaul workflow and chat architecture - Separate Chat and Workflow API endpoints and database models - Use JSONB to store workflow execution context in Postgres - Convert workflow engine to use pydantic-ai execution graphs inside a Ray task - Update frontend React components to support standalone workflow creation - Move workflow_engine inside workflow package to keep core root clean - Remove obsolete and broken workflow runner tests Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
This commit is contained in:
@@ -44,10 +44,7 @@ class BaseIndividualModel(BaseDataModel):
|
||||
|
||||
agent_type: Mapped[str] = mapped_column(String(32))
|
||||
|
||||
__mapper_args__ = {
|
||||
"polymorphic_on": "agent_type",
|
||||
"polymorphic_identity": "base"
|
||||
}
|
||||
__mapper_args__ = {"polymorphic_on": "agent_type", "polymorphic_identity": "base"}
|
||||
|
||||
|
||||
# ==========================================
|
||||
@@ -57,8 +54,7 @@ class SpecialistIndividualModel(BaseIndividualModel):
|
||||
__tablename__ = "specialist_individual"
|
||||
|
||||
agent_id: Mapped[str] = mapped_column(
|
||||
ForeignKey("base_individual.agent_id", ondelete="CASCADE"),
|
||||
primary_key=True
|
||||
ForeignKey("base_individual.agent_id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
bound_skill: Mapped[Optional[Dict[str, Any]]] = mapped_column(JSONB)
|
||||
workspace: Mapped[Optional[List[str]]] = mapped_column(JSONB)
|
||||
@@ -70,12 +66,12 @@ class SpecialistIndividualModel(BaseIndividualModel):
|
||||
sub_ordinary_agents: Mapped[List["OrdinaryIndividualModel"]] = relationship(
|
||||
back_populates="manager",
|
||||
cascade="all, delete-orphan",
|
||||
foreign_keys="[OrdinaryIndividualModel.manager_id]"
|
||||
foreign_keys="[OrdinaryIndividualModel.manager_id]",
|
||||
)
|
||||
sub_special_agents: Mapped[List["SpecialIndividualModel"]] = relationship(
|
||||
back_populates="manager",
|
||||
cascade="all, delete-orphan",
|
||||
foreign_keys="[SpecialIndividualModel.manager_id]"
|
||||
foreign_keys="[SpecialIndividualModel.manager_id]",
|
||||
)
|
||||
|
||||
__mapper_args__ = {
|
||||
@@ -90,8 +86,7 @@ class OrdinaryIndividualModel(BaseIndividualModel):
|
||||
__tablename__ = "ordinary_individual"
|
||||
|
||||
agent_id: Mapped[str] = mapped_column(
|
||||
ForeignKey("base_individual.agent_id", ondelete="CASCADE"),
|
||||
primary_key=True
|
||||
ForeignKey("base_individual.agent_id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
finetuned_from: Mapped[Optional[str]] = mapped_column(String(100))
|
||||
tools: Mapped[Optional[List[str]]] = mapped_column(
|
||||
@@ -106,7 +101,7 @@ class OrdinaryIndividualModel(BaseIndividualModel):
|
||||
# 逻辑关联:指向上级专家
|
||||
manager: Mapped[Optional["SpecialistIndividualModel"]] = relationship(
|
||||
back_populates="sub_ordinary_agents",
|
||||
foreign_keys=[manager_id] # 显式指定使用 manager_id 解析关系
|
||||
foreign_keys=[manager_id], # 显式指定使用 manager_id 解析关系
|
||||
)
|
||||
|
||||
__mapper_args__ = {
|
||||
@@ -121,12 +116,10 @@ class SpecialIndividualModel(BaseIndividualModel):
|
||||
__tablename__ = "special_individual"
|
||||
|
||||
agent_id: Mapped[str] = mapped_column(
|
||||
ForeignKey("base_individual.agent_id", ondelete="CASCADE"),
|
||||
primary_key=True
|
||||
ForeignKey("base_individual.agent_id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
modality_type: Mapped[ModalityType] = mapped_column(
|
||||
default=ModalityType.MULTIMODAL,
|
||||
server_default=text("'multimodal'")
|
||||
default=ModalityType.MULTIMODAL, server_default=text("'multimodal'")
|
||||
)
|
||||
multimodal_config: Mapped[Optional[Dict[str, Any]]] = mapped_column(JSONB)
|
||||
|
||||
@@ -137,10 +130,9 @@ class SpecialIndividualModel(BaseIndividualModel):
|
||||
|
||||
# 【修复2】:修正 back_populates 指向正确的变量名
|
||||
manager: Mapped[Optional["SpecialistIndividualModel"]] = relationship(
|
||||
back_populates="sub_special_agents",
|
||||
foreign_keys=[manager_id]
|
||||
back_populates="sub_special_agents", foreign_keys=[manager_id]
|
||||
)
|
||||
|
||||
__mapper_args__ = {
|
||||
"polymorphic_identity": "special",
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user