crewAI
crewAI copied to clipboard
How to use GPT-3.5??
from crewai import Agent, Task, Crew, Process
from langchain.llms import Ollama, openai
from langchain.tools import DuckDuckGoSearchRun
search_tool = DuckDuckGoSearchRun()
ChatOpenAI = openai(model="gpt-3.5")
os.environ["OPENAI_API_KEY"] = "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"
researcher = Agent(
role='Senior Research Analyst',
goal='Uncover cutting-edge developments in AI and data science in',
backstory="""You work at a leading tech think tank.
Your expertise lies in identifying emerging trends.
You have a knack for dissecting complex data and presenting
actionable insights.""",
verbose=True,
allow_delegation=False,
tools=[search_tool],
llm=ChatOpenAI(model_name="gpt-3.5", temperature=0.7)
)
this giving error
python3 main.py
Traceback (most recent call last):
File "/home/sanju/AI-projects/crewAI/main.py", line 9, in <module>
ChatOpenAI = openai(model="gpt-3.5")
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable
Should be pretty straightforward:
from langchain.chat_models import ChatOpenAI
gpt35 = ChatOpenAI(
temperature=0.7,
model_name="gpt-3.5",
)
Agent(
# ...
llm=gpt35
)
import os
from crewai import Agent, Task, Crew, Process
from langchain.llms import OpenAI
os.environ["OPENAI_API_KEY"] = "sk-hBOcPKVc...P3aX50lUotMCDBhb"
# Define your agents with roles and goals
researcher = Agent(
role="...",
goal="...",
backstory="...",
verbose=True,
llm=OpenAI(
temperature=0.8, model_name="gpt-3.5-turbo-1106"
), # It uses langchain.chat_models, default is GPT 3.5
)
Just set env OPENAI_MODEL_NAME = gpt3.5-turbo
Just set env OPENAI_MODEL_NAME = gpt3.5-turbo
This one is the only that worked for me