Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with Code: Requesting Human Input #4786

Open
tayloreeves opened this issue Dec 23, 2024 · 0 comments
Open

Errors with Code: Requesting Human Input #4786

tayloreeves opened this issue Dec 23, 2024 · 0 comments

Comments

@tayloreeves
Copy link

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!

@tayloreeves tayloreeves changed the title Errors with Code Errors with Code: Requesting Human Input Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant