microsoft / autogen

A programming framework for agentic AI. Discord: https://aka.ms/autogen-dc. Roadmap: https://aka.ms/autogen-roadmap
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
28.64k stars 4.18k forks source link

[Bug]: 'NoneType' object has no attribute 'chat' #2372

Open aavetis opened 3 months ago

aavetis commented 3 months ago

Describe the bug

On a fresh install of Autogen Studio, using one of the pre loaded agents and workflows, provided my own API key (tested and works), and getting this error on any message:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/autogenstudio/web/app.py", line 120, in add_message
    response_message: Message = managers["chat"].chat(
AttributeError: 'NoneType' object has no attribute 'chat'

Steps to reproduce

Model Used

gpt-4, or any local endpoint as well

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

wepromen commented 2 months ago

Me too. Please help!

stollz commented 1 month ago

same happens with v0.1.1. Travel planning workflow Test workflow "Travel" prompt: Plan a 2 day trip to hawaii. Limit to 3 activities per day, be as brief as possible!

console output:

user_proxy (to chat_manager): 2024-06-18 09:24:17.990 | INFO | autogenstudio.web.app:message_handler:38 - Processing Agent Message on Queue: Active Connections: ['c2eb5ab8-4d13-4e8e-8a81-4f918c29c5fc'] 2024-06-18 09:24:17.990 | INFO | autogenstudio.web.app:message_handler:45 - Sending message to connection_id: c2eb5ab8-4d13-4e8e-8a81-4f918c29c5fc. Connection ID: c2eb5ab8-4d13-4e8e-8a81-4f918c29c5fc

TERMINATE


agent type <class 'autogenstudio.workflowmanager.ExtendedConversableAgent'> agent type <class 'autogenstudio.workflowmanager.ExtendedGroupChatManager'> groupchat found, processing 4

File "/Users/I/miniconda3/envs/autogenstudio/lib/python3.11/site-packages/autogenstudio/web/app.py", line 453, in run_session_workflow agent_response: Message = managers["chat"].chat( ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/I/miniconda3/envs/autogenstudio/lib/python3.11/site-packages/autogenstudio/chatmanager.py", line 79, in chat result_message: Message = workflow_manager.run(message=f"{message_text}", clear_history=False, history=history) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/I/miniconda3/envs/autogenstudio/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 397, in run usage = self._get_usage_summary() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/I/miniconda3/envs/autogenstudio/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 373, in _get_usage_summary receiver_usage = self._get_agent_usage(self.receiver) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/I/miniconda3/envs/autogenstudio/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 365, in _get_agent_usage "total_cost": find_key_value(agent_usage, "total_cost"), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/I/miniconda3/envs/autogenstudio/lib/python3.11/site-packages/autogenstudio/utils/utils.py", line 514, in find_key_value for key, value in d.items(): ^^^^^^^ AttributeError: 'NoneType' object has no attribute 'items'

Li-Yanzhi commented 1 month ago

Same issue in AutoGen Studio 0.1.1 too

Next speaker: user_proxy

user_proxy (to chat_manager):
2024-06-18 23:02:00.059 | INFO     | autogenstudio.web.app:message_handler:38 - ** Processing Agent Message on Queue: Active Connections: ['f37daec4-07c7-4c3b-ac63-a25224af0163'] **

2024-06-18 23:02:00.059 | INFO     | autogenstudio.web.app:message_handler:45 - Sending message to connection_id: f37daec4-07c7-4c3b-ac63-a25224af0163. Connection ID: f37daec4-07c7-4c3b-ac63-a25224af0163
TERMINATE

--------------------------------------------------------------------------------
agent type <class 'autogenstudio.workflowmanager.ExtendedConversableAgent'>
Traceback (most recent call last):
  File "d:\Dev\OpenAI-Lab\.conda\Lib\site-packages\autogenstudio\web\app.py", line 453, in run_session_workflow
    agent_response: Message = managers["chat"].chat(
                              ^^^^^^^^^^^^^^^^^^^^^^
  File "d:\Dev\OpenAI-Lab\.conda\Lib\site-packages\autogenstudio\chatmanager.py", line 79, in chat
    result_message: Message = workflow_manager.run(message=f"{message_text}", clear_history=False, history=history)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\Dev\.conda\Lib\site-packages\autogenstudio\workflowmanager.py", line 397, in run
    usage = self._get_usage_summary()
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\Dev\.conda\Lib\site-packages\autogenstudio\workflowmanager.py", line 373, in _get_usage_summary
    receiver_usage = self._get_agent_usage(self.receiver)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\Dev\.conda\Lib\site-packages\autogenstudio\workflowmanager.py", line 353, in _get_agent_usage
    "total_cost": find_key_value(agent_usage, "total_cost"),
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\Dev\.conda\Lib\site-packages\autogenstudio\utils\utils.py", line 514, in find_key_value
    for key, value in d.items():
                      ^^^^^^^
AttributeError: 'NoneType' object has no attribute 'items'
victordibia commented 1 month ago

Thanks @Li-Yanzhi for the bug fix in cost extraction. Pushed an update - v0.1.2

huqianghui commented 1 month ago

v0.1.2 still have the below same type error:

Traceback (most recent call last): File "/opt/homebrew/lib/python3.11/site-packages/autogenstudio/web/app.py", line 453, in run_session_workflow agent_response: Message = managers["chat"].chat( ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/autogenstudio/chatmanager.py", line 79, in chat result_message: Message = workflow_manager.run(message=f"{message_text}", clear_history=False, history=history) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 587, in run self._run_workflow(message=message, history=history, File "/opt/homebrew/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 528, in _run_workflow result = auto_workflow.run( ^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 404, in run output = self._generate_output( ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 345, in _generate_output output = summarize_chat_history( ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/autogenstudio/utils/utils.py", line 470, in summarize_chat_history response = client.create(messages=summarization_prompt, cache_seed=None) ^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'create'

victordibia commented 1 month ago

Thanks for noting this @huqianghui . The error suggests that a model client is not set on the receiver. Will add a check for this to fix. In the meantime, can you try setting summary method to last or none for your workflow or verify that the receiver agent indeed has a model associated with it.

Reference of adding model to an agent here https://youtu.be/v5U4o-ODrng?si=lxOR8liSTU90CnVQ .. 7:15