Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc link: https://js.langchain.com/v0.2/docs/tutorials/rag/ Bug title: Issue in the Section 5 '5. Retrieval and Generation: Generate' #6643

Open
2 tasks done
thinley4 opened this issue Aug 27, 2024 · 1 comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@thinley4
Copy link

Checklist

  • I added a very descriptive title to this issue.
  • I included a link to the documentation page I am referring to (if applicable).

Issue with current documentation:

If I replace this code:

import { ChatPromptTemplate } from "@langchain/core/prompts";
import { pull } from "langchain/hub";

const prompt = await pull("rlm/rag-prompt");

Error
Bug

With this code:

import * as hub from "langchain/hub";
const prompt = await hub.pull("rlm/rag-prompt");

Everything works fine.

Idea or request for content:

No response

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Aug 27, 2024
Copy link

dosubot bot commented Aug 27, 2024

Hello @thinley4! I'm here to help you with any bugs, questions, or contributions you have. Let's work together to resolve the issue you're facing.

To resolve the TypeError indicating that prompt.invoke is not a function, ensure that you are correctly importing and using the ChatPromptTemplate class. The invoke method is defined within the ChatPromptTemplate class, so the error might be due to an incorrect import or usage.

Here is an example of how to correctly import and use the ChatPromptTemplate class:

import { ChatOpenAI } from "@langchain/openai";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { pull } from "langchain/hub";
import { ChatPromptTemplate } from "@langchain/core/prompts";

const model = new ChatOpenAI({
  openAIApiKey: "sk-XXXX",
});

async function main() {
  const prompt = await pull<ChatPromptTemplate>(
    "hwchase17/openai-functions-agent"
  );

  const agent = await createOpenAIFunctionsAgent({
    llm: model,
    prompt,
    tools: []
  });

  const agentExecutor = new AgentExecutor({
    agent,
    tools: [],
  });

  console.log(agentExecutor);
}

main();

Ensure that the ChatPromptTemplate class is correctly imported from the @langchain/core/prompts module and that you are calling the invoke method on an instance of ChatPromptTemplate. Additionally, make sure that the pull function is correctly used to fetch the prompt template. Note that the import paths have been updated to reflect the new module structure as per the latest changes in the langchain library [1][2][3].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant