Open thinley4 opened 3 weeks ago
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.
Checklist
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
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