autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[Bug]: Local Models try to connect to OpenAi

Open CHesketh76 opened this issue 1 year ago • 22 comments

Describe the bug

After setting up Agents and workflow with local endpoints. Getting this error message openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable when running in PlayGround. AutoGen_BUG_01

Steps to reproduce

  1. Install then run Ollama with mistral model Mistral
  2. Install then run litellm and upgrade gunicorn
  3. Endpoint for litellm will be http://0.0.0.0:8000/
  4. Create New agent named mistral and base url to be http://0.0.0.0:8000/ give it any system prompt, then save
  5. Create New Workflow, change the model's base urls to http://0.0.0.0:8000/ for both the Sender and Receiver in the Workflow. Then Save
  6. Go to Playground, create new chat with newly create workflow. Say hi, then error message will appear in app and console screen will display full error log

Expected Behavior

When I try hello there I expect a response, not an error message from the application. AutoGen_BUG_03

Screenshots and logs

Traceback (most recent call last): File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogenstudio/web/app.py", line 68, in add_message response_message: Message = chatmanager.chat( ^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogenstudio/chatmanager.py", line 22, in chat flow = AutoGenWorkFlowManager(config=flow_config, history=history, work_dir=scratch_dir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 35, in init self.sender = self.load(config.sender) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 156, in load agent = self.load_agent_config(agent_spec.config, agent_spec.type) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogenstudio/workflowmanager.py", line 175, in load_agent_config agent = autogen.UserProxyAgent(**agent_config.dict()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogen/agentchat/user_proxy_agent.py", line 83, in init super().init( File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 126, in init self.client = OpenAIWrapper(**self.llm_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/autogen/oai/client.py", line 105, in init self._clients = [self._client(extra_kwargs, openai_config)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3. 11.6/lib/python3.11/site-packages/autogen/oai/client.py", line 162, in _client client = OpenAI(**openai_config) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bear/.pyenv/versions/3.11.6/lib/python3.11/site-packages/openai/_client.py", line 97, in init raise OpenAIError( openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

AutoGen_BUG_02

Additional Information

AutoGen Version: autogenstudio-0.0.25a0 Operating System: Windows and Linux Python Version: 3.11

CHesketh76 avatar Jan 15 '24 18:01 CHesketh76