![]() |
https://www.pexels.com/photo/back-view-of-a-teen-boy-with-a-digital-background-9783353/ |
In this blog, we looked at Autogen Swarm. We use the same scenario in the previous blog. We used the RoundRobinGroupChat
method to route messages to agent. The ask is
I want the sum of my saving and investment account balances.
The code is in this repo.
Here are the dependencies (can be found in repo too). Note that autogen-agentchat
version need to be greater than 0.4.8
Most of the logic is in the main.py.
We created a Swarm with 3 agents. Here is the output for one of the successful run.
python -m autogen_swarm.main
---------- user ---------- I want the sum of my saving and investment account balances. ---------- banking_teller_agent ---------- [FunctionCall(id='call_fv1vYaHONFFSSwcRHBUj7qlA', arguments='{}', name='transfer_to_saving_account_agent'), FunctionCall(id='call_FSYuMw8WqJzIcoEOjomxhW44', arguments='{}', name='transfer_to_investment_account_agent')] ---------- banking_teller_agent ---------- [FunctionExecutionResult(content='Transferred to saving_account_agent, adopting the role of saving_account_agent immediately.', name='transfer_to_saving_account_agent', call_id='call_fv1vYaHONFFSSwcRHBUj7qlA', is_error=False), FunctionExecutionResult( content="Error: The tool 'transfer_to_investment_account_agent' is not available.", name='transfer_to_investment_account_agent', call_id='call_FSYuMw8WqJzIcoEOjomxhW44', is_error=True)] ---------- banking_teller_agent ---------- Transferred to saving_account_agent, adopting the role of saving_account_agent immediately. ---------- saving_account_agent ---------- [FunctionCall(id='call_NjW0G9dU1pKrp9vr8SApHfyq', arguments='{}', name='get_bank_account_id')] ---------- saving_account_agent ---------- [FunctionExecutionResult(content='789', name='get_bank_account_id', call_id='call_NjW0G9dU1pKrp9vr8SApHfyq', is_error=False)] ---------- saving_account_agent ---------- 789 ---------- saving_account_agent ---------- [FunctionCall(id='call_RdbDIwrFcMFHFicsLx5k96KH', arguments= '{"bank_account_id":"789"}', name='get_saving_account_balance')] ---------- saving_account_agent ---------- [FunctionExecutionResult(content='30000.3', name='get_saving_account_balance', call_id='call_RdbDIwrFcMFHFicsLx5k96KH', is_error=False)] ---------- saving_account_agent ---------- 30000.3 ---------- saving_account_agent ---------- Your saving account balance is $30,000.30. I will now hand you over to the investment account agent for the investment account details. ---------- saving_account_agent ---------- [FunctionCall(id='call_AQ1dHyyFmxATG6jW9YQhgZas', arguments='{}', name='transfer_to_investment_account_agent')] ---------- saving_account_agent ---------- [FunctionExecutionResult(content='Transferred to investment_account_agent, adopting the role of investment_account_agent immediately.', name='transfer_to_investment_account_agent', call_id='call_AQ1dHyyFmxATG6jW9YQhgZas', is_error=False)] ---------- saving_account_agent ---------- Transferred to investment_account_agent, adopting the role of investment_account_agent immediately. ---------- investment_account_agent ---------- [FunctionCall(id='call_FROiMHUbzQNXEB93SMWqd7w2', arguments='{}', name='get_bank_account_id')] ---------- investment_account_agent ---------- [FunctionExecutionResult(content='789', name='get_bank_account_id', call_id='call_FROiMHUbzQNXEB93SMWqd7w2', is_error=False)] ---------- investment_account_agent ---------- 789 ---------- investment_account_agent ---------- [FunctionCall(id='call_qpIhjxHGywIRZj8v3fUJu2Mc', arguments='{"bank_account_id":"789"}', name='get_investment_account_balance')] ---------- investment_account_agent ---------- [FunctionExecutionResult(content='300000.3', name='get_investment_account_balance', call_id= 'call_qpIhjxHGywIRZj8v3fUJu2Mc', is_error=False)] ---------- investment_account_agent ---------- 300000.3 ---------- investment_account_agent ---------- Your investment account balance is $300,000.30. Adding your saving account balance, which is $30,000.30, your total balance is $330,000.60. I will now hand you over to the banking teller. ---------- investment_account_agent ---------- [FunctionCall(id='call_z9y5zGrYrhXjx1ZDTHBvqZ9T', arguments='{}', name='transfer_to_banking_teller_agent')] ---------- investment_account_agent ---------- [FunctionExecutionResult(content='Transferred to banking_teller_agent, adopting the role of banking_teller_agent immediately.', name='transfer_to_banking_teller_agent', call_id='call_z9y5zGrYrhXjx1ZDTHBvqZ9T', is_error=False)] ---------- investment_account_agent ---------- Transferred to banking_teller_agent, adopting the role of banking_teller_agent immediately. ---------- banking_teller_agent ---------- The sum of your saving account balance ($30,000.30) and investment account balance ($300,000.30) is $330,000.60. TERMINATE
In order to get this working consistently, We to work on tweaking the prompts. This works about 80% of the time.
Comments
Post a Comment