autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[Bug]: Autogen Studio | Windows 11 | init error with Azure OpenAI key

Open sayanghosh123 opened this issue 2 years ago • 4 comments

Describe the bug

I am trying to get the Autogen Studio working on my machine. I've followed the instructions in this video / blog and am working with a venv.

https://microsoft.github.io/autogen/blog/2023/12/01/AutoGenStudio/ https://www.youtube.com/watch?v=OMa9_xuFG0s

I've set the env variable AZURE_OPENAI_API_KEY using set AZURE_OPENAI_API_KEY=****************, but the app seems to be simply default expecting the OpenAI key. The stacktrace is under "Screenshots and logs".

I am almost sure I've missed out something but I couldn't make it out from the doc. If there are any pointers, would be much appreciated.

Steps to reproduce

Please see above - it is the main flow of Autogen Studio.

Expected Behavior

No response

Screenshots and logs

Traceback (most recent call last): File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogenstudio\web\app.py", line 68, in add_message response_message: Message = chatmanager.chat( ^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogenstudio\chatmanager.py", line 23, in chat flow = AutoGenWorkFlowManager(config=flow_config, history=history, work_dir=scratch_dir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogenstudio\workflowmanager.py", line 31, in init self.receiver = self.load(config.receiver) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogenstudio\workflowmanager.py", line 138, in load agent = autogen.AssistantAgent(**asdict(agent_spec.config)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogen\agentchat\assistant_agent.py", line 57, in init super().init( File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 117, in init self.client = OpenAIWrapper(**self.llm_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogen\oai\client.py", line 77, in init self._clients = [self._client(config, openai_config) for config in config_list] # could modify the config ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogen\oai\client.py", line 77, in self._clients = [self._client(config, openai_config) for config in config_list] # could modify the config ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\autogen\oai\client.py", line 138, in _client client = OpenAI(**openai_config) ^^^^^^^^^^^^^^^^^^^^^^^ File "<user_directory>\autogen-studio\ag-venv\Lib\site-packages\openai_client.py", line 92, 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

Additional Information

AutoGen Version: 0.2.0 AutoGen Studio Version: 0.0.18a0 Operating System: Windows 11 Enterprise Insider Preview Version 22H2 OS build 23606.1000 Windows Feature Experience Pack 1000.23606.1000.0 Python Version: Python 3.11.3 Related Issues: Any other relevant information.

sayanghosh123 avatar Jan 03 '24 06:01 sayanghosh123

@victordibia

rickyloynd-microsoft avatar Jan 03 '24 15:01 rickyloynd-microsoft

@sayanghosh123 ,

Thanks for the note. In general, autogen studio will attempt to fetch and use OPENAI_API_KEY if a key is not specified in the llm_config. For azure openai, we can specify the key and other details in the UI.

  • Go to build ..
  • Select a workflow .. scroll to the model section ...
  • Select a model to edit it or select add to add a new model

Image

  • Modify model details .. add key, url, version , type (type should be azure)

Image

Image

Once you have configured the workflow .. you should be able to use it in the playground (select the updated workflow from the agent workflow dropdown)

victordibia avatar Jan 03 '24 22:01 victordibia

Thanks for the help @victordibia - sincerely appreciated.

I've managed to solve it with the following -

Model name - From Azure AI Studio Deployment Name OR, Open in Playground > View Code > value of engine Key - from Azure portal Endpoint - from Azure portal Type - "azure" Version - From Azure AI Studio, Open in Playground > View Code > openai.api_version = "2023-07-01-preview"

All 5 are required. I had to set them on both Sender and Receiver to get it working.

UX Suggestion - could we decouple the model definition from workflow, so we can reuse the model, similar to how PromptFlow handles connections.

sayanghosh123 avatar Jan 04 '24 01:01 sayanghosh123

@sayanghosh123 ,

FYI , models have been added and can be reused. Added models can also be tested.

You can update autogenstudio to test out this feature.

  • pip uninstall autogenstudio
  • pip install -U autogenstudio
  • autogenstudio ui --appdir newdir

the last command tells autogenstudio to use newdir to store files including creating a new db.

https://github.com/microsoft/autogen/assets/1547007/54bf4cb7-67c3-475b-b52c-3f640dcc2de5

victordibia avatar Feb 04 '24 04:02 victordibia