crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG]litellmGemini API not working ?

Open ANPCI opened this issue 1 year ago • 1 comments

Description

Crewai generating error when using Gemini pro api, while it's working fine with other openai models.

Steps to Reproduce

add the script to test.py and run it with poetry run python test.py

Expected behavior

it should access gemini api to generate content

Screenshots/Code snippets

import os from langchain_google_genai import ChatGoogleGenerativeAI from crewai import Agent, Task, Crew, Process

if name == "main":

# Set gemini pro as llm
llm = ChatGoogleGenerativeAI(
    model="gemini-pro", verbose=True, temperature=0.9, google_api_key="AIzaSyAfGxWFWyKQk5fzSBKQS4y95JB0Wv_OvYE"
)

# Create agents
screenwriter = Agent(
    role="Screenwriter",
    goal="Translate ideas into engaging scenes with vivid descriptions, snappy dialogue, and emotional depth.",
    backstory="""Former freelance screenwriter for low-budget indie films. Learned to work quickly under constraints, 
                generating multiple variations on a theme. Excels at building tension and incorporating plot twists.""",
    verbose=True,
    allow_delegation=False,
    llm=llm,
)

critic = Agent(
    role="Analytical Eye & Genre Enforcer",
    goal="Ensure stories are internally consistent, adhere to the intended genre, and maintain stylistic choices.",
    backstory="""A retired film studies professor with an encyclopedic knowledge of classic tropes, storytelling structures, 
                and audience expectations. Has a knack for spotting potential plot holes and continuity errors.""",
    verbose=True,
    allow_delegation=False,
    llm=llm,
)

story_master = Agent(
    role="Project Lead & Master Orchestrator",
    goal="Guide the overall story generation process, manage the workflow between the Screenwriter and Critic, and ensure a cohesive final product.",
    backstory="""A seasoned novelist turned game narrative designer. Has a strong understanding of both high-level plot frameworks and the detailed 
                scene creation required to immerse a reader in the world.""",
    verbose=True,
    allow_delegation=True,
    llm=llm,
)

# Get the story idea from the user
user_input = input(
    "Please provide a short story idea. You can specify the genre and theme: "
)

# Create the task
story_task = Task(
    description=f"Write a short story with the following user input: {user_input}",
    agent=story_master,
)

# Create the crew
story_crew = Crew(
    agents=[screenwriter, critic, story_master],
    tasks=[story_task],
    verbose=True,
    process=Process.sequential,
)

# Execution Flow
story_output = story_crew.kickoff()

Operating System

macOS Sonoma

Python Version

3.10

crewAI Version

0.63.6

crewAI Tools Version

0.12.1

Virtual Environment

Poetry

Evidence

Error Message in terminal :

Provider List: https://docs.litellm.ai/docs/providers

2024-10-03 16:03:06,390 - 8480485952 - llm.py-llm:104 - ERROR: Failed to get supported params: argument of type 'NoneType' is not iterable

Possible Solution

None

Additional context

Tried running the script multiple times, same issue

ANPCI avatar Oct 03 '24 20:10 ANPCI

Hi

Can you try this?

from crewai import Agent, LLM, Task, Crew, Process
llm = LLM(
model="gemini/gemini-pro", temperature=0.9,
api_key=API_KEY,
)

For reference you can also check this screenshot image

And the rest of your code: image

punitchauhan771 avatar Oct 04 '24 18:10 punitchauhan771

I also cannot use Gemini with VertexAI in a crew, but it works using the LiteLLM

httplups avatar Oct 07 '24 18:10 httplups

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 07 '24 12:11 github-actions[bot]

any updates?

httplups avatar Nov 07 '24 12:11 httplups

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Dec 09 '24 12:12 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Dec 15 '24 12:12 github-actions[bot]

any update?

anmol52490 avatar Feb 26 '25 12:02 anmol52490