[Bug]: When i use multi-agent to solve problems,therr is the error:"AttributeError: 'NoneType' object has no attribute 'prompt_tokens' "
Describe the bug
`
llm_config = { "cache_seed": 42, # change the cache_seed for different trials "temperature": 0, "config_list": config_list, "timeout": 120, "functions":[ { "name": "get_account_id", "description": "retrieves the account id for a user given their name", "parameters": { "type": "object", "properties": { "name":{ "type": "string", "description": "The name of the customer that will be used to lookup the account id" } }, "required": ["name"] } }, { "name": "get_last_bill_amount", "description": "Retrieves the last bill amount for a user for a given account id.", "parameters": { "type": "object", "properties": { "account_id":{ "type": "string", "description": "The account id fetched from get_account_id that will be used to lookup the last bill for the customer" } }, "required": ["account_id"] } } ] }
nofunction_llm_config = { "cache_seed": 42, # change the cache_seed for different trials "temperature": 0, "config_list": config_list, "timeout": 120,
}
name_to_account_id = { "Alice": "A123", "Bob": "B456", "Charlie": "C789" }
account_id_to_bill = { "A123": 120.50, "B456": 200.75, "C789": 99.99 }
def get_account_id(name): print("--------------------") print(name_to_account_id.get(name, "Name not found")), return name_to_account_id.get(name, "Name not found")
def get_last_bill_amount(account_id): return account_id_to_bill.get(account_id, "Account ID not found")
user_proxy = autogen.UserProxyAgent( name="user_proxy", system_message="A human user_proxy. 如果你的问题需要执行工具(比如执行函数、请求接口)才能解决,去找task_executor去执行", code_execution_config=False, human_input_mode="TERMINATE", # max_consecutive_auto_reply=3, # is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"), llm_config=nofunction_llm_config,
)
knowledge_responsor = autogen.AssistantAgent( name="knowledge_responsor", system_message=''' 当user_proxy交给你的问题你能解决时,你来负责回复他答案。你的知识如下 { ”tws是一款田所在公司的游戏“ ”tws所在公司还有一个项目叫小智助手“ } ''', human_input_mode="NEVER", max_consecutive_auto_reply=10, llm_config=nofunction_llm_config,
)
task_executor = autogen.AssistantAgent( name="task_executor", llm_config=llm_config,
system_message="""
task_executor. 解决user_proxy发来的执行工具的诉求。
""",
human_input_mode="NEVER",
max_consecutive_auto_reply=10,
)
groupchat = autogen.GroupChat( agents=[user_proxy, knowledge_responsor,task_executor], messages=[], max_round=50, func_call_filter=True,
)
manager = autogen.GroupChatManager( groupchat=groupchat, llm_config=nofunction_llm_config, max_consecutive_auto_reply=20, human_input_mode="NEVER", system_message=""" Group chat manager. 当用户发起问题时,你需要先判断他的意图,根据他的意图决定他的问题交给谁来回复。 如果他的意图需要执行工具(比如执行函数、请求接口)才能解决,你就告诉user_proxy,让他去找task_executor去执行。 如果他的意图是”询问问题,需要对应的知识回复“,你就交给knowledge_responsor让他回复;
如果他的意图knowledge_responsor和task_executor都无法解决,你就返回“对不起,当前我暂无法解决你的问题,你可以尝试转人工”
""",
)
for agent in [user_proxy,knowledge_responsor]: # register functions for all agents. agent.register_function( function_map={ "get_account_id": get_account_id, "get_last_bill_amount": get_last_bill_amount, } )
user_proxy.initiate_chat(manager,message="我是Bob,我的账号余额是多少")
user_proxy.initiate_chat(manager,message="我是Bob,我的账户余额还有多少",clear_history=True,silent=True,) `
Steps to reproduce
here is the error:
Traceback (most recent call last):
File "C:\Users\safa\PycharmProjects\pythonProject1\function_call+rag.py", line 202, in
进程已结束,退出代码1
Expected Behavior
No response
Screenshots and logs
Additional Information
python 3.10.9
This looks like #984.
I think @kevin666aa is working on this.