langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.16k stars 2.05k forks source link

Error in documentation? #2446

Closed mrahmadt closed 12 months ago

mrahmadt commented 12 months ago

Hi

https://js.langchain.com/docs/get_started/quickstart https://js.langchain.com/docs/modules/agents/agent_types/openai_functions_agent

explain how to use openai-functions agent, but it seems it's not correct https://github.com/hwchase17/langchainjs/blob/main/langchain/src/agents/initialize.ts

type AgentType =
  | "zero-shot-react-description"
  | "chat-zero-shot-react-description"
  | "chat-conversational-react-description";

it's confusing for a new user to langchain, is this an error?

dosubot[bot] commented 12 months ago

🤖

Hello,

Thank you for bringing this to our attention. I understand that the discrepancy between the documentation and the codebase can be confusing.

The OpenAIAgent class in the LangChain framework correctly defines the _agentType() method to return "openai-functions" as a constant. This is consistent with the AgentType in the initialize.ts file. Here is the relevant code snippet:

_agentType() {
  return "openai-functions" as const;
}

This method is used to specify the type of the agent, and in this case, it is "openai-functions". The "as const" part is a TypeScript feature that makes the return type a literal type instead of a string, ensuring that the value is constant and cannot be changed.

In the context shared, the "openai-functions" agent type is used in the InitializeAgentExecutorOptionsStructured interface and in the initializeAgentExecutorWithOptions function. This further confirms that the "openai-functions" agent type is valid and correctly used in the LangChain framework.

As for the "zero-shot-react-description", "chat-zero-shot-react-description", and "chat-conversational-react-description" agent types, I wasn't able to find specific information about them in the repository. It's possible that these are agent types used in other parts of the LangChain framework or they could be legacy code from previous versions.

I hope this clears up the confusion. If you have any more questions, feel free to ask.

Best, Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

jacoblee93 commented 12 months ago

Did you try it?

Options for the withOptions method are here: https://github.com/hwchase17/langchainjs/blob/main/langchain/src/agents/initialize.ts#L97