crewAIInc / 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
18.69k stars 2.58k forks source link

Add support of g4f #367

Closed pencilvania closed 4 days ago

pencilvania commented 5 months ago

Hi Guys

I added gpt4free (import g4f) https://github.com/xtekky/gpt4free and using it , but the problem is when I want using tools like WebsiteSearchTool it seems need to OPENAI_API_KEY when we are using even llm can it be integrated ?

rrfaria commented 5 months ago

looking at documentation I guess you can run it by running a docker container

docker pull hlohaus789/g4f
docker run -p 8080:8080 -p 1337:1337 -p 7900:7900 --shm-size="2g" hlohaus789/g4f:latest

it exposes an api for you

http://localhost:1337/v1

and you can use this api with openAi lib

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    openai_api_base="http://localhost:1337/v1",
    openai_api_key="anything_noneeded",
    model_name="gpt-3.5-turbo"
)

... 
# code of your agents
Agent(
      role='your role',
      goal='your goal.',
      verbose=True,
      backstory="""your backstory""",
      allow_delegation=True,
      llm=llm,
    )

Pass llm to your agents and it will work

github-actions[bot] commented 1 week ago

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] commented 4 days ago

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