langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Is it possible to use gpt-3.5-turbo or gpt-4 as the LLM model for agents?

Open mathematicsofpaul opened this issue 1 year ago • 4 comments

Provided I have given a system prompt, I wanted to use gpt-4 as the llm for my agents. I read around, but it only seems like gpt-3 davinci and nothing beyond it is an option.

Can gpt-3.5-turbo or gpt-4 be included as a llm option for agents?

mathematicsofpaul avatar Mar 31 '23 07:03 mathematicsofpaul

I think so:

from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.chat_models import ChatOpenAI


llm = ChatOpenAI(model='gpt-3.5-turbo',temperature=0)
tools = load_tools(['human'], llm=llm)

agent = initialize_agent(tools, llm, agent="chat-zero-shot-react-description", verbose=True)

agent.run("Can you ask the human what to do?")

jonmellman avatar Mar 31 '23 19:03 jonmellman

This is how I've done it as well

kaashin avatar Apr 01 '23 06:04 kaashin

Trying to do this but getting na error:

openai has no ChatCompletion attribute

Any thoughts?

ChuckJonas avatar Apr 06 '23 17:04 ChuckJonas

Is there any way to do this without having the agent prompt me asking for a user input?

mathematicsofpaul avatar Apr 14 '23 09:04 mathematicsofpaul

I tried this approach. But, with this approach I am not able to use the tools, due to parsing error:

OutputParserException: Could not parse LLM output: `I need to use the NewsTool to find news articles about the sale of XYZ stocks.`

gdevanla avatar Jun 29 '23 22:06 gdevanla

Same issue from my end

therealjuanmartinez avatar Jul 12 '23 18:07 therealjuanmartinez

Hi, @mathematicsofpaul! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue was about using GPT-3.5-turbo or GPT-4 as the language model for agents, instead of just GPT-3 davinci. One user suggested a code snippet to use GPT-3.5-turbo as the model, and another user confirmed that they have used the same approach successfully. The reported issues related to the ChatCompletion attribute error and parsing error when using the tools have been resolved.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your contribution to the LangChain repository!

dosubot[bot] avatar Oct 11 '23 16:10 dosubot[bot]