Skip to main content

background

Damj Logo

✨ Damj ✨

damj is a tool for creating comprehensive prompts for language models by combining project files and applying custom processing options.

PyPI

Introduction

damj is designed to help developers create effective prompts for large language models (LLMs) such as ChatGPT. By combining different project files and applying customizable processing options, damj simplifies the process of generating prompts tailored to specific project contexts.

Features

  • Combine multiple project files into a single prompt.
  • Apply customizable processing options to include/exclude comments, imports, and docstrings for python scripts.
  • Support for processing Jupyter notebooks and including cell outputs.
  • Easy integration and usage within Python projects.

Installation

From PyPI

You can install the latest release from PyPI:

pip install damj

From Source

git clone https://github.com/baselhusam/damj.git
cd damj
pip install .

Usage

Basic Example

import os
from damj import Damj

cwd = os.getcwd()
damj = Damj(cwd)

damj.project_info(
    project_overview="This is a sample project.",
    add_project_structure=True,
)

prompt = damj.create_prompt(
    question="What is the purpose of this project?",
)

print(prompt)

Output:

# Project Overview
This is a sample project.


# Project Structure
|   ├── LICENSE
|   ├── README.md
|   ├── pyproject.toml
|   ├── requirements.txt
├── assets/
|   ├── background.png
|   ├── logo.png
├── damj/
|   ├── __init__.py
|   ├── damj.py
|   ├── utils.py



# Question
What is the purpose of this project?

Another Detailed Exmaple

import os
from damj import Damj

cwd = os.getcwd()

damj = Damj(
    cwd=cwd,
    whitelist_files=["*.py"],
    blacklist_files=[".venv", "__pycache__"],
    snippet_marker="```"
)

damj.project_info(
    project_overview="This is a sample project.",
    add_project_structure=True,
    add_files_content=True,
    py_options={
        "add_imports": True,
        "add_comments": True,
        "add_docstrings": False,
        "ipynb_output": False
    }
)

prompt = damj.create_prompt(
    question="What is the purpose of this project?",
    copy_to_clipboard=True,
    to_markdown=False
)

print(prompt)

Use damj Utils Components

damj also provides several utility functions that can be used independently. These utilities include functions to get the project structure, get file content, and more.

Get Project Structure

The get_project_structure function generates a markdown representation of the directory structure, excluding blacklisted files and directories.

from damj.utils import get_project_structure

# Get the project structure excluding .venv and __pycache__ directories
cwd = os.getcwd()
blacklist = [".venv", "__pycache__"]
project_structure = get_project_structure(cwd, blacklist)
print(project_structure)

Get File Content

The get_file_content function retrieves the content of a file, applying the specified py_options.

from damj.utils import get_file_content

py_options = {
    "add_comments": True,
    "add_imports": True,
    "add_docstrings": False,
    "ipynb_output": False
}

# Get the content of a Python file with the specified options
file_content = get_file_content("example.py", py_options)
print(file_content)

License

This project is licensed under the Apache Software License. See the LICENSE file for details.


Contributors

Basel Mather (baselmathar@gmail.com)


Contributing

Contributions are welcome! Please fork the repository and open a pull request with your changes.

Metadata

Release files for damj 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for damj 0.1.4
File Size Uploaded Provenance Actions
damj-0.1.4.tar.gz 388.4 kB Without provenance Details for damj-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for damj 0.1.4
File Interpreter ABI Platform Actions
damj-0.1.4-py3-none-any.whl Python 3 none any Details for damj-0.1.4-py3-none-any.whl

Total release size: 400.5 kB

Release files / damj-0.1.4.tar.gz

Download URL damj-0.1.4.tar.gz
Size 388.4 kB
Tags Source
SHA-256 checksum
How to use checksums
19742a49e01c7f5b41979a38c26b6576de8132e3c111c98465f21eb92f42814c
BLAKE2b-256 checksum
How to use checksums
cd87aa835e7074418dfa771a288d89538345f5c8ce582e0fcb10998934d91fbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / damj-0.1.4-py3-none-any.whl

Download URL damj-0.1.4-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd52665853846c137916c33ff1189d142c3b1c6db2aa527d7dc702141c44ded3
BLAKE2b-256 checksum
How to use checksums
5702cbf9f6c2816a12b5d40ad7d11297daded02979d1e276d01a7fd2d1fa216b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for damj 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page