An LLM-powered API for automatically answering questions from course materials.
This FastAPI application uses advanced language models to provide accurate answers to questions. The system can:
- Process natural language questions and find similar questions in its database
- Generate and execute Python or Bash code to solve computational problems
- Handle file uploads (ZIP, CSV) and extract relevant information
- Determines whether code execution is needed or if a direct answer is sufficient
- Generates Python or Bash code based on the question
- Executes code in a secure temporary environment
- Extracts code from markdown code blocks if necessary
- Handles ZIP files by extracting contents
- Processes CSV files to extract data
- Provides file context to the LLM for better answers
- Connects to LLM API for generating answers and code
- Uses environment variables for secure API token storage
- Python 3.8+
- FastAPI
- scikit-learn
- dotenv
- Clone the repository:
git clone https://github.com/krishna-gramener/tdsproject2.git
cd tdsproject2- Install dependencies:
pip install -r requirements.txt- Create a
.envfile with your API token:
GITHUB_API_KEY=your_api_token_here
VERCEL_API_KEY=your_api_token_here
- Run the application:
uvicorn app:app --reloadMethod: POST
Parameters:
question(required): The question to answerfile(optional): A file to upload (ZIP or CSV)
curl -X POST "http://localhost:8000/api/" \
-H "Content-Type: multipart/form-data" \
-F "question=What is the output of pd.read_csv('data.csv').head()?" \
-F "file=@data.csv"The API returns detailed error messages when:
- Code execution fails
- The LLM API returns an error
- File processing encounters issues
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature-name - Submit a pull request
MIT