update structure of flow
This commit is contained in:
parent
d0492a500e
commit
82e3140357
@ -1,5 +1,4 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from enum import Enum
|
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@ -7,10 +6,6 @@ from pydantic import BaseModel
|
|||||||
from app.agent.base import BaseAgent
|
from app.agent.base import BaseAgent
|
||||||
|
|
||||||
|
|
||||||
class FlowType(str, Enum):
|
|
||||||
PLANNING = "planning"
|
|
||||||
|
|
||||||
|
|
||||||
class BaseFlow(BaseModel, ABC):
|
class BaseFlow(BaseModel, ABC):
|
||||||
"""Base class for execution flows supporting multiple agents"""
|
"""Base class for execution flows supporting multiple agents"""
|
||||||
|
|
||||||
@ -60,32 +55,3 @@ class BaseFlow(BaseModel, ABC):
|
|||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def execute(self, input_text: str) -> str:
|
async def execute(self, input_text: str) -> str:
|
||||||
"""Execute the flow with given input"""
|
"""Execute the flow with given input"""
|
||||||
|
|
||||||
|
|
||||||
class PlanStepStatus(str, Enum):
|
|
||||||
"""Enum class defining possible statuses of a plan step"""
|
|
||||||
|
|
||||||
NOT_STARTED = "not_started"
|
|
||||||
IN_PROGRESS = "in_progress"
|
|
||||||
COMPLETED = "completed"
|
|
||||||
BLOCKED = "blocked"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_all_statuses(cls) -> list[str]:
|
|
||||||
"""Return a list of all possible step status values"""
|
|
||||||
return [status.value for status in cls]
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_active_statuses(cls) -> list[str]:
|
|
||||||
"""Return a list of values representing active statuses (not started or in progress)"""
|
|
||||||
return [cls.NOT_STARTED.value, cls.IN_PROGRESS.value]
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_status_marks(cls) -> Dict[str, str]:
|
|
||||||
"""Return a mapping of statuses to their marker symbols"""
|
|
||||||
return {
|
|
||||||
cls.COMPLETED.value: "[✓]",
|
|
||||||
cls.IN_PROGRESS.value: "[→]",
|
|
||||||
cls.BLOCKED.value: "[!]",
|
|
||||||
cls.NOT_STARTED.value: "[ ]",
|
|
||||||
}
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
|
from enum import Enum
|
||||||
from typing import Dict, List, Union
|
from typing import Dict, List, Union
|
||||||
|
|
||||||
from app.agent.base import BaseAgent
|
from app.agent.base import BaseAgent
|
||||||
from app.flow.base import BaseFlow, FlowType
|
from app.flow.base import BaseFlow
|
||||||
from app.flow.planning import PlanningFlow
|
from app.flow.planning import PlanningFlow
|
||||||
|
|
||||||
|
|
||||||
|
class FlowType(str, Enum):
|
||||||
|
PLANNING = "planning"
|
||||||
|
|
||||||
|
|
||||||
class FlowFactory:
|
class FlowFactory:
|
||||||
"""Factory for creating different types of flows with support for multiple agents"""
|
"""Factory for creating different types of flows with support for multiple agents"""
|
||||||
|
|
||||||
|
@ -1,17 +1,47 @@
|
|||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from enum import Enum
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
from app.agent.base import BaseAgent
|
from app.agent.base import BaseAgent
|
||||||
from app.flow.base import BaseFlow, PlanStepStatus
|
from app.flow.base import BaseFlow
|
||||||
from app.llm import LLM
|
from app.llm import LLM
|
||||||
from app.logger import logger
|
from app.logger import logger
|
||||||
from app.schema import AgentState, Message, ToolChoice
|
from app.schema import AgentState, Message, ToolChoice
|
||||||
from app.tool import PlanningTool
|
from app.tool import PlanningTool
|
||||||
|
|
||||||
|
|
||||||
|
class PlanStepStatus(str, Enum):
|
||||||
|
"""Enum class defining possible statuses of a plan step"""
|
||||||
|
|
||||||
|
NOT_STARTED = "not_started"
|
||||||
|
IN_PROGRESS = "in_progress"
|
||||||
|
COMPLETED = "completed"
|
||||||
|
BLOCKED = "blocked"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_all_statuses(cls) -> list[str]:
|
||||||
|
"""Return a list of all possible step status values"""
|
||||||
|
return [status.value for status in cls]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_active_statuses(cls) -> list[str]:
|
||||||
|
"""Return a list of values representing active statuses (not started or in progress)"""
|
||||||
|
return [cls.NOT_STARTED.value, cls.IN_PROGRESS.value]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_status_marks(cls) -> Dict[str, str]:
|
||||||
|
"""Return a mapping of statuses to their marker symbols"""
|
||||||
|
return {
|
||||||
|
cls.COMPLETED.value: "[✓]",
|
||||||
|
cls.IN_PROGRESS.value: "[→]",
|
||||||
|
cls.BLOCKED.value: "[!]",
|
||||||
|
cls.NOT_STARTED.value: "[ ]",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class PlanningFlow(BaseFlow):
|
class PlanningFlow(BaseFlow):
|
||||||
"""A flow that manages planning and execution of tasks using agents."""
|
"""A flow that manages planning and execution of tasks using agents."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user