autobyteus 1.1.2__py3-none-any.whl → 1.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autobyteus/agent/agent.py +1 -1
- autobyteus/agent/bootstrap_steps/__init__.py +2 -0
- autobyteus/agent/bootstrap_steps/agent_bootstrapper.py +2 -0
- autobyteus/agent/bootstrap_steps/mcp_server_prewarming_step.py +71 -0
- autobyteus/agent/bootstrap_steps/system_prompt_processing_step.py +4 -2
- autobyteus/agent/context/agent_config.py +36 -5
- autobyteus/agent/events/worker_event_dispatcher.py +1 -2
- autobyteus/agent/handlers/inter_agent_message_event_handler.py +1 -1
- autobyteus/agent/handlers/llm_user_message_ready_event_handler.py +2 -2
- autobyteus/agent/handlers/tool_result_event_handler.py +48 -20
- autobyteus/agent/handlers/user_input_message_event_handler.py +1 -1
- autobyteus/agent/input_processor/__init__.py +1 -7
- autobyteus/agent/llm_response_processor/provider_aware_tool_usage_processor.py +41 -12
- autobyteus/agent/message/context_file_type.py +6 -0
- autobyteus/agent/message/send_message_to.py +68 -99
- autobyteus/agent/phases/discover.py +2 -1
- autobyteus/agent/runtime/agent_worker.py +25 -34
- autobyteus/agent/shutdown_steps/__init__.py +17 -0
- autobyteus/agent/shutdown_steps/agent_shutdown_orchestrator.py +63 -0
- autobyteus/agent/shutdown_steps/base_shutdown_step.py +33 -0
- autobyteus/agent/shutdown_steps/llm_instance_cleanup_step.py +45 -0
- autobyteus/agent/shutdown_steps/mcp_server_cleanup_step.py +32 -0
- autobyteus/agent/tool_execution_result_processor/__init__.py +9 -0
- autobyteus/agent/tool_execution_result_processor/base_processor.py +46 -0
- autobyteus/agent/tool_execution_result_processor/processor_definition.py +36 -0
- autobyteus/agent/tool_execution_result_processor/processor_meta.py +36 -0
- autobyteus/agent/tool_execution_result_processor/processor_registry.py +70 -0
- autobyteus/agent/workspace/base_workspace.py +17 -2
- autobyteus/cli/__init__.py +1 -1
- autobyteus/cli/cli_display.py +1 -1
- autobyteus/cli/workflow_tui/__init__.py +4 -0
- autobyteus/cli/workflow_tui/app.py +210 -0
- autobyteus/cli/workflow_tui/state.py +189 -0
- autobyteus/cli/workflow_tui/widgets/__init__.py +6 -0
- autobyteus/cli/workflow_tui/widgets/agent_list_sidebar.py +149 -0
- autobyteus/cli/workflow_tui/widgets/focus_pane.py +335 -0
- autobyteus/cli/workflow_tui/widgets/logo.py +27 -0
- autobyteus/cli/workflow_tui/widgets/renderables.py +70 -0
- autobyteus/cli/workflow_tui/widgets/shared.py +51 -0
- autobyteus/cli/workflow_tui/widgets/status_bar.py +14 -0
- autobyteus/events/event_types.py +3 -0
- autobyteus/llm/api/lmstudio_llm.py +37 -0
- autobyteus/llm/api/openai_compatible_llm.py +20 -3
- autobyteus/llm/llm_factory.py +2 -0
- autobyteus/llm/lmstudio_provider.py +89 -0
- autobyteus/llm/providers.py +1 -0
- autobyteus/llm/token_counter/token_counter_factory.py +2 -0
- autobyteus/tools/__init__.py +2 -0
- autobyteus/tools/ask_user_input.py +2 -1
- autobyteus/tools/base_tool.py +2 -0
- autobyteus/tools/bash/bash_executor.py +2 -1
- autobyteus/tools/browser/session_aware/browser_session_aware_navigate_to.py +2 -0
- autobyteus/tools/browser/session_aware/browser_session_aware_web_element_trigger.py +3 -0
- autobyteus/tools/browser/session_aware/browser_session_aware_webpage_reader.py +3 -0
- autobyteus/tools/browser/session_aware/browser_session_aware_webpage_screenshot_taker.py +3 -0
- autobyteus/tools/browser/standalone/google_search_ui.py +2 -0
- autobyteus/tools/browser/standalone/navigate_to.py +2 -0
- autobyteus/tools/browser/standalone/web_page_pdf_generator.py +3 -0
- autobyteus/tools/browser/standalone/webpage_image_downloader.py +3 -0
- autobyteus/tools/browser/standalone/webpage_reader.py +2 -0
- autobyteus/tools/browser/standalone/webpage_screenshot_taker.py +3 -0
- autobyteus/tools/file/file_reader.py +36 -9
- autobyteus/tools/file/file_writer.py +37 -9
- autobyteus/tools/functional_tool.py +5 -4
- autobyteus/tools/image_downloader.py +2 -0
- autobyteus/tools/mcp/__init__.py +10 -7
- autobyteus/tools/mcp/call_handlers/__init__.py +0 -2
- autobyteus/tools/mcp/config_service.py +1 -6
- autobyteus/tools/mcp/factory.py +12 -26
- autobyteus/tools/mcp/server/__init__.py +16 -0
- autobyteus/tools/mcp/server/base_managed_mcp_server.py +139 -0
- autobyteus/tools/mcp/server/http_managed_mcp_server.py +29 -0
- autobyteus/tools/mcp/server/proxy.py +36 -0
- autobyteus/tools/mcp/server/stdio_managed_mcp_server.py +33 -0
- autobyteus/tools/mcp/server_instance_manager.py +93 -0
- autobyteus/tools/mcp/tool.py +28 -46
- autobyteus/tools/mcp/tool_registrar.py +179 -0
- autobyteus/tools/mcp/types.py +10 -21
- autobyteus/tools/pdf_downloader.py +2 -1
- autobyteus/tools/registry/tool_definition.py +20 -7
- autobyteus/tools/registry/tool_registry.py +75 -28
- autobyteus/tools/timer.py +2 -0
- autobyteus/tools/tool_category.py +14 -4
- autobyteus/tools/tool_meta.py +6 -1
- autobyteus/tools/tool_origin.py +10 -0
- autobyteus/workflow/agentic_workflow.py +93 -0
- autobyteus/{agent/workflow → workflow}/base_agentic_workflow.py +19 -27
- autobyteus/workflow/bootstrap_steps/__init__.py +20 -0
- autobyteus/workflow/bootstrap_steps/agent_tool_injection_step.py +34 -0
- autobyteus/workflow/bootstrap_steps/base_workflow_bootstrap_step.py +23 -0
- autobyteus/workflow/bootstrap_steps/coordinator_initialization_step.py +41 -0
- autobyteus/workflow/bootstrap_steps/coordinator_prompt_preparation_step.py +108 -0
- autobyteus/workflow/bootstrap_steps/workflow_bootstrapper.py +50 -0
- autobyteus/workflow/bootstrap_steps/workflow_runtime_queue_initialization_step.py +25 -0
- autobyteus/workflow/context/__init__.py +17 -0
- autobyteus/workflow/context/team_manager.py +147 -0
- autobyteus/workflow/context/workflow_config.py +30 -0
- autobyteus/workflow/context/workflow_context.py +61 -0
- autobyteus/workflow/context/workflow_node_config.py +76 -0
- autobyteus/workflow/context/workflow_runtime_state.py +53 -0
- autobyteus/workflow/events/__init__.py +29 -0
- autobyteus/workflow/events/workflow_event_dispatcher.py +39 -0
- autobyteus/workflow/events/workflow_events.py +53 -0
- autobyteus/workflow/events/workflow_input_event_queue_manager.py +21 -0
- autobyteus/workflow/exceptions.py +8 -0
- autobyteus/workflow/factory/__init__.py +9 -0
- autobyteus/workflow/factory/workflow_factory.py +99 -0
- autobyteus/workflow/handlers/__init__.py +19 -0
- autobyteus/workflow/handlers/base_workflow_event_handler.py +16 -0
- autobyteus/workflow/handlers/inter_agent_message_request_event_handler.py +61 -0
- autobyteus/workflow/handlers/lifecycle_workflow_event_handler.py +27 -0
- autobyteus/workflow/handlers/process_user_message_event_handler.py +46 -0
- autobyteus/workflow/handlers/tool_approval_workflow_event_handler.py +39 -0
- autobyteus/workflow/handlers/workflow_event_handler_registry.py +23 -0
- autobyteus/workflow/phases/__init__.py +11 -0
- autobyteus/workflow/phases/workflow_operational_phase.py +19 -0
- autobyteus/workflow/phases/workflow_phase_manager.py +48 -0
- autobyteus/workflow/runtime/__init__.py +13 -0
- autobyteus/workflow/runtime/workflow_runtime.py +82 -0
- autobyteus/workflow/runtime/workflow_worker.py +117 -0
- autobyteus/workflow/shutdown_steps/__init__.py +17 -0
- autobyteus/workflow/shutdown_steps/agent_team_shutdown_step.py +42 -0
- autobyteus/workflow/shutdown_steps/base_workflow_shutdown_step.py +16 -0
- autobyteus/workflow/shutdown_steps/bridge_cleanup_step.py +28 -0
- autobyteus/workflow/shutdown_steps/sub_workflow_shutdown_step.py +41 -0
- autobyteus/workflow/shutdown_steps/workflow_shutdown_orchestrator.py +35 -0
- autobyteus/workflow/streaming/__init__.py +26 -0
- autobyteus/workflow/streaming/agent_event_bridge.py +48 -0
- autobyteus/workflow/streaming/agent_event_multiplexer.py +70 -0
- autobyteus/workflow/streaming/workflow_event_bridge.py +50 -0
- autobyteus/workflow/streaming/workflow_event_notifier.py +83 -0
- autobyteus/workflow/streaming/workflow_event_stream.py +33 -0
- autobyteus/workflow/streaming/workflow_stream_event_payloads.py +28 -0
- autobyteus/workflow/streaming/workflow_stream_events.py +45 -0
- autobyteus/workflow/utils/__init__.py +9 -0
- autobyteus/workflow/utils/wait_for_idle.py +46 -0
- autobyteus/workflow/workflow_builder.py +151 -0
- {autobyteus-1.1.2.dist-info → autobyteus-1.1.4.dist-info}/METADATA +16 -13
- {autobyteus-1.1.2.dist-info → autobyteus-1.1.4.dist-info}/RECORD +156 -75
- {autobyteus-1.1.2.dist-info → autobyteus-1.1.4.dist-info}/top_level.txt +1 -0
- examples/__init__.py +1 -0
- examples/discover_phase_transitions.py +104 -0
- examples/run_browser_agent.py +260 -0
- examples/run_google_slides_agent.py +286 -0
- examples/run_mcp_browser_client.py +174 -0
- examples/run_mcp_google_slides_client.py +270 -0
- examples/run_mcp_list_tools.py +189 -0
- examples/run_poem_writer.py +274 -0
- examples/run_sqlite_agent.py +293 -0
- examples/workflow/__init__.py +1 -0
- examples/workflow/run_basic_research_workflow.py +189 -0
- examples/workflow/run_code_review_workflow.py +269 -0
- examples/workflow/run_debate_workflow.py +212 -0
- examples/workflow/run_workflow_with_tui.py +153 -0
- autobyteus/agent/context/agent_phase_manager.py +0 -264
- autobyteus/agent/context/phases.py +0 -49
- autobyteus/agent/group/__init__.py +0 -0
- autobyteus/agent/group/agent_group.py +0 -164
- autobyteus/agent/group/agent_group_context.py +0 -81
- autobyteus/agent/input_processor/content_prefixing_input_processor.py +0 -41
- autobyteus/agent/input_processor/metadata_appending_input_processor.py +0 -34
- autobyteus/agent/input_processor/passthrough_input_processor.py +0 -33
- autobyteus/agent/workflow/__init__.py +0 -11
- autobyteus/agent/workflow/agentic_workflow.py +0 -89
- autobyteus/tools/mcp/call_handlers/sse_handler.py +0 -22
- autobyteus/tools/mcp/registrar.py +0 -323
- autobyteus/workflow/simple_task.py +0 -98
- autobyteus/workflow/task.py +0 -147
- autobyteus/workflow/workflow.py +0 -49
- {autobyteus-1.1.2.dist-info → autobyteus-1.1.4.dist-info}/WHEEL +0 -0
- {autobyteus-1.1.2.dist-info → autobyteus-1.1.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
import logging
|
|
3
|
-
from typing import Optional, Callable, Any, List, Union
|
|
4
|
-
|
|
5
|
-
from autobyteus.agent.agent import Agent
|
|
6
|
-
from autobyteus.events.event_types import EventType
|
|
7
|
-
from autobyteus.llm.models import LLMModel
|
|
8
|
-
from autobyteus.llm.llm_factory import LLMFactory
|
|
9
|
-
from autobyteus.conversation.user_message import UserMessage
|
|
10
|
-
|
|
11
|
-
logger = logging.getLogger(__name__)
|
|
12
|
-
|
|
13
|
-
class SimpleTask:
|
|
14
|
-
"""
|
|
15
|
-
A simplified task execution class for running single-instruction tasks
|
|
16
|
-
with minimal configuration and built-in result handling.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
def __init__(
|
|
20
|
-
self,
|
|
21
|
-
name: str,
|
|
22
|
-
instruction: str,
|
|
23
|
-
llm_model: LLMModel,
|
|
24
|
-
input_data: Optional[Union[str, List[str]]] = None,
|
|
25
|
-
output_parser: Optional[Callable[[str], Any]] = None,
|
|
26
|
-
):
|
|
27
|
-
"""
|
|
28
|
-
Initialize a SimpleTask.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
name (str): Name of the task
|
|
32
|
-
instruction (str): Task instruction/prompt
|
|
33
|
-
llm_model (LLMModel): LLM model to use
|
|
34
|
-
input_data (Optional[Union[str, List[str]]], optional): Input data or file paths. Defaults to None.
|
|
35
|
-
output_parser (Optional[Callable], optional): Function to parse the output. Defaults to None.
|
|
36
|
-
"""
|
|
37
|
-
self.name = name
|
|
38
|
-
self.instruction = instruction
|
|
39
|
-
self.llm_model = llm_model
|
|
40
|
-
self.input_data = input_data if isinstance(input_data, list) else ([input_data] if input_data else [])
|
|
41
|
-
self.output_parser = output_parser
|
|
42
|
-
|
|
43
|
-
logger.info(f"Initialized task '{self.name}' with model {self.llm_model.value} and {len(self.input_data)} inputs")
|
|
44
|
-
|
|
45
|
-
async def execute(self) -> Any:
|
|
46
|
-
"""
|
|
47
|
-
Execute the task and return the result.
|
|
48
|
-
|
|
49
|
-
Returns:
|
|
50
|
-
The result of the task execution, parsed if output_parser is provided
|
|
51
|
-
"""
|
|
52
|
-
try:
|
|
53
|
-
llm = LLMFactory.create_llm(self.llm_model)
|
|
54
|
-
|
|
55
|
-
user_message = UserMessage(
|
|
56
|
-
content=self.instruction,
|
|
57
|
-
file_paths=self.input_data
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
agent = Agent(
|
|
61
|
-
role=self.name,
|
|
62
|
-
llm=llm,
|
|
63
|
-
initial_user_message=user_message
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
result_queue = asyncio.Queue()
|
|
67
|
-
|
|
68
|
-
async def handle_response(*args, **kwargs):
|
|
69
|
-
response = kwargs.get('response')
|
|
70
|
-
if response:
|
|
71
|
-
await result_queue.put(response)
|
|
72
|
-
|
|
73
|
-
agent.subscribe(EventType.ASSISTANT_RESPONSE, handle_response, agent.agent_id)
|
|
74
|
-
|
|
75
|
-
try:
|
|
76
|
-
agent.start()
|
|
77
|
-
result = await asyncio.wait_for(
|
|
78
|
-
result_queue.get(),
|
|
79
|
-
timeout=30.0
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
# Only parse if output_parser is provided
|
|
83
|
-
if self.output_parser:
|
|
84
|
-
return self.output_parser(result)
|
|
85
|
-
return result
|
|
86
|
-
|
|
87
|
-
except asyncio.TimeoutError:
|
|
88
|
-
logger.error(f"Task '{self.name}' timed out")
|
|
89
|
-
raise TimeoutError(f"Task '{self.name}' execution timed out")
|
|
90
|
-
|
|
91
|
-
finally:
|
|
92
|
-
agent.unsubscribe("ASSISTANT_RESPONSE", handle_response, agent.agent_id)
|
|
93
|
-
agent.stop()
|
|
94
|
-
await agent.cleanup()
|
|
95
|
-
|
|
96
|
-
except Exception as e:
|
|
97
|
-
logger.error(f"Error executing task '{self.name}': {str(e)}")
|
|
98
|
-
raise
|
autobyteus/workflow/task.py
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
task.py: Contains the Task class for representing individual tasks within a workflow.
|
|
3
|
-
|
|
4
|
-
This module defines the Task class, which encapsulates the functionality for a single task,
|
|
5
|
-
including its objective, input and output descriptions, associated tools, LLM integration,
|
|
6
|
-
and execution logic using a dynamically created Agent.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
from typing import Any, List, Optional
|
|
10
|
-
from autobyteus.tools.base_tool import BaseTool
|
|
11
|
-
from autobyteus.llm.base_llm import BaseLLM
|
|
12
|
-
from autobyteus.agent.agent import Agent
|
|
13
|
-
from autobyteus.prompt.prompt_builder import PromptBuilder
|
|
14
|
-
from autobyteus.person.person import Person
|
|
15
|
-
|
|
16
|
-
class Task:
|
|
17
|
-
def __init__(
|
|
18
|
-
self,
|
|
19
|
-
description: str,
|
|
20
|
-
objective: str,
|
|
21
|
-
input_description: str,
|
|
22
|
-
expected_output_description: str,
|
|
23
|
-
workflow_description: Optional[str],
|
|
24
|
-
tools: List[BaseTool],
|
|
25
|
-
llm: BaseLLM,
|
|
26
|
-
person: Optional[Person] = None,
|
|
27
|
-
subtasks: Optional[List['Task']] = None
|
|
28
|
-
):
|
|
29
|
-
self.description = description
|
|
30
|
-
self.objective = objective
|
|
31
|
-
self.input_description = input_description
|
|
32
|
-
self.expected_output_description = expected_output_description
|
|
33
|
-
self.workflow_description = workflow_description
|
|
34
|
-
self.tools = tools
|
|
35
|
-
self.llm = llm
|
|
36
|
-
self.person = None
|
|
37
|
-
if person:
|
|
38
|
-
self.assign_to(person)
|
|
39
|
-
self.subtasks = subtasks or []
|
|
40
|
-
self.result = None
|
|
41
|
-
|
|
42
|
-
def assign_to(self, person: Person):
|
|
43
|
-
if self.person:
|
|
44
|
-
self.person.unassign_task(self)
|
|
45
|
-
self.person = person
|
|
46
|
-
person.assign_task(self)
|
|
47
|
-
|
|
48
|
-
def unassign(self):
|
|
49
|
-
if self.person:
|
|
50
|
-
self.person.unassign_task(self)
|
|
51
|
-
self.person = None
|
|
52
|
-
|
|
53
|
-
async def execute(self, input_data: Any) -> Any:
|
|
54
|
-
if self.subtasks:
|
|
55
|
-
return await self._execute_subtasks(input_data)
|
|
56
|
-
else:
|
|
57
|
-
return await self._execute_single_task(input_data)
|
|
58
|
-
|
|
59
|
-
async def _execute_subtasks(self, input_data: Any) -> Any:
|
|
60
|
-
result = input_data
|
|
61
|
-
for subtask in self.subtasks:
|
|
62
|
-
print(f"Executing subtask: {subtask.objective}")
|
|
63
|
-
result = await subtask.execute(result)
|
|
64
|
-
self.result = result
|
|
65
|
-
return self.result
|
|
66
|
-
|
|
67
|
-
async def _execute_single_task(self, input_data: Any) -> Any:
|
|
68
|
-
agent = self._create_agent()
|
|
69
|
-
|
|
70
|
-
# Set the variable values for the prompt
|
|
71
|
-
agent.prompt_builder.set_variable_value("name", self.person.name)
|
|
72
|
-
agent.prompt_builder.set_variable_value("role", self.person.role.name)
|
|
73
|
-
agent.prompt_builder.set_variable_value("person_description", self.person.get_description())
|
|
74
|
-
agent.prompt_builder.set_variable_value("task_description", self.description)
|
|
75
|
-
agent.prompt_builder.set_variable_value("objective", self.objective)
|
|
76
|
-
agent.prompt_builder.set_variable_value("input_description", self.input_description)
|
|
77
|
-
agent.prompt_builder.set_variable_value("expected_output_description", self.expected_output_description)
|
|
78
|
-
agent.prompt_builder.set_variable_value("workflow_description", self.workflow_description)
|
|
79
|
-
agent.prompt_builder.set_variable_value("tools", self._format_tools())
|
|
80
|
-
agent.prompt_builder.set_variable_value("input_data", str(input_data))
|
|
81
|
-
|
|
82
|
-
# Run the agent
|
|
83
|
-
await agent.run()
|
|
84
|
-
|
|
85
|
-
# Retrieve the result from the agent's conversation
|
|
86
|
-
self.result = agent.conversation.get_last_assistant_message()
|
|
87
|
-
return self.result
|
|
88
|
-
|
|
89
|
-
def _create_agent(self) -> Agent:
|
|
90
|
-
agent_id = f"task_{self.objective[:10]}_{id(self)}"
|
|
91
|
-
|
|
92
|
-
# Generate the initial prompt
|
|
93
|
-
initial_prompt = self._generate_initial_prompt()
|
|
94
|
-
|
|
95
|
-
return Agent(
|
|
96
|
-
role=f"Task_{self.objective[:20]}",
|
|
97
|
-
llm=self.llm,
|
|
98
|
-
tools=self.tools,
|
|
99
|
-
use_xml_parser=True,
|
|
100
|
-
agent_id=agent_id,
|
|
101
|
-
initial_user_message=initial_prompt
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
def _generate_initial_prompt(self) -> str:
|
|
105
|
-
template = """
|
|
106
|
-
You are {name}. Your role is {role}.
|
|
107
|
-
|
|
108
|
-
{person_description}
|
|
109
|
-
|
|
110
|
-
Task Description: {task_description}
|
|
111
|
-
Objective: {objective}
|
|
112
|
-
|
|
113
|
-
Input Description: {input_description}
|
|
114
|
-
Expected Output: {expected_output_description}
|
|
115
|
-
|
|
116
|
-
Workflow:
|
|
117
|
-
{workflow_description}
|
|
118
|
-
|
|
119
|
-
Available Tools:
|
|
120
|
-
{tools}
|
|
121
|
-
|
|
122
|
-
Input Data:
|
|
123
|
-
{input_data}
|
|
124
|
-
|
|
125
|
-
Please complete the task based on the given information and using the available tools.
|
|
126
|
-
"""
|
|
127
|
-
prompt_builder = PromptBuilder.from_string(template)
|
|
128
|
-
prompt_builder.set_variable_value("name", self.person.name)
|
|
129
|
-
prompt_builder.set_variable_value("role", self.person.role.name)
|
|
130
|
-
prompt_builder.set_variable_value("person_description", self.person.get_description())
|
|
131
|
-
prompt_builder.set_variable_value("task_description", self.description)
|
|
132
|
-
prompt_builder.set_variable_value("objective", self.objective)
|
|
133
|
-
prompt_builder.set_variable_value("input_description", self.input_description)
|
|
134
|
-
prompt_builder.set_variable_value("expected_output_description", self.expected_output_description)
|
|
135
|
-
prompt_builder.set_variable_value("workflow_description", self.workflow_description)
|
|
136
|
-
prompt_builder.set_variable_value("tools", self._format_tools())
|
|
137
|
-
prompt_builder.set_variable_value("input_data", "To be provided during execution")
|
|
138
|
-
return prompt_builder.build()
|
|
139
|
-
|
|
140
|
-
def _format_tools(self) -> str:
|
|
141
|
-
return "\n".join([f"- {tool.get_name()}: {tool.get_description()}" for tool in self.tools])
|
|
142
|
-
|
|
143
|
-
def get_result(self) -> Any:
|
|
144
|
-
return self.result
|
|
145
|
-
|
|
146
|
-
def add_subtask(self, subtask: 'Task'):
|
|
147
|
-
self.subtasks.append(subtask)
|
autobyteus/workflow/workflow.py
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
workflow.py: Contains the Workflow class for managing a sequence of tasks.
|
|
3
|
-
|
|
4
|
-
This module defines the Workflow class, which represents a series of tasks to be executed in order.
|
|
5
|
-
The Workflow class allows adding tasks, executing the entire workflow, and retrieving the final result.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from typing import List, Any
|
|
9
|
-
from autobyteus.workflow.task import Task
|
|
10
|
-
|
|
11
|
-
class Workflow:
|
|
12
|
-
def __init__(self):
|
|
13
|
-
"""
|
|
14
|
-
Initialize a new Workflow instance with an empty list of tasks.
|
|
15
|
-
"""
|
|
16
|
-
self.tasks: List[Task] = []
|
|
17
|
-
|
|
18
|
-
def add_task(self, task: Task):
|
|
19
|
-
"""
|
|
20
|
-
Add a new task to the workflow.
|
|
21
|
-
|
|
22
|
-
Args:
|
|
23
|
-
task (Task): The task to be added to the workflow.
|
|
24
|
-
"""
|
|
25
|
-
self.tasks.append(task)
|
|
26
|
-
|
|
27
|
-
async def execute(self, input_data: Any) -> Any:
|
|
28
|
-
"""
|
|
29
|
-
Execute all tasks in the workflow sequentially.
|
|
30
|
-
|
|
31
|
-
Args:
|
|
32
|
-
input_data (Any): The initial input data for the first task.
|
|
33
|
-
|
|
34
|
-
Returns:
|
|
35
|
-
Any: The result of the final task in the workflow.
|
|
36
|
-
"""
|
|
37
|
-
result = input_data
|
|
38
|
-
for task in self.tasks:
|
|
39
|
-
result = await task.execute(result)
|
|
40
|
-
return result
|
|
41
|
-
|
|
42
|
-
def get_result(self) -> Any:
|
|
43
|
-
"""
|
|
44
|
-
Get the result of the last task in the workflow.
|
|
45
|
-
|
|
46
|
-
Returns:
|
|
47
|
-
Any: The result of the last task, or None if there are no tasks.
|
|
48
|
-
"""
|
|
49
|
-
return self.tasks[-1].get_result() if self.tasks else None
|
|
File without changes
|
|
File without changes
|