This Python script automates the analysis and summarization of all files within a specified directory, leveraging the Ollama machine learning model to understand and process content efficiently. The output includes two types of documentation files:
- README.md - A user-friendly document enhanced with emojis to highlight key points.
- DOKU.md - A detailed, technical document for in-depth understanding.
- Automated File Processing: Iterates through all files in a directory, extracting text for analysis.
- Integration with Ollama: Uses advanced machine learning models to generate concise summaries.
- Dual Documentation: Generates both a simple README and a comprehensive technical document.
- Python 3.8 or higher
- Access to the Ollama API
- Required Python packages:
json
,os
,sys
,traceback
,dotenv
- Clone the repository or download the files into your working directory.
- Install the required Python packages:
pip install ollama dotenv
- Set your Ollama API credentials in a
.env
file in the same directory as the script:PROJECT_PLANNER_MODEL=dolphin-mistral:latest CODER_MODEL=codellama:7b MARKDOWN_MAKER=vicuna:13b-16k TASKNAMER=stablelm2:1.6b-zephyr-fp16
Run the script via the command line with the directory path as an argument:
python path_to_script.py path_to_directory
python summarize_directory.py ./example_directory
This will process files in ./example_directory
and generate README.md
and DOKU.md
in your working directory.
The script includes basic error handling to diagnose and report issues during execution. Check the console outputs and tracebacks to identify the causes of failures.
Ensure that you process trusted data, as the script does not perform comprehensive security checks on the content of the files.