From bbb01b194e51ec34c27192687c02301686870ca0 Mon Sep 17 00:00:00 2001 From: Humza Sami Date: Thu, 24 Jul 2025 12:31:35 +0500 Subject: [PATCH] Refactor: Rename functions in builder, expander, manager, and structurer --- primisai/nexus/architect/builder.py | 2 +- primisai/nexus/architect/expander.py | 2 +- primisai/nexus/architect/manager.py | 9 ++++----- primisai/nexus/architect/structurer.py | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/primisai/nexus/architect/builder.py b/primisai/nexus/architect/builder.py index 382e5e4..42769c4 100644 --- a/primisai/nexus/architect/builder.py +++ b/primisai/nexus/architect/builder.py @@ -319,7 +319,7 @@ def _update_system_messages(self, agent_messages: Dict[str, str]): if agent.name in agent_messages: agent.system_message = agent_messages[agent.name] - def build_and_validate(self) -> Supervisor: + def build_component_and_validate(self) -> Supervisor: """Build and validate all components, then assemble the workflow""" # 1. Build and validate main supervisor main_sup_builder = SupervisorBuilder(self.definition.main_supervisor, self.llm_config) diff --git a/primisai/nexus/architect/expander.py b/primisai/nexus/architect/expander.py index 20776ca..16b084c 100644 --- a/primisai/nexus/architect/expander.py +++ b/primisai/nexus/architect/expander.py @@ -36,7 +36,7 @@ def __init__(self, llm_config: Dict[str, str]): """ self.ai = AI(llm_config) - def expand_workflow_query(self, user_query: str, nexus_guidelines: str) -> str: + def decompose_and_plan_tasks(self, user_query: str, nexus_guidelines: str) -> str: """ Expand a high-level workflow query into detailed component pseudocode. diff --git a/primisai/nexus/architect/manager.py b/primisai/nexus/architect/manager.py index 7911b91..8ef5501 100644 --- a/primisai/nexus/architect/manager.py +++ b/primisai/nexus/architect/manager.py @@ -110,7 +110,7 @@ def _create_supervisor_instance(self, workflow_id: str, unique_suffix: int): """Factory function to create a supervisor instance for evaluation.""" run_id = f"{workflow_id}_{unique_suffix}" builder = WorkflowBuilder(self.system_messages, self.structured_workflow, self.llm_config, run_id) - return builder.build_and_validate() + return builder.build_component_and_validate() def _save_workflow_to_file(self, accuracy: float, iteration: int) -> str: """Builds the workflow with current system messages and saves it to a file.""" @@ -119,7 +119,7 @@ def _save_workflow_to_file(self, accuracy: float, iteration: int) -> str: output_path = os.path.join(self.output_dir, filename) builder = WorkflowBuilder(self.system_messages, self.structured_workflow, self.llm_config, self.workflow_id) - builder.build_and_validate() + builder.build_component_and_validate() builder.save_workflow_to_file(output_path) logger.info(f"Workflow saved to: {output_path}") return output_path @@ -133,8 +133,8 @@ def build_and_optimize(self) -> Dict[str, Any]: final accuracy, path to the saved file, and performance history. """ logger.info("Step 1: Designing initial workflow from user query...") - expanded_workflow = self.expander.expand_workflow_query(self.user_query, prompts.nexus_guidelines) - self.structured_workflow = self.structurer.structure_workflow(expanded_workflow) + expanded_workflow = self.expander.decompose_and_plan_tasks(self.user_query, prompts.nexus_guidelines) + self.structured_workflow = self.structurer.reasoning_workflow_design(expanded_workflow) agents_names = [self.structured_workflow.main_supervisor.name] + [agent.name for agent in self.structured_workflow.agents] logger.info(f"Created agents: {', '.join(agents_names)}") @@ -156,7 +156,6 @@ def build_and_optimize(self) -> Dict[str, Any]: self.workflow_id, iteration=i, is_factory=True) - accuracy = evaluation_results['accuracy'] final_accuracy = accuracy diff --git a/primisai/nexus/architect/structurer.py b/primisai/nexus/architect/structurer.py index 9027f0f..0edfc84 100644 --- a/primisai/nexus/architect/structurer.py +++ b/primisai/nexus/architect/structurer.py @@ -45,7 +45,7 @@ def __init__(self, llm_config: Dict[str, str]): with open(doc_path, "r", encoding="utf-8") as file: self.nexus_documentation = file.read() - def structure_workflow(self, expanded_workflow: str) -> WorkflowDefinition: + def reasoning_workflow_design(self, expanded_workflow: str) -> WorkflowDefinition: """ Convert expanded workflow description into structured component definitions.