Skip to content

Repository files navigation

AI Study Assistant

A Streamlit application that uses MarkItDown and Large Language Models (Gemini) to convert documents (PDF, PPT, etc.) into comprehensive, structured study notes.

Features

  • Document Ingestion: Supports various formats via MarkItDown (PDF, PPT, DOCX, etc.).
  • Markdown Conversion: Extracts content and basic structure from documents.
  • Optional OCR Enhancement (PDFs only): Uses Gemini 1.5 to analyze images/diagrams within PDFs, extract text (OCR), and generate descriptions, integrating this with the main markdown content.
  • Detailed Notes Generation: Employs a Gemini model (configurable, defaults to gemini-1.5-pro-latest) via Camel AI to transform the markdown into detailed study notes, following a structured format.
  • Customizable Output: Choose between ASCII-only diagrams or include simple Mermaid diagrams in the notes.
  • Web Interface: Easy-to-use Streamlit application for uploading files/URLs and viewing results.

Project Structure

markitdown_camel/
├── src/
│   ├── agents/          # LLM agent logic (Note Creation, OCR)
│   │   ├── __init__.py
│   │   ├── note_creation_agent.py
│   │   └── ocr_agent.py
│   ├── app/             # Streamlit application UI and logic
│   │   ├── __init__.py
│   │   └── app.py
│   └── __init__.py
├── docs/                # Detailed documentation
│   ├── how_to_run.md
│   └── README_STUDY_ASSISTANT.md
├── .env.template        # Template for environment variables
├── .env                 # Local environment variables (GITIGNORED)
├── .gitignore           # Specifies intentionally untracked files that Git should ignore
├── README.md            # This file
├── requirements.txt     # Python package dependencies
└── run.py               # Simple application launcher script

Setup and Configuration

Prerequisites

  • Python 3.9+
  • Conda (Recommended for managing environments)
  • Access to Google AI Studio or Google Cloud AI Platform for a Google API Key (for Gemini models).
  • (Optional) Access to Anthropic's API for a key if you wish to modify the agent to use Claude models.

Installation Steps

  1. Clone the Repository:

    git clone <your-repo-url>
    cd markitdown_camel
  2. Create and Activate Environment (Recommended):

    # Using Conda
    conda create -n study_assist python=3.10 -y
    conda activate study_assist
    
    # Or using venv
    # python -m venv venv
    # source venv/bin/activate # On Linux/Mac
    # venv\Scripts\activate    # On Windows
  3. Install Dependencies:

    pip install -r requirements.txt

    (This installs streamlit, camel-ai[google], markitdown[all], google-generativeai, python-dotenv, and their dependencies).

  4. Configure API Keys:

    • Copy the template file: cp .env.template .env
    • Edit the .env file:
      # .env
      GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY_HERE
      # ANTHROPIC_API_KEY=YOUR_ANTHROPIC_KEY_HERE # (Optional: If modifying agent)
    • Replace YOUR_GOOGLE_API_KEY_HERE with your actual Google API key.
    • (Optional) If you plan to modify src/agents/note_creation_agent.py to use Anthropic's Claude models, add your Anthropic key.

Running the Application

Ensure your virtual environment is activated and your .env file is configured.

python run.py

This script will load the environment variables and start the Streamlit application. Open the provided local URL (usually http://localhost:8501) in your web browser.

Alternatively, you can run directly with Streamlit:

streamlit run src/app/app.py

Usage

  1. Configure Options (Sidebar):
    • Diagram Style: Choose "ASCII Charts Only" or "ASCII + Simple Mermaid" for the visual style in the final notes.
    • Enhance PDF Analysis (OCR): Toggle this on if processing a PDF and you want to use Gemini 1.5 to analyze images/diagrams within it. (Note: This adds significant processing time).
  2. Upload Document (Tab 1):
    • Select "Upload File" or "Enter URL".
    • Provide your document.
    • Click "Convert to Markdown".
  3. Review Markdown (Tab 2):
    • The extracted text (and OCR results, if enabled) will be displayed.
    • Review the content.
    • Click "Generate Study Notes" at the bottom when ready.
  4. View Study Notes (Tab 3):
    • The detailed, structured notes will appear here.
    • Use the download button to save the notes as a Markdown file.

Disclaimer: Model Choice and Note Quality

This application uses Google's Gemini models (specifically gemini-2.5-pro-preview-03-25 by default for note generation) via the Camel AI library. While powerful, the quality, detail, and formatting consistency of the generated notes can vary depending on the complexity of the source document and the model's interpretation of the detailed prompts.

For potentially improved note quality, structure, and adherence to complex formatting instructions, consider modifying the src/agents/note_creation_agent.py file to utilize Anthropic's Claude models (e.g., Claude 3 Opus). This would require:

  1. Installing the necessary Camel AI integration: pip install camel-ai[anthropic]
  2. Updating the ModelFactory.create call within note_creation_agent.py to specify ModelPlatformType.ANTHROPIC and the desired Claude model type.
  3. Ensuring your ANTHROPIC_API_KEY is set in the .env file.

Experimenting with different models and potentially refining the prompts further may be necessary to achieve optimal results for your specific needs.

Dependencies

Key dependencies are listed in requirements.txt. Core libraries include:

  • streamlit: For the web application interface.
  • markitdown[all]: For initial document conversion to Markdown.
  • camel-ai[google]: For interacting with Gemini models for note generation.
  • google-generativeai: For direct PDF analysis using Gemini 1.5 (OCR feature).
  • python-dotenv: For managing environment variables.

Further Documentation

See the docs/ directory for potentially more detailed guides originally generated during development.

About

No description, website, or topics provided.

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages