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.64k stars 2.57k forks source link

How to use GPT-3.5?? #95

Closed thesanju closed 7 months ago

thesanju commented 7 months ago
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
Biancamazzi commented 7 months ago

Should be pretty straightforward:

from langchain.chat_models import ChatOpenAI

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

Agent(
# ...
llm=gpt35
)
llxxxll commented 7 months ago
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
)
imnotdev25 commented 3 months ago

Just set env OPENAI_MODEL_NAME = gpt3.5-turbo

titopuertolara commented 2 months ago

Just set env OPENAI_MODEL_NAME = gpt3.5-turbo

This one is the only that worked for me