OpenAI Agent
OpenAI API that supports function calling, it’s never been easier to build your own agent!
In this notebook tutorial, we showcase how to write your own OpenAI agent
Setup
First, you need to install the llamaindex
package. You can do this by running the following command in your terminal:
pnpm i llamaindex
Then we can define a function to sum two numbers and another function to divide two numbers.
function sumNumbers({ a, b }: { a: number; b: number }): number {
return a + b;
}
// Define a function to divide two numbers
function divideNumbers({ a, b }: { a: number; b: number }): number {
return a / b;
}
Create a function tool
Now we can create a function tool from the sum function and another function tool from the divide function.
For the parameters of the sum function, we can define a JSON schema.