From 817f7893a2cd4641468ffa737323d40bf68927c6 Mon Sep 17 00:00:00 2001 From: akhisud3195 Date: Fri, 2 May 2025 17:26:05 +0530 Subject: [PATCH] Remove legacy swarm_wrapper code --- .../rowboat_agents/src/graph/swarm_wrapper.py | 74 ------------------- 1 file changed, 74 deletions(-) diff --git a/apps/rowboat_agents/src/graph/swarm_wrapper.py b/apps/rowboat_agents/src/graph/swarm_wrapper.py index e3c9859e..d632a395 100644 --- a/apps/rowboat_agents/src/graph/swarm_wrapper.py +++ b/apps/rowboat_agents/src/graph/swarm_wrapper.py @@ -281,80 +281,6 @@ def get_agents(agent_configs, tool_configs, complete_request): print("="*100) return new_agents - -def create_response(messages=None, tokens_used=None, agent=None, error_msg=''): - """ - Create a Response object with the given parameters. - - Args: - messages: List of messages - tokens_used: Dictionary tracking token usage - agent: The agent that generated the response - error_msg: Error message if any - - Returns: - Response object - """ - if messages is None: - messages = [] - if tokens_used is None: - tokens_used = {} - - return NewResponse( - messages=messages, - agent=agent, - tokens_used=tokens_used, - error_msg=error_msg - ) - - -async def run( - agent, - messages, - external_tools=None, - tokens_used=None -): - """ - Wrapper function for initializing and running the Swarm client. - """ - logger.info(f"Initializing Swarm client for agent: {agent.name}") - print(f"Initializing Swarm client for agent: {agent.name}") - - # Initialize default parameters - if external_tools is None: - external_tools = [] - if tokens_used is None: - tokens_used = {} - - # Format messages to ensure they're compatible with the OpenAI API - formatted_messages = [] - for msg in messages: - if isinstance(msg, dict) and "content" in msg: - formatted_msg = { - "role": msg.get("role", "user"), - "content": msg["content"] - } - formatted_messages.append(formatted_msg) - else: - formatted_messages.append({ - "role": "user", - "content": str(msg) - }) - - logger.info("Beginning Swarm run") - print("Beginning Swarm run") - - try: - response = await Runner.run(agent, formatted_messages) - except Exception as e: - logger.error(f"Error during run: {str(e)}") - print(f"Error during run: {str(e)}") - raise - - logger.info(f"Completed Swarm run for agent: {agent.name}") - print(f"Completed Swarm run for agent: {agent.name}") - return response - async def run_streamed( agent, messages,