Workflow Copilot: backend side of the first version (#4401)

This commit is contained in:
Stanislav Novosad
2026-01-06 14:58:44 -07:00
committed by GitHub
parent 1e314ce149
commit e3dd75d7c1
10 changed files with 1440 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
from datetime import datetime
from enum import StrEnum
from pydantic import BaseModel, ConfigDict, Field
class WorkflowCopilotChat(BaseModel):
model_config = ConfigDict(from_attributes=True)
workflow_copilot_chat_id: str = Field(..., description="ID for the workflow copilot chat")
organization_id: str = Field(..., description="Organization ID for the chat")
workflow_permanent_id: str = Field(..., description="Workflow permanent ID for the chat")
created_at: datetime = Field(..., description="When the chat was created")
modified_at: datetime = Field(..., description="When the chat was last modified")
class WorkflowCopilotChatSender(StrEnum):
USER = "user"
AI = "ai"
class WorkflowCopilotChatMessage(BaseModel):
model_config = ConfigDict(from_attributes=True)
workflow_copilot_chat_message_id: str = Field(..., description="ID for the workflow copilot chat message")
workflow_copilot_chat_id: str = Field(..., description="ID of the parent workflow copilot chat")
sender: WorkflowCopilotChatSender = Field(..., description="Message sender")
content: str = Field(..., description="Message content")
global_llm_context: str | None = Field(None, description="Optional global LLM context for the message")
created_at: datetime = Field(..., description="When the message was created")
modified_at: datetime = Field(..., description="When the message was last modified")
class WorkflowCopilotChatRequest(BaseModel):
workflow_permanent_id: str = Field(..., description="Workflow permanent ID for the chat")
workflow_copilot_chat_id: str | None = Field(None, description="The chat ID to send the message to")
workflow_run_id: str | None = Field(None, description="The workflow run ID to use for the context")
message: str = Field(..., description="The message that user sends")
workflow_yaml: str = Field(..., description="Current workflow YAML including unsaved changes")
class WorkflowCopilotChatResponse(BaseModel):
workflow_copilot_chat_id: str = Field(..., description="The chat ID")
message: str = Field(..., description="The message sent to the user")
updated_workflow_yaml: str | None = Field(None, description="The updated workflow yaml")
request_time: datetime = Field(..., description="When the request was received")
response_time: datetime = Field(..., description="When the assistant message was created")
class WorkflowCopilotChatHistoryMessage(BaseModel):
sender: WorkflowCopilotChatSender = Field(..., description="Message sender")
content: str = Field(..., description="Message content")
created_at: datetime = Field(..., description="When the message was created")
class WorkflowCopilotChatHistoryResponse(BaseModel):
workflow_copilot_chat_id: str | None = Field(None, description="Latest chat ID for the workflow")
chat_history: list[WorkflowCopilotChatHistoryMessage] = Field(default_factory=list, description="Chat messages")