You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all,
I am currently trying to set up the Gemini Assistant API with 2 converable agents working together. When I try to run this code, it asks for keyboard input, and then I get the following error when anything is inputted: "Error during agent setup or execution: Missing required arguments; Expected either ('messages' and 'model') or ('messages', 'model' and 'stream') arguments to be given"
Here is my code for reference:
`# Imported Modules
import os
from autogen import AssistantAgent
import google.generativeai as genai
Load API Key from a file
try:
with open("API KEY.txt", "r") as file:
API_KEY = file.read().strip() # Ensure no trailing newlines or spaces
except FileNotFoundError:
raise FileNotFoundError("API KEY.txt file not found. Ensure the file exists in the script's directory.")
Test to ensure API key is valid
try:
genai.configure(api_key=API_KEY)
print("Google Generative AI configured successfully.")
except Exception as e:
raise Exception(f"Failed to configure Google Generative AI: {e}")
AssistantAgent Configuration
try:
Gemini1 = AssistantAgent(
name="Gemini1",
system_message="Always answer questions within one sentence.",
llm_config={"model_name": "gemini-1.5-flash", "api_key": API_KEY, "seed": 25},
max_consecutive_auto_reply=3
)
Gemini2 = AssistantAgent(
name="Gemini2",
system_message="You should ask weird, tricky, and concise questions. "
"Ask the next question based on (by evolving) the previous one.",
llm_config={"model_name": "gemini-1.5-flash", "api_key": API_KEY, "seed": 25},
max_consecutive_auto_reply=4
)
# Simulate Conversation Between Two Agents
initial_message = [
{"role": "system", "content": Gemini1.system_message},
{"role": "user", "content": "Should Spider-Man invest in a 401K?"}
]
# Run the conversation
result = Gemini1.initiate_chat(
Gemini2, # Gemini2 is the target conversational agent
messages=initial_message, # Initial conversation messages
model={"name": "gemini-1.5-flash", "api_key": API_KEY, "seed": 25}, # Explicit model config
max_turns=2, # Define the maximum number of turns
)
print("Agent Conversation Result:", result)
except Exception as e:
print(f"Error during agent setup or execution: {e}")`
If someone could help out, that'd be great!
The text was updated successfully, but these errors were encountered:
Hi all,
I am currently trying to set up the Gemini Assistant API with 2 converable agents working together. When I try to run this code, it asks for keyboard input, and then I get the following error when anything is inputted: "Error during agent setup or execution: Missing required arguments; Expected either ('messages' and 'model') or ('messages', 'model' and 'stream') arguments to be given"
Here is my code for reference:
`# Imported Modules
import os
from autogen import AssistantAgent
import google.generativeai as genai
Load API Key from a file
try:
with open("API KEY.txt", "r") as file:
API_KEY = file.read().strip() # Ensure no trailing newlines or spaces
except FileNotFoundError:
raise FileNotFoundError("API KEY.txt file not found. Ensure the file exists in the script's directory.")
Test to ensure API key is valid
try:
genai.configure(api_key=API_KEY)
print("Google Generative AI configured successfully.")
except Exception as e:
raise Exception(f"Failed to configure Google Generative AI: {e}")
AssistantAgent Configuration
try:
Gemini1 = AssistantAgent(
name="Gemini1",
system_message="Always answer questions within one sentence.",
llm_config={"model_name": "gemini-1.5-flash", "api_key": API_KEY, "seed": 25},
max_consecutive_auto_reply=3
)
except Exception as e:
print(f"Error during agent setup or execution: {e}")`
If someone could help out, that'd be great!
The text was updated successfully, but these errors were encountered: