joaomdmoura / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
17.06k stars 2.32k forks source link

Dependency on OpenAI / Hello World #256

Open jjsarf opened 4 months ago

jjsarf commented 4 months ago

Can we remove dependency on OpenAI by default?

from langchain.tools import tool
from openai import OpenAI
from crewai import Agent, Crew, Task, Process

# Assuming the "Hello World" tool is defined as before
@tool
def hello_world_tool() -> str:
    """A simple tool that returns 'Hello World'"""
    return "Hello World"

# Create an Agent with the "Hello World" Tool
greeter_agent = Agent(
    role='Greeter',
    goal='To greet the world',
    backstory='An AI programmed to spread positivity by greeting everyone.',
    tools=[hello_world_tool],
    verbose=True
)

# Define a Task for the Crew (even if it's a simple demonstration)
greeting_task = Task(
    description='Use the "Hello World" tool to greet.',
    agent=greeter_agent,
)

# Create a Crew with the Greeter Agent and the Greeting Task
crew = Crew(
    agents=[greeter_agent],
    tasks=[greeting_task],
    process=Process.sequential,  # Using a sequential process for task execution
    verbose=True
)

# Kick off the Crew's Work
# This is the code you would execute in a suitable environment:
result = crew.kickoff()
print(result)

Traceback (most recent call last): File "/home/ivica/crewai/ivo/helloworld.py", line 12, in greeter_agent = Agent( ^^^^^^ File "/home/ivica/miniconda3/envs/m2/lib/python3.11/site-packages/pydantic/main.py", line 171, in init self.__pydantic_validator.validate_python(data, self_instance=self) File "/home/ivica/miniconda3/envs/m2/lib/python3.11/site-packages/crewai/agent.py", line 97, in default_factory=lambda: ChatOpenAI( ^^^^^^^^^^^ File "/home/ivica/miniconda3/envs/m2/lib/python3.11/site-packages/langchain_core/load/serializable.py", line 107, in init super().init(**kwargs) File "/home/ivica/miniconda3/envs/m2/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in init raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for ChatOpenAI root__ Did not find openai_api_key, please add an environment variable OPENAI_API_KEY which contains it, or pass openai_api_key as a named parameter. (type=value_error)

rounakskm commented 4 months ago

Easiest workaround I found was to just add a dummy OPENAI_API_KEY=DUMMY_KEY in the .env file

ciaotesla commented 4 months ago

I encounter this issue too. I set the env with a dummy OpenAI key. Getting this error, do I just ignore it like a warning?

It seems we encountered an unexpected error while trying to use the tool. This was the error: Error code: 401 - {'error': {'message': 'Incorrect API key provided: DUMMY_KEY. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

jjsarf commented 4 months ago

So the idea is can we have tasks/tools/agent that do not depend on any Gen AI LLM by default?

jjsarf commented 2 months ago

Not sure. The point is to be able to have a mix of AI and non AI agents

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Tony Kipkemboi @.> Sent: Saturday, April 27, 2024 12:02:44 AM To: joaomdmoura/crewAI @.> Cc: John Jerkovic @.>; Author @.> Subject: Re: [joaomdmoura/crewAI] Dependency on OpenAI / Hello World (Issue #256)

Has anyone found a good solution for this yet? Setting the dummy key doesn't work, FYI.

— Reply to this email directly, view it on GitHubhttps://github.com/joaomdmoura/crewAI/issues/256#issuecomment-2080349854, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIFQXAVWB3MD5RZ3EB6WFW3Y7MPOJAVCNFSM6AAAAABDONPQUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBQGM2DSOBVGQ. You are receiving this because you authored the thread.Message ID: @.***>