crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

How to use GPT-3.5??

Open thesanju opened this issue 1 year ago • 1 comments

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

thesanju avatar Jan 09 '24 12:01 thesanju

Should be pretty straightforward:

from langchain.chat_models import ChatOpenAI

gpt35 = ChatOpenAI(
  temperature=0.7,
  model_name="gpt-3.5",
)

Agent(
# ...
llm=gpt35
)

Biancamazzi avatar Jan 09 '24 14:01 Biancamazzi

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
)

llxxxll avatar Jan 10 '24 10:01 llxxxll

Just set env OPENAI_MODEL_NAME = gpt3.5-turbo

imnotdev25 avatar May 24 '24 03:05 imnotdev25

Just set env OPENAI_MODEL_NAME = gpt3.5-turbo

This one is the only that worked for me

titopuertolara avatar Jun 07 '24 20:06 titopuertolara