OpenAi Functions Executor
To take advantage of OpenAI Function Calling announcement|docs, You can use an LlmExecutorOpenAiFunctions
. A LlmExecutorOpenAiFunctions is exactly like a regular llm executor - in fact, it just extends the class and adds options with some additional type restraints.
Basic Example
Highlighted below are the few lines that demonstrate the options for a
const llm = createLlmOpenAi({/* options */});
const instruction = `You are walking through a maze.
You must take one step at a time.
Pick a direction to move.`;
const prompt = createChatPrompt(instruction);
const executor = new LlmExecutorOpenAiFunctions({
llm,
prompt,
})
const functions = [{
name: "move_left",
description: "move one block to the left",
parameters: {/* options */}
},{
name: "move_right",
description: "move one block to the right",
parameters: {/* options */}
}]
const response = await executor.execute({
input: "Hello!"
}, {
function_call: "auto",
functions: functions,
})