This Node.js application utilizes the OpenAI Assistants API to create a Math Tutor assistant. It allows you to interact with the assistant by asking math-related questions and getting answers.
This Node.js application utilizes the OpenAI Assistants API to create a Math Tutor assistant. It allows you to interact with the assistant by asking math-related questions and getting answers.
Before running the code, ensure you have the following prerequisites installed:
You may need to make sure that your Node.js version is compatible with the OpenAI npm to avoid dependency issues.
Clone or download this repository to your local machine.
Navigate to the project folder in your terminal.
Create a .env
file in the project directory and add your OpenAI API key to it:
OPENAI_API_KEY="REPLACE WITH YOUR OPENAI API KEY HERE"
Install the required dependencies by running the following commands:
yarn add openai
yarn add readline
yarn add dotenv
To run the Math Tutor Assistant, execute the following command in your terminal:
node math-tutor.js
The chatbot will start and guide you through the process of asking math questions.
The code is set up to use the GPT-4 model and the “Math Tutor” assistant by default. You can customize the assistant’s behavior by modifying the code. You can change the assistant’s name, instructions, and the OpenAI model used in the main
function.
const assistant = await openai.beta.assistants.create({
name: "Math Tutor",
instructions:
"You are a math tutor. Write and run code to answer math questions.",
tools: [{ type: "code_interpreter" }],
model: "gpt-4-1106-preview",
});
This project is licensed under the MIT License.