autobyteus 1.1.4__py3-none-any.whl → 1.1.5__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/context/__init__.py +4 -2
- autobyteus/agent/context/agent_config.py +0 -4
- autobyteus/agent/context/agent_context_registry.py +73 -0
- autobyteus/agent/events/notifiers.py +4 -0
- autobyteus/agent/handlers/inter_agent_message_event_handler.py +7 -2
- autobyteus/agent/handlers/llm_complete_response_received_event_handler.py +19 -19
- autobyteus/agent/handlers/user_input_message_event_handler.py +15 -0
- autobyteus/agent/message/send_message_to.py +29 -23
- autobyteus/agent/runtime/agent_runtime.py +10 -2
- autobyteus/agent/sender_type.py +15 -0
- autobyteus/agent/streaming/agent_event_stream.py +6 -0
- autobyteus/agent/streaming/stream_event_payloads.py +12 -0
- autobyteus/agent/streaming/stream_events.py +3 -0
- autobyteus/agent/system_prompt_processor/tool_manifest_injector_processor.py +7 -4
- autobyteus/agent_team/__init__.py +1 -0
- autobyteus/agent_team/agent_team.py +93 -0
- autobyteus/agent_team/agent_team_builder.py +184 -0
- autobyteus/agent_team/base_agent_team.py +86 -0
- autobyteus/agent_team/bootstrap_steps/__init__.py +24 -0
- autobyteus/agent_team/bootstrap_steps/agent_configuration_preparation_step.py +73 -0
- autobyteus/agent_team/bootstrap_steps/agent_team_bootstrapper.py +54 -0
- autobyteus/agent_team/bootstrap_steps/agent_team_runtime_queue_initialization_step.py +25 -0
- autobyteus/agent_team/bootstrap_steps/base_agent_team_bootstrap_step.py +23 -0
- autobyteus/agent_team/bootstrap_steps/coordinator_initialization_step.py +41 -0
- autobyteus/agent_team/bootstrap_steps/coordinator_prompt_preparation_step.py +85 -0
- autobyteus/agent_team/bootstrap_steps/task_notifier_initialization_step.py +51 -0
- autobyteus/agent_team/bootstrap_steps/team_context_initialization_step.py +45 -0
- autobyteus/agent_team/context/__init__.py +17 -0
- autobyteus/agent_team/context/agent_team_config.py +33 -0
- autobyteus/agent_team/context/agent_team_context.py +61 -0
- autobyteus/agent_team/context/agent_team_runtime_state.py +56 -0
- autobyteus/agent_team/context/team_manager.py +147 -0
- autobyteus/agent_team/context/team_node_config.py +76 -0
- autobyteus/agent_team/events/__init__.py +29 -0
- autobyteus/agent_team/events/agent_team_event_dispatcher.py +39 -0
- autobyteus/agent_team/events/agent_team_events.py +53 -0
- autobyteus/agent_team/events/agent_team_input_event_queue_manager.py +21 -0
- autobyteus/agent_team/exceptions.py +8 -0
- autobyteus/agent_team/factory/__init__.py +9 -0
- autobyteus/agent_team/factory/agent_team_factory.py +99 -0
- autobyteus/agent_team/handlers/__init__.py +19 -0
- autobyteus/agent_team/handlers/agent_team_event_handler_registry.py +23 -0
- autobyteus/agent_team/handlers/base_agent_team_event_handler.py +16 -0
- autobyteus/agent_team/handlers/inter_agent_message_request_event_handler.py +61 -0
- autobyteus/agent_team/handlers/lifecycle_agent_team_event_handler.py +27 -0
- autobyteus/agent_team/handlers/process_user_message_event_handler.py +46 -0
- autobyteus/agent_team/handlers/tool_approval_team_event_handler.py +48 -0
- autobyteus/agent_team/phases/__init__.py +11 -0
- autobyteus/agent_team/phases/agent_team_operational_phase.py +19 -0
- autobyteus/agent_team/phases/agent_team_phase_manager.py +48 -0
- autobyteus/agent_team/runtime/__init__.py +13 -0
- autobyteus/agent_team/runtime/agent_team_runtime.py +82 -0
- autobyteus/agent_team/runtime/agent_team_worker.py +117 -0
- autobyteus/agent_team/shutdown_steps/__init__.py +17 -0
- autobyteus/agent_team/shutdown_steps/agent_team_shutdown_orchestrator.py +35 -0
- autobyteus/agent_team/shutdown_steps/agent_team_shutdown_step.py +42 -0
- autobyteus/agent_team/shutdown_steps/base_agent_team_shutdown_step.py +16 -0
- autobyteus/agent_team/shutdown_steps/bridge_cleanup_step.py +28 -0
- autobyteus/agent_team/shutdown_steps/sub_team_shutdown_step.py +41 -0
- autobyteus/agent_team/streaming/__init__.py +26 -0
- autobyteus/agent_team/streaming/agent_event_bridge.py +48 -0
- autobyteus/agent_team/streaming/agent_event_multiplexer.py +70 -0
- autobyteus/agent_team/streaming/agent_team_event_notifier.py +64 -0
- autobyteus/agent_team/streaming/agent_team_event_stream.py +33 -0
- autobyteus/agent_team/streaming/agent_team_stream_event_payloads.py +32 -0
- autobyteus/agent_team/streaming/agent_team_stream_events.py +56 -0
- autobyteus/agent_team/streaming/team_event_bridge.py +50 -0
- autobyteus/agent_team/task_notification/__init__.py +11 -0
- autobyteus/agent_team/task_notification/system_event_driven_agent_task_notifier.py +164 -0
- autobyteus/agent_team/task_notification/task_notification_mode.py +24 -0
- autobyteus/agent_team/utils/__init__.py +9 -0
- autobyteus/agent_team/utils/wait_for_idle.py +46 -0
- autobyteus/cli/agent_team_tui/__init__.py +4 -0
- autobyteus/cli/agent_team_tui/app.py +210 -0
- autobyteus/cli/agent_team_tui/state.py +180 -0
- autobyteus/cli/agent_team_tui/widgets/__init__.py +6 -0
- autobyteus/cli/agent_team_tui/widgets/agent_list_sidebar.py +149 -0
- autobyteus/cli/agent_team_tui/widgets/focus_pane.py +320 -0
- autobyteus/cli/agent_team_tui/widgets/logo.py +20 -0
- autobyteus/cli/agent_team_tui/widgets/renderables.py +77 -0
- autobyteus/cli/agent_team_tui/widgets/shared.py +60 -0
- autobyteus/cli/agent_team_tui/widgets/status_bar.py +14 -0
- autobyteus/cli/agent_team_tui/widgets/task_board_panel.py +82 -0
- autobyteus/events/event_types.py +7 -2
- autobyteus/llm/api/autobyteus_llm.py +11 -12
- autobyteus/llm/api/lmstudio_llm.py +10 -13
- autobyteus/llm/api/ollama_llm.py +8 -13
- autobyteus/llm/autobyteus_provider.py +73 -46
- autobyteus/llm/llm_factory.py +102 -140
- autobyteus/llm/lmstudio_provider.py +63 -48
- autobyteus/llm/models.py +83 -53
- autobyteus/llm/ollama_provider.py +69 -61
- autobyteus/llm/ollama_provider_resolver.py +1 -0
- autobyteus/llm/providers.py +13 -13
- autobyteus/llm/runtimes.py +11 -0
- autobyteus/task_management/__init__.py +43 -0
- autobyteus/task_management/base_task_board.py +68 -0
- autobyteus/task_management/converters/__init__.py +11 -0
- autobyteus/task_management/converters/task_board_converter.py +64 -0
- autobyteus/task_management/converters/task_plan_converter.py +48 -0
- autobyteus/task_management/deliverable.py +16 -0
- autobyteus/task_management/deliverables/__init__.py +8 -0
- autobyteus/task_management/deliverables/file_deliverable.py +15 -0
- autobyteus/task_management/events.py +27 -0
- autobyteus/task_management/in_memory_task_board.py +126 -0
- autobyteus/task_management/schemas/__init__.py +15 -0
- autobyteus/task_management/schemas/deliverable_schema.py +13 -0
- autobyteus/task_management/schemas/plan_definition.py +35 -0
- autobyteus/task_management/schemas/task_status_report.py +27 -0
- autobyteus/task_management/task_plan.py +110 -0
- autobyteus/task_management/tools/__init__.py +14 -0
- autobyteus/task_management/tools/get_task_board_status.py +68 -0
- autobyteus/task_management/tools/publish_task_plan.py +113 -0
- autobyteus/task_management/tools/update_task_status.py +135 -0
- autobyteus/tools/bash/bash_executor.py +59 -14
- autobyteus/tools/mcp/config_service.py +63 -58
- autobyteus/tools/mcp/server/http_managed_mcp_server.py +14 -2
- autobyteus/tools/mcp/server/stdio_managed_mcp_server.py +14 -2
- autobyteus/tools/mcp/server_instance_manager.py +30 -4
- autobyteus/tools/mcp/tool_registrar.py +103 -50
- autobyteus/tools/parameter_schema.py +17 -11
- autobyteus/tools/registry/tool_definition.py +24 -29
- autobyteus/tools/tool_category.py +1 -0
- autobyteus/tools/usage/formatters/default_json_example_formatter.py +78 -3
- autobyteus/tools/usage/formatters/default_xml_example_formatter.py +23 -3
- autobyteus/tools/usage/formatters/gemini_json_example_formatter.py +6 -0
- autobyteus/tools/usage/formatters/google_json_example_formatter.py +7 -0
- autobyteus/tools/usage/formatters/openai_json_example_formatter.py +6 -4
- autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py +23 -7
- autobyteus/tools/usage/parsers/provider_aware_tool_usage_parser.py +14 -25
- autobyteus/tools/usage/providers/__init__.py +2 -12
- autobyteus/tools/usage/providers/tool_manifest_provider.py +36 -29
- autobyteus/tools/usage/registries/__init__.py +7 -12
- autobyteus/tools/usage/registries/tool_formatter_pair.py +15 -0
- autobyteus/tools/usage/registries/tool_formatting_registry.py +58 -0
- autobyteus/tools/usage/registries/tool_usage_parser_registry.py +55 -0
- {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/METADATA +3 -3
- {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/RECORD +146 -72
- examples/agent_team/__init__.py +1 -0
- examples/run_browser_agent.py +17 -15
- examples/run_google_slides_agent.py +17 -16
- examples/run_poem_writer.py +22 -12
- examples/run_sqlite_agent.py +17 -15
- autobyteus/tools/mcp/call_handlers/__init__.py +0 -16
- autobyteus/tools/mcp/call_handlers/base_handler.py +0 -40
- autobyteus/tools/mcp/call_handlers/stdio_handler.py +0 -76
- autobyteus/tools/mcp/call_handlers/streamable_http_handler.py +0 -55
- autobyteus/tools/usage/providers/json_example_provider.py +0 -32
- autobyteus/tools/usage/providers/json_schema_provider.py +0 -35
- autobyteus/tools/usage/providers/json_tool_usage_parser_provider.py +0 -28
- autobyteus/tools/usage/providers/xml_example_provider.py +0 -28
- autobyteus/tools/usage/providers/xml_schema_provider.py +0 -29
- autobyteus/tools/usage/providers/xml_tool_usage_parser_provider.py +0 -26
- autobyteus/tools/usage/registries/json_example_formatter_registry.py +0 -51
- autobyteus/tools/usage/registries/json_schema_formatter_registry.py +0 -51
- autobyteus/tools/usage/registries/json_tool_usage_parser_registry.py +0 -42
- autobyteus/tools/usage/registries/xml_example_formatter_registry.py +0 -30
- autobyteus/tools/usage/registries/xml_schema_formatter_registry.py +0 -33
- autobyteus/tools/usage/registries/xml_tool_usage_parser_registry.py +0 -30
- examples/workflow/__init__.py +0 -1
- examples/workflow/run_basic_research_workflow.py +0 -189
- examples/workflow/run_code_review_workflow.py +0 -269
- examples/workflow/run_debate_workflow.py +0 -212
- examples/workflow/run_workflow_with_tui.py +0 -153
- {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/WHEEL +0 -0
- {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/licenses/LICENSE +0 -0
- {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/top_level.txt +0 -0
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
# file: autobyteus/examples/workflow/run_debate_workflow.py
|
|
2
|
-
"""
|
|
3
|
-
This example script demonstrates a hierarchical workflow.
|
|
4
|
-
A parent workflow (The Debate) manages two sub-workflows (Debating Teams).
|
|
5
|
-
"""
|
|
6
|
-
import asyncio
|
|
7
|
-
import logging
|
|
8
|
-
import argparse
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
import sys
|
|
11
|
-
import os
|
|
12
|
-
|
|
13
|
-
# --- Boilerplate to make the script runnable from the project root ---
|
|
14
|
-
SCRIPT_DIR = Path(__file__).resolve().parent.parent
|
|
15
|
-
PACKAGE_ROOT = SCRIPT_DIR.parent
|
|
16
|
-
if str(PACKAGE_ROOT) not in sys.path:
|
|
17
|
-
sys.path.insert(0, str(PACKAGE_ROOT))
|
|
18
|
-
|
|
19
|
-
# Load environment variables from .env file
|
|
20
|
-
try:
|
|
21
|
-
from dotenv import load_dotenv
|
|
22
|
-
load_dotenv(PACKAGE_ROOT / ".env")
|
|
23
|
-
except ImportError:
|
|
24
|
-
pass
|
|
25
|
-
|
|
26
|
-
# --- Imports for the Workflow TUI Example ---
|
|
27
|
-
try:
|
|
28
|
-
from autobyteus.agent.context import AgentConfig
|
|
29
|
-
from autobyteus.llm.models import LLMModel
|
|
30
|
-
from autobyteus.llm.llm_factory import default_llm_factory, LLMFactory
|
|
31
|
-
from autobyteus.workflow.workflow_builder import WorkflowBuilder
|
|
32
|
-
from autobyteus.cli.workflow_tui.app import WorkflowApp
|
|
33
|
-
from autobyteus.workflow.context.workflow_config import WorkflowConfig
|
|
34
|
-
except ImportError as e:
|
|
35
|
-
print(f"Error importing autobyteus components: {e}", file=sys.stderr)
|
|
36
|
-
sys.exit(1)
|
|
37
|
-
|
|
38
|
-
# --- Logging Setup ---
|
|
39
|
-
def setup_file_logging() -> Path:
|
|
40
|
-
log_dir = PACKAGE_ROOT / "logs"
|
|
41
|
-
log_dir.mkdir(exist_ok=True)
|
|
42
|
-
log_file_path = log_dir / "debate_workflow_tui_app.log"
|
|
43
|
-
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s: %(message)s", filename=log_file_path, filemode="w")
|
|
44
|
-
logging.getLogger("asyncio").setLevel(logging.WARNING)
|
|
45
|
-
logging.getLogger("textual").setLevel(logging.WARNING)
|
|
46
|
-
return log_file_path
|
|
47
|
-
|
|
48
|
-
def create_debate_workflow(moderator_model: str, affirmative_model: str, negative_model: str, use_xml_tool_format: bool = True):
|
|
49
|
-
"""Creates a hierarchical debate workflow for the TUI demonstration."""
|
|
50
|
-
# Validate models
|
|
51
|
-
def _validate_model(model_name: str):
|
|
52
|
-
try:
|
|
53
|
-
_ = LLMModel[model_name]
|
|
54
|
-
except KeyError:
|
|
55
|
-
logging.critical(f"LLM Model '{model_name}' is not valid. Use --help-models to see available models.")
|
|
56
|
-
print(f"\nCRITICAL ERROR: LLM Model '{model_name}' is not valid. Use --help-models to see available models.\nCheck log file for details.")
|
|
57
|
-
sys.exit(1)
|
|
58
|
-
|
|
59
|
-
for model in [moderator_model, affirmative_model, negative_model]:
|
|
60
|
-
_validate_model(model)
|
|
61
|
-
|
|
62
|
-
logging.info(f"Using models -> Moderator: {moderator_model}, Affirmative: {affirmative_model}, Negative: {negative_model}")
|
|
63
|
-
logging.info(f"Using XML tool format: {use_xml_tool_format}")
|
|
64
|
-
|
|
65
|
-
# --- AGENT CONFIGURATIONS ---
|
|
66
|
-
|
|
67
|
-
# Parent-Level Agents
|
|
68
|
-
moderator_config = AgentConfig(
|
|
69
|
-
name="DebateModerator", role="Coordinator", description="Manages the debate, gives turns, and summarizes.",
|
|
70
|
-
llm_instance=default_llm_factory.create_llm(model_identifier=moderator_model),
|
|
71
|
-
system_prompt=(
|
|
72
|
-
"You are the impartial moderator of a debate between two teams. Your goal is to facilitate a structured, turn-by-turn debate on a user's topic.\n"
|
|
73
|
-
"Your team consists of Team_Affirmative and Team_Negative. You will delegate tasks to them using their unique names.\n"
|
|
74
|
-
"Responsibilities: 1. Announce the topic. 2. Ask Team_Affirmative for an opening statement. 3. Ask Team_Negative for a rebuttal. "
|
|
75
|
-
"4. Facilitate a structured flow of arguments. 5. Conclude the debate.\n"
|
|
76
|
-
"CRITICAL RULE: You must enforce a strict turn-based system. Only communicate with ONE team at a time using the `SendMessageTo` tool. After sending a message, you must wait for a response before messaging the other team.\n"
|
|
77
|
-
"Do not debate yourself. Your role is to moderate.\n\n{{tools}}"
|
|
78
|
-
),
|
|
79
|
-
use_xml_tool_format=use_xml_tool_format
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
# Team Affirmative Agents
|
|
83
|
-
lead_affirmative_config = AgentConfig(
|
|
84
|
-
name="Lead_Affirmative", role="Coordinator", description="Leads the team arguing FOR the motion.",
|
|
85
|
-
llm_instance=default_llm_factory.create_llm(model_identifier=affirmative_model),
|
|
86
|
-
system_prompt=(
|
|
87
|
-
"You are the lead of the Affirmative team. You receive high-level instructions from the DebateModerator (e.g., 'prepare opening statement').\n"
|
|
88
|
-
"Your job is to delegate this task to your team member, the Proponent, by giving them a specific instruction.\n\n{{tools}}"
|
|
89
|
-
),
|
|
90
|
-
use_xml_tool_format=use_xml_tool_format
|
|
91
|
-
)
|
|
92
|
-
proponent_config = AgentConfig(
|
|
93
|
-
name="Proponent", role="Debater", description="Argues in favor of the debate topic.",
|
|
94
|
-
llm_instance=default_llm_factory.create_llm(model_identifier=affirmative_model),
|
|
95
|
-
system_prompt="You are a Proponent. You will receive instructions from your team lead. Your role is to argue STRONGLY and PERSUASIVELY IN FAVOR of the motion.",
|
|
96
|
-
use_xml_tool_format=use_xml_tool_format
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
# Team Negative Agents
|
|
100
|
-
lead_negative_config = AgentConfig(
|
|
101
|
-
name="Lead_Negative", role="Coordinator", description="Leads the team arguing AGAINST the motion.",
|
|
102
|
-
llm_instance=default_llm_factory.create_llm(model_identifier=negative_model),
|
|
103
|
-
system_prompt=(
|
|
104
|
-
"You are the lead of the Negative team. You receive high-level instructions from the DebateModerator (e.g., 'prepare your rebuttal').\n"
|
|
105
|
-
"Your job is to delegate this task to your team member, the Opponent, by giving them a specific instruction.\n\n{{tools}}"
|
|
106
|
-
),
|
|
107
|
-
use_xml_tool_format=use_xml_tool_format
|
|
108
|
-
)
|
|
109
|
-
opponent_config = AgentConfig(
|
|
110
|
-
name="Opponent", role="Debater", description="Argues against the debate topic.",
|
|
111
|
-
llm_instance=default_llm_factory.create_llm(model_identifier=negative_model),
|
|
112
|
-
system_prompt="You are an Opponent. You will receive instructions from your team lead. Your role is to argue STRONGLY and PERSUASIVELY AGAINST the motion.",
|
|
113
|
-
use_xml_tool_format=use_xml_tool_format
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
# --- BUILD SUB-WORKFLOWS ---
|
|
117
|
-
|
|
118
|
-
# Build Team Affirmative
|
|
119
|
-
team_affirmative_workflow: WorkflowConfig = (
|
|
120
|
-
WorkflowBuilder(name="Team_Affirmative", description="A two-agent team that argues in favor of a proposition.", role="Argues FOR the motion")
|
|
121
|
-
.set_coordinator(lead_affirmative_config)
|
|
122
|
-
.add_agent_node(proponent_config)
|
|
123
|
-
.build()._runtime.context.config # Build to get the config object
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
# Build Team Negative
|
|
127
|
-
team_negative_workflow: WorkflowConfig = (
|
|
128
|
-
WorkflowBuilder(name="Team_Negative", description="A two-agent team that argues against a proposition.", role="Argues AGAINST the motion")
|
|
129
|
-
.set_coordinator(lead_negative_config)
|
|
130
|
-
.add_agent_node(opponent_config)
|
|
131
|
-
.build()._runtime.context.config # Build to get the config object
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
# --- BUILD PARENT WORKFLOW ---
|
|
135
|
-
|
|
136
|
-
debate_workflow = (
|
|
137
|
-
WorkflowBuilder(name="Grand_Debate", description="A hierarchical workflow for a moderated debate between two teams.")
|
|
138
|
-
.set_coordinator(moderator_config)
|
|
139
|
-
.add_workflow_node(team_affirmative_workflow)
|
|
140
|
-
.add_workflow_node(team_negative_workflow)
|
|
141
|
-
.build()
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
return debate_workflow
|
|
145
|
-
|
|
146
|
-
async def main(args: argparse.Namespace, log_file: Path):
|
|
147
|
-
"""Main async function to create the workflow and run the TUI app."""
|
|
148
|
-
print("Setting up hierarchical debate workflow...")
|
|
149
|
-
print(f"--> Logs will be written to: {log_file.resolve()}")
|
|
150
|
-
|
|
151
|
-
# Resolve model for each role, falling back to the default --llm-model
|
|
152
|
-
moderator_model = args.moderator_model or args.llm_model
|
|
153
|
-
affirmative_model = args.affirmative_model or args.llm_model
|
|
154
|
-
negative_model = args.negative_model or args.llm_model
|
|
155
|
-
print(f"--> Moderator Model: {moderator_model}")
|
|
156
|
-
print(f"--> Affirmative Team Model: {affirmative_model}")
|
|
157
|
-
print(f"--> Negative Team Model: {negative_model}")
|
|
158
|
-
|
|
159
|
-
# Determine tool format setting from args
|
|
160
|
-
use_xml_tool_format = not args.no_xml_tools
|
|
161
|
-
print(f"--> Using XML Tool Format: {use_xml_tool_format}")
|
|
162
|
-
|
|
163
|
-
try:
|
|
164
|
-
workflow = create_debate_workflow(
|
|
165
|
-
moderator_model=moderator_model,
|
|
166
|
-
affirmative_model=affirmative_model,
|
|
167
|
-
negative_model=negative_model,
|
|
168
|
-
use_xml_tool_format=use_xml_tool_format,
|
|
169
|
-
)
|
|
170
|
-
app = WorkflowApp(workflow=workflow)
|
|
171
|
-
await app.run_async()
|
|
172
|
-
except Exception as e:
|
|
173
|
-
logging.critical(f"Failed to create or run debate workflow TUI: {e}", exc_info=True)
|
|
174
|
-
print(f"\nCRITICAL ERROR: {e}\nCheck log file for details: {log_file.resolve()}")
|
|
175
|
-
|
|
176
|
-
if __name__ == "__main__":
|
|
177
|
-
parser = argparse.ArgumentParser(
|
|
178
|
-
description="Run a hierarchical 2-team debate workflow with a Textual TUI.",
|
|
179
|
-
formatter_class=argparse.RawTextHelpFormatter
|
|
180
|
-
)
|
|
181
|
-
parser.add_argument("--llm-model", type=str, default="kimi-latest", help="The default LLM model for all agents. Can be overridden by other arguments.")
|
|
182
|
-
parser.add_argument("--moderator-model", type=str, help="Specific LLM model for the Moderator. Defaults to --llm-model.")
|
|
183
|
-
parser.add_argument("--affirmative-model", type=str, help="Specific LLM model for the Affirmative Team. Defaults to --llm-model.")
|
|
184
|
-
parser.add_argument("--negative-model", type=str, help="Specific LLM model for the Negative Team. Defaults to --llm-model.")
|
|
185
|
-
parser.add_argument("--no-xml-tools", action="store_true", help="Disable XML-based tool formatting. Recommended for models that struggle with XML.")
|
|
186
|
-
parser.add_argument("--help-models", action="store_true", help="Display available LLM models and exit.")
|
|
187
|
-
|
|
188
|
-
if "--help-models" in sys.argv:
|
|
189
|
-
try:
|
|
190
|
-
LLMFactory.ensure_initialized()
|
|
191
|
-
print("Available LLM Models (you can use either name or value with model arguments):")
|
|
192
|
-
all_models = sorted(list(LLMModel), key=lambda m: m.name)
|
|
193
|
-
if not all_models:
|
|
194
|
-
print(" No models found.")
|
|
195
|
-
for model in all_models:
|
|
196
|
-
print(f" - Name: {model.name:<35} Value: {model.value}")
|
|
197
|
-
except Exception as e:
|
|
198
|
-
print(f"Error listing models: {e}")
|
|
199
|
-
sys.exit(0)
|
|
200
|
-
|
|
201
|
-
parsed_args = parser.parse_args()
|
|
202
|
-
|
|
203
|
-
log_file_path = setup_file_logging()
|
|
204
|
-
try:
|
|
205
|
-
asyncio.run(main(parsed_args, log_file_path))
|
|
206
|
-
except KeyboardInterrupt:
|
|
207
|
-
print("\nExiting application.")
|
|
208
|
-
except Exception as e:
|
|
209
|
-
# This catches errors during asyncio.run, which might not be logged otherwise
|
|
210
|
-
logging.critical(f"Top-level application error: {e}", exc_info=True)
|
|
211
|
-
print(f"\nUNHANDLED ERROR: {e}\nCheck log file for details: {log_file_path.resolve()}")
|
|
212
|
-
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
# file: autobyteus/examples/workflow/run_workflow_with_tui.py
|
|
2
|
-
"""
|
|
3
|
-
This example script demonstrates how to run an AgenticWorkflow with the
|
|
4
|
-
new Textual-based user interface.
|
|
5
|
-
"""
|
|
6
|
-
import asyncio
|
|
7
|
-
import logging
|
|
8
|
-
import argparse
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
import sys
|
|
11
|
-
import os
|
|
12
|
-
|
|
13
|
-
# --- Boilerplate to make the script runnable from the project root ---
|
|
14
|
-
SCRIPT_DIR = Path(__file__).resolve().parent.parent
|
|
15
|
-
PACKAGE_ROOT = SCRIPT_DIR.parent
|
|
16
|
-
if str(PACKAGE_ROOT) not in sys.path:
|
|
17
|
-
sys.path.insert(0, str(PACKAGE_ROOT))
|
|
18
|
-
|
|
19
|
-
# Load environment variables from .env file
|
|
20
|
-
try:
|
|
21
|
-
from dotenv import load_dotenv
|
|
22
|
-
load_dotenv(PACKAGE_ROOT / ".env")
|
|
23
|
-
except ImportError:
|
|
24
|
-
pass
|
|
25
|
-
|
|
26
|
-
# --- Imports for the Workflow TUI Example ---
|
|
27
|
-
try:
|
|
28
|
-
from autobyteus.agent.context import AgentConfig
|
|
29
|
-
from autobyteus.llm.models import LLMModel
|
|
30
|
-
from autobyteus.llm.llm_factory import default_llm_factory, LLMFactory
|
|
31
|
-
from autobyteus.workflow.workflow_builder import WorkflowBuilder
|
|
32
|
-
from autobyteus.cli.workflow_tui.app import WorkflowApp
|
|
33
|
-
except ImportError as e:
|
|
34
|
-
print(f"Error importing autobyteus components: {e}", file=sys.stderr)
|
|
35
|
-
sys.exit(1)
|
|
36
|
-
|
|
37
|
-
# --- Logging Setup ---
|
|
38
|
-
# It's crucial to log to a file so that stdout/stderr are free for Textual.
|
|
39
|
-
def setup_file_logging() -> Path:
|
|
40
|
-
"""
|
|
41
|
-
Sets up file-based logging and returns the path to the log file.
|
|
42
|
-
"""
|
|
43
|
-
log_dir = PACKAGE_ROOT / "logs"
|
|
44
|
-
log_dir.mkdir(exist_ok=True)
|
|
45
|
-
log_file_path = log_dir / "workflow_tui_app.log"
|
|
46
|
-
|
|
47
|
-
logging.basicConfig(
|
|
48
|
-
level=logging.INFO,
|
|
49
|
-
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
50
|
-
filename=log_file_path,
|
|
51
|
-
filemode="w",
|
|
52
|
-
)
|
|
53
|
-
# Silence the noisy asyncio logger in the file log
|
|
54
|
-
logging.getLogger("asyncio").setLevel(logging.WARNING)
|
|
55
|
-
logging.getLogger("textual").setLevel(logging.WARNING)
|
|
56
|
-
|
|
57
|
-
return log_file_path
|
|
58
|
-
|
|
59
|
-
def create_demo_workflow(model_name: str):
|
|
60
|
-
"""Creates a simple two-agent workflow for the TUI demonstration."""
|
|
61
|
-
# The factory will handle API key checks based on the selected model's provider.
|
|
62
|
-
|
|
63
|
-
# Validate model
|
|
64
|
-
try:
|
|
65
|
-
_ = LLMModel[model_name]
|
|
66
|
-
except KeyError:
|
|
67
|
-
logging.critical(f"LLM Model '{model_name}' is not valid. Use --help-models to see available models.")
|
|
68
|
-
print(f"\nCRITICAL ERROR: LLM Model '{model_name}' is not valid. Use --help-models to see available models.\nCheck log file for details.")
|
|
69
|
-
sys.exit(1)
|
|
70
|
-
|
|
71
|
-
# Coordinator Agent Config - Gets its own LLM instance
|
|
72
|
-
coordinator_config = AgentConfig(
|
|
73
|
-
name="Coordinator",
|
|
74
|
-
role="Project Manager",
|
|
75
|
-
description="Delegates tasks to the team to fulfill the user's request.",
|
|
76
|
-
llm_instance=default_llm_factory.create_llm(model_identifier=model_name),
|
|
77
|
-
system_prompt=(
|
|
78
|
-
"You are a project manager. Your job is to understand the user's request and delegate tasks to your team. "
|
|
79
|
-
"The workflow will provide you with a team manifest. Use your tools to communicate with your team.\n\n"
|
|
80
|
-
"Here are your available tools:\n"
|
|
81
|
-
"{{tools}}"
|
|
82
|
-
)
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
# Specialist Agent Config (FactChecker) - Gets its own LLM instance
|
|
86
|
-
fact_checker_config = AgentConfig(
|
|
87
|
-
name="FactChecker",
|
|
88
|
-
role="Specialist",
|
|
89
|
-
description="An agent with a limited, internal knowledge base for answering direct factual questions.",
|
|
90
|
-
llm_instance=default_llm_factory.create_llm(model_identifier=model_name),
|
|
91
|
-
system_prompt=(
|
|
92
|
-
"You are a fact-checking bot. You have the following knowledge:\n"
|
|
93
|
-
"- The capital of France is Paris.\n"
|
|
94
|
-
"- The tallest mountain on Earth is Mount Everest.\n"
|
|
95
|
-
"If asked something you don't know, say 'I do not have information on that topic.'\n\n"
|
|
96
|
-
"Here is the manifest of tools available to you:\n"
|
|
97
|
-
"{{tools}}"
|
|
98
|
-
)
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
# Build the workflow
|
|
102
|
-
workflow = (
|
|
103
|
-
WorkflowBuilder(
|
|
104
|
-
name="TUIDemoWorkflow",
|
|
105
|
-
description="A simple two-agent workflow for demonstrating the TUI."
|
|
106
|
-
)
|
|
107
|
-
.set_coordinator(coordinator_config)
|
|
108
|
-
.add_agent_node(fact_checker_config, dependencies=[])
|
|
109
|
-
.build()
|
|
110
|
-
)
|
|
111
|
-
return workflow
|
|
112
|
-
|
|
113
|
-
async def main(args: argparse.Namespace, log_file: Path):
|
|
114
|
-
"""Main async function to create the workflow and run the TUI app."""
|
|
115
|
-
print("Setting up workflow...")
|
|
116
|
-
print(f"--> Logs will be written to: {log_file.resolve()}")
|
|
117
|
-
try:
|
|
118
|
-
workflow = create_demo_workflow(model_name=args.llm_model)
|
|
119
|
-
app = WorkflowApp(workflow=workflow)
|
|
120
|
-
await app.run_async()
|
|
121
|
-
except Exception as e:
|
|
122
|
-
logging.critical(f"Failed to create or run workflow TUI: {e}", exc_info=True)
|
|
123
|
-
print(f"\nCRITICAL ERROR: {e}\nCheck log file for details: {log_file.resolve()}")
|
|
124
|
-
|
|
125
|
-
if __name__ == "__main__":
|
|
126
|
-
parser = argparse.ArgumentParser(description="Run an AgenticWorkflow with a Textual TUI.")
|
|
127
|
-
parser.add_argument("--llm-model", type=str, default="kimi-latest", help="The LLM model to use for the agents.")
|
|
128
|
-
parser.add_argument("--help-models", action="store_true", help="Display available LLM models and exit.")
|
|
129
|
-
|
|
130
|
-
if "--help-models" in sys.argv:
|
|
131
|
-
try:
|
|
132
|
-
LLMFactory.ensure_initialized()
|
|
133
|
-
print("Available LLM Models (you can use either name or value with --llm-model):")
|
|
134
|
-
all_models = sorted(list(LLMModel), key=lambda m: m.name)
|
|
135
|
-
if not all_models:
|
|
136
|
-
print(" No models found.")
|
|
137
|
-
for model in all_models:
|
|
138
|
-
print(f" - Name: {model.name:<35} Value: {model.value}")
|
|
139
|
-
except Exception as e:
|
|
140
|
-
print(f"Error listing models: {e}")
|
|
141
|
-
sys.exit(0)
|
|
142
|
-
|
|
143
|
-
parsed_args = parser.parse_args()
|
|
144
|
-
|
|
145
|
-
log_file_path = setup_file_logging()
|
|
146
|
-
try:
|
|
147
|
-
asyncio.run(main(parsed_args, log_file_path))
|
|
148
|
-
except KeyboardInterrupt:
|
|
149
|
-
print("\nExiting application.")
|
|
150
|
-
except Exception as e:
|
|
151
|
-
# This catches errors during asyncio.run, which might not be logged otherwise
|
|
152
|
-
logging.critical(f"Top-level application error: {e}", exc_info=True)
|
|
153
|
-
print(f"\nUNHANDLED ERROR: {e}\nCheck log file for details: {log_file_path.resolve()}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|