mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-06 13:52:44 +02:00
Remove legacy swarm_wrapper code
This commit is contained in:
parent
6d47adafb3
commit
817f7893a2
1 changed files with 0 additions and 74 deletions
|
|
@ -281,80 +281,6 @@ def get_agents(agent_configs, tool_configs, complete_request):
|
||||||
print("="*100)
|
print("="*100)
|
||||||
return new_agents
|
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(
|
async def run_streamed(
|
||||||
agent,
|
agent,
|
||||||
messages,
|
messages,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue