Example


const prompt = ChatPromptTemplate.fromMessages([
["ai", "You are a helpful assistant"],
["human", "{input}"],
new MessagesPlaceholder("agent_scratchpad"),
]);

const modelWithFunctions = new ChatOpenAI({
modelName: "gpt-4",
temperature: 0,
}).bind({
functions: tools.map((tool) => convertToOpenAIFunction(tool)),
});

const runnableAgent = RunnableSequence.from([
{
input: (i) => i.input,
agent_scratchpad: (i) => formatAgentSteps(i.steps),
},
prompt,
modelWithFunctions,
new OpenAIFunctionsAgentOutputParser(),
]);

const result = await runnableAgent.invoke({
input: "What is the weather in New York?",
steps: agentSteps,
});

Hierarchy (view full)

Constructors

Methods

Generated using TypeDoc