A Streamlit application that uses MarkItDown and Large Language Models (Gemini) to convert documents (PDF, PPT, etc.) into comprehensive, structured study notes.
- 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.
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
- 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.
-
Clone the Repository:
git clone <your-repo-url> cd markitdown_camel
-
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
-
Install Dependencies:
pip install -r requirements.txt
(This installs
streamlit,camel-ai[google],markitdown[all],google-generativeai,python-dotenv, and their dependencies). -
Configure API Keys:
- Copy the template file:
cp .env.template .env - Edit the
.envfile:# .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_HEREwith your actual Google API key. - (Optional) If you plan to modify
src/agents/note_creation_agent.pyto use Anthropic's Claude models, add your Anthropic key.
- Copy the template file:
Ensure your virtual environment is activated and your .env file is configured.
python run.pyThis 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- 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).
- Upload Document (Tab 1):
- Select "Upload File" or "Enter URL".
- Provide your document.
- Click "Convert to Markdown".
- 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.
- View Study Notes (Tab 3):
- The detailed, structured notes will appear here.
- Use the download button to save the notes as a Markdown file.
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:
- Installing the necessary Camel AI integration:
pip install camel-ai[anthropic] - Updating the
ModelFactory.createcall withinnote_creation_agent.pyto specifyModelPlatformType.ANTHROPICand the desired Claude model type. - Ensuring your
ANTHROPIC_API_KEYis set in the.envfile.
Experimenting with different models and potentially refining the prompts further may be necessary to achieve optimal results for your specific needs.
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.
See the docs/ directory for potentially more detailed guides originally generated during development.