![]() |
https://www.pexels.com/photo/a-woman-in-black-top-pointing-finger-6153752/ |
In AutoGen 0.4.x, there are different strategies to orchestrate agents to complex a task. Among them, we have the RoundRobinGroupChat (a very simple blog on it) and Swarm (yet another blog about it). In this blog, we have the SelectorGroupChat. Using the same use case.
"sum of my saving and investment account balances."
The code is available here. Here are the dependencies (can be found in repo too).
Most of the logic is in the main.py.
A customer facing agent, collecting request and delegating the tasks to other agents.
Then we have a bunch of agents armed with tools. And thisWe define the terminating criteria. Create the selector prompt template to collect the message history.
Then we have the Selector Group Chat. We also dumped out the token usages at the end.
Here is the output
---------- user ---------- Get the account ID and then get the saving balance and investment balance. Both saving and investment account have the same account ID. Sum the balances when they are available. ---------- account_agent ---------- [FunctionCall(id='call_7fzGQiXbffzUcOuXeRT0PuxM', arguments='{}', name='get_bank_account_id')] ---------- account_agent ---------- [FunctionExecutionResult(content='123', name='get_bank_account_id', call_id='call_7fzGQiXbffzUcOuXeRT0PuxM', is_error=False)] ---------- account_agent ---------- 123 ---------- saving_account_agent ---------- [FunctionCall(id='call_8rjfBFTiCKc8REDllj3sYvnZ', arguments='{"bank_account_id": "123"}', name='get_saving_account_balance')] ---------- saving_account_agent ---------- [FunctionExecutionResult(content='10000.1', name='get_saving_account_balance', call_id='call_8rjfBFTiCKc8REDllj3sYvnZ', is_error=False)] ---------- saving_account_agent ---------- 10000.1 ---------- investment_agent ---------- [FunctionCall(id='call_pkbYmcccFcCdXlFKTTSAh5w8', arguments='{"bank_account_id":"123"}', name='get_investment_account_balance')] ---------- investment_agent ---------- [FunctionExecutionResult(content='100000.1', name='get_investment_account_balance', call_id='call_pkbYmcccFcCdXlFKTTSAh5w8', is_error=False)] ---------- investment_agent ---------- 100000.1 ---------- customer_agent ---------- account_agent : Provide the account ID. saving_account_agent : Provide saving account balance for the given account ID. investment_agent : Provide investment account balance for the given account ID. ```json { "account_id": "123", "saving_balance": 10000.1, "investment_balance": 100000.1, "total_balance": 110000.2 }``` TERMINATE account_agent: RequestUsage(prompt_tokens=98, completion_tokens=12) saving_account_agent: RequestUsage(prompt_tokens=176, completion_tokens=35) investment_agent: RequestUsage(prompt_tokens=191, completion_tokens=20) customer_agent: RequestUsage(prompt_tokens=234, completion_tokens=86)
The JSON is right and the token usages look right.
Comments
Post a Comment