Skip to main content

Interactive code summarizer using AI and TUI

Project description

Code Summarizer for LLM Interaction

Project Description 📝

This tool generates concise code summaries optimized for Large Language Models (LLMs). It uses OpenAI's GPT-4 to create project overviews, making it easier for LLMs to understand and work with your codebase. Features include interactive file selection, summary caching, and automatic README generation.

Video Tutorial

codesum youtube video

Key Features 🔑

  • Curses-based interactive file selection
  • Intelligent summary caching
  • Respects .gitignore rules
  • Generates detailed and compressed summaries
  • Creates AI-generated README.md
  • Command-line argument support

Installation 🛠️

You can set up this project using either the automated setup script or manual installation.

Option 1: Automated Setup (Recommended)

  1. Clone the repository
  2. Navigate to the project directory
  3. Run the setup script:
    python setup.py
    
    This script will:
    • Create a virtual environment
    • Install dependencies
    • Set up the .env file
    • Create an alias for easy usage

Option 2: Manual Setup

  1. Clone the repository
  2. Navigate to the project directory
  3. Set up the Python environment:
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    
  4. Create a .env file with your OpenAI API key:
    OPENAI_API_KEY='your-api-key-here'
    LLM_MODEL='gpt-4'
    
  5. Optionally, run codesum.sh for automated setup

Usage 🚀

Python script:

python app.py [--infer]

Bash script:

chmod +x codesum.sh
./codesum.sh [arguments]

Using the alias (if set up):

codesum [arguments]

The --infer flag enables OpenAI API calls for summaries and README generation.

Output 📂

When run, the script produces the following:

  1. Local Code Summary:

    • File: .summary_files/code_summary.md
    • Contents: A comprehensive summary of all selected files, including their full content and a tree structure of the project.
    • The contents of this file will automatically be sent to the system clipboard.
  2. Compressed Code Summary (optional):

    • File: .summary_files/compressed_code_summary.md
    • Contents: A condensed version of the code summary, including AI-generated summaries for each file and the project structure.
  3. Updated README.md (optional):

    • File: README.md in the project root
    • Contents: An AI-generated README file based on the compressed code summary, including sections like Project Description, Installation, Usage, and more.
  4. Metadata Files:

    • Location: .summary_files/[file_path]_metadata.json for each summarized file
    • Contents: JSON files containing the hash of the original file and its generated summary, used for caching purposes.
  5. Previous Selection File:

    • File: .summary_files/previous_selection.json
    • Contents: A JSON file storing the list of previously selected files for future reference.

These outputs provide a comprehensive overview of your project, facilitate efficient interaction with LLMs, and streamline future summarization processes.

Dependencies 📚

  • openai
  • itsprompt
  • pathspec
  • python-dotenv
  • keyboard
  • curses (built-in)

Acknowledgements 🙌

Thanks to all contributors and library creators.

License 📜

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codesum-0.1.1.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codesum-0.1.1-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file codesum-0.1.1.tar.gz.

File metadata

  • Download URL: codesum-0.1.1.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for codesum-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2080e67fcb69e66f6c73d5dc6de8dd966877824924b41b3c114f7bc64ff59871
MD5 be2161ba69fec45c25954168212097fa
BLAKE2b-256 ad2e9b02269a82177151eb910ceea19ea9f127aa557887021cd93d960da0d74c

See more details on using hashes here.

File details

Details for the file codesum-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: codesum-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for codesum-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 710353b8b7642f3d0b83701cacd39f914ad4f4696860883d008c8dbab4bdd16b
MD5 a05c339224f21ca8d4de7b3021380394
BLAKE2b-256 8d520a88c690155069ba66acadf93ff87edb9ddc3fd929ca5d0eb4f97ee14373

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page