Description
What happened?
While running the script autogen_code_reviewer.py that utilizes the autogen library, the following error occurred:
ImportError: Please install google-generativeai
and 'vertexai' to use Google's API.
This error persists even after installing both google-generativeai and vertexai in the virtual environment. I verified both libraries using the pip show command. Also, the script was activated in a fresh virtual environment with all packages installed. The same code was running 2 days back, but suddenly throwing the above error.
What did you expect to happen?
The script should have executed without throwing the ImportError, as the necessary dependencies (google-generativeai and vertexai) were installed successfully. Specifically:
- The AssistantAgent initialization should proceed without issues.
- The script should begin generating and reviewing code as expected.
How can we reproduce it (as minimally and precisely as possible)?
-
Activate the virtual environment.
-
Install the necessary dependencies:
pip install pyautogen google-generativeai vertexai autogen-agentchat~=0.2 -
Run the following script:
import autogen
from autogen import AssistantAgent, UserProxyAgent
config_list = [
{
"model": "gemini-1.5-pro-002",
"api_type": "google",
"project_id": "my_project_id",
"location": "my_location"
}
]
code_generator = AssistantAgent(
name="code_generator",
llm_config={
"config_list": config_list,
"seed": 42,
"temperature": 0.7
},
system_message="""You are an expert code generator. Generate clean and well-documented code based on the requirements provided.""",
max_consecutive_auto_reply=2
)
Note: I authenticated with GCP using :gcloud auth application-default login, to use the Gemini model
AutoGen version
pyautogen version : 0.7.1
Which package was this bug in
Core
Model used
gemini-1.5-pro-002
Python version
3.12.5
Operating system
Windows 11
Any additional info you think would be helpful for fixing this bug
No response