This repo contains code to extract math equations from images using Mathpix API and generate explanations for the steps using OpenAI API.
- Python 3.7+
- Pip
- Virtualenv (optional)
- Clone the repo:
git clone https://github.com/username/repo-name.git
- (Optional) Create and activate a virtual environment:
virtualenv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate
- Install the requirements
pip install -r requirements.txt
- Create a .env file with your API keys:
MATHPIX_APP_ID=YOUR_APP_ID
MATHPIX_APP_KEY=YOUR_APP_KEY
If you want immediately test if GPT understands the output, add
OPENAI_API_KEY=YOUR_API_KEY
- Run the code:
python main.py
This will process all images in the input
folder and save the responses in the output
and answers
folders.
To test in OpenAI test mode, set openai_test_mode = True
in main.py
. This will send requests to OpenAI's test API endpoint.