microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
34.96k stars 5.06k forks source link

[Bug]: TypeError: 'NoneType' object is not iterable #3547

Open Jocatins opened 2 months ago

Jocatins commented 2 months ago

Describe the bug

I have been having challenges with Autogen framework for quite sometime now, I have followed YouTube tutorials, Autogen documentations, done the necessary installations and still get the same error _TypeError: 'NoneType' object is not iterable_. this is my codes I used, the app builds a folder named "coding", afterwhich the application breaks and then this error pops up.

image

Steps to reproduce

These are my codes

import os import autogen from autogen import AssistantAgent, UserProxyAgent

os.environ["OPENAI_API_KEY"] = "dummy_key"

llm_config_local = {"config_list" : [{ "model": "gemma-2-2b-it-GGUF/gemma-2-2b-it-Q4_K_M.gguf", "base_url": "http://localhost:1234/v1/completions", "api_key": None, "price": [0, 0] }]}

assistant = AssistantAgent("assistant", llm_config=llm_config_local)

user_proxy = UserProxyAgent( "user_proxy", code_execution_config={"executor": autogen.coding.LocalCommandLineCodeExecutor(work_dir="coding")} )

Start the chat

user_proxy.initiate_chat( assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.", )

Model Used

LM server

"model": "gemma-2-2b-it-GGUF/gemma-2-2b-it-Q4_K_M.gguf",

Expected Behavior

bug error -

user_proxy.initiate_chat( File "C:\autogen-ai\myenv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 1102, in initiate_chat self.send(msg2send, recipient, silent=silent) File "C:\autogen-ai\myenv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 738, in send recipient.receive(message, self, request_reply, silent) File "C:\autogen-ai\myenv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 902, in receive
reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\autogen-ai\myenv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 2056, in generate_reply final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\autogen-ai\myenv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 1424, in generate_oai_reply extracted_response = self._generate_oai_reply_from_client( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\autogen-ai\myenv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 1446, in _generate_oai_reply_from_client extracted_response = llm_client.extract_text_or_completion_object(response)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\autogen-ai\myenv\Lib\site-packages\autogen\oai\client.py", line 1057, in extract_text_or_completion_object return response.message_retrieval_function(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\autogen-ai\myenv\Lib\site-packages\autogen\oai\client.py", line 197, in message_retrieval return [ # type: ignore [return-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not iterable

Screenshots and logs

Screenshot 2024-09-19 143401

Additional Information

No response

ekzhu commented 1 month ago

Are you using local models? Can you follow documentation for LiteLLM + Ollama? https://microsoft.github.io/autogen/0.2/docs/topics/non-openai-models/local-ollama