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:
@@ -25,6 +25,8 @@ from .module.event import EventDatabase
|
||||
from .module.user import AuthDatabase
|
||||
from .module.provider import ProviderDatabase
|
||||
from .module.system_node import SystemNodeDatabase
|
||||
from .module.workflow import WorkflowDatabase
|
||||
from .module.chat_history import ChatHistoryDatabase
|
||||
|
||||
|
||||
@ray.remote
|
||||
@@ -51,6 +53,8 @@ class PostgresDatabase:
|
||||
self._individual_database = IndividualDatabase(self.async_session_maker)
|
||||
self._event_database = EventDatabase(self.async_session_maker)
|
||||
self._system_node_database = SystemNodeDatabase(self.async_session_maker)
|
||||
self._workflow_database = WorkflowDatabase(self.async_session_maker)
|
||||
self._chat_history_database = ChatHistoryDatabase(self.async_session_maker)
|
||||
|
||||
self.ready_event = asyncio.Event()
|
||||
|
||||
@@ -254,3 +258,51 @@ class PostgresDatabase:
|
||||
async def delete_event(self, trace_id: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._event_database.delete_event(trace_id)
|
||||
|
||||
# Workflow Database Methods
|
||||
async def create_workflow(
|
||||
self, trace_id: str, user_id: str, title: str, command: str
|
||||
):
|
||||
await self.ready_event.wait()
|
||||
return await self._workflow_database.create_workflow(
|
||||
trace_id, user_id, title, command
|
||||
)
|
||||
|
||||
async def get_workflow(self, trace_id: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._workflow_database.get_workflow(trace_id)
|
||||
|
||||
async def update_workflow_status(self, trace_id: str, status: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._workflow_database.update_workflow_status(trace_id, status)
|
||||
|
||||
async def list_workflows(self, user_id: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._workflow_database.list_workflows(user_id)
|
||||
|
||||
async def upsert_workflow_context(self, trace_id: str, **kwargs):
|
||||
await self.ready_event.wait()
|
||||
return await self._workflow_database.upsert_workflow_context(trace_id, **kwargs)
|
||||
|
||||
async def get_workflow_context(self, trace_id: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._workflow_database.get_workflow_context(trace_id)
|
||||
|
||||
# Chat History Database Methods
|
||||
async def create_chat_session(self, user_id: str, title: str = "新对话"):
|
||||
await self.ready_event.wait()
|
||||
return await self._chat_history_database.create_chat_session(user_id, title)
|
||||
|
||||
async def list_chat_sessions(self, user_id: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._chat_history_database.list_chat_sessions(user_id)
|
||||
|
||||
async def add_chat_message(self, chat_id: str, message: str, message_owner: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._chat_history_database.add_chat_message(
|
||||
chat_id, message, message_owner
|
||||
)
|
||||
|
||||
async def list_chat_messages(self, chat_id: str):
|
||||
await self.ready_event.wait()
|
||||
return await self._chat_history_database.list_chat_messages(chat_id)
|
||||
|
||||
Reference in New Issue
Block a user