files-to-prompt


Namefiles-to-prompt JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryConcatenate a directory full of files into a single prompt for use with LLMs
upload_time2024-04-08 06:06:30
maintainerNone
docs_urlNone
authorSimon Willison
requires_python>=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # files-to-prompt

[![PyPI](https://img.shields.io/pypi/v/files-to-prompt.svg)](https://pypi.org/project/files-to-prompt/)
[![Changelog](https://img.shields.io/github/v/release/simonw/files-to-prompt?include_prereleases&label=changelog)](https://github.com/simonw/files-to-prompt/releases)
[![Tests](https://github.com/simonw/files-to-prompt/actions/workflows/test.yml/badge.svg)](https://github.com/simonw/files-to-prompt/actions/workflows/test.yml)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/files-to-prompt/blob/master/LICENSE)

Concatenate a directory full of files into a single prompt for use with LLMs

## Installation

Install this tool using `pip`:
```bash
pip install files-to-prompt
```

## Usage

To use `files-to-prompt`, provide the path to one or more files or directories you want to process:

```bash
files-to-prompt path/to/file_or_directory [path/to/another/file_or_directory ...]
```

This will output the contents of every file, with each file preceded by its relative path and separated by `---`.

### Options

- `--include-hidden`: Include files and folders starting with `.` (hidden files and directories).
  ```bash
  files-to-prompt path/to/directory --include-hidden
  ```

- `--ignore-gitignore`: Ignore `.gitignore` files and include all files.
  ```bash
  files-to-prompt path/to/directory --ignore-gitignore
  ```

- `--ignore <pattern>`: Specify one or more patterns to ignore. Can be used multiple times.
  ```bash
  files-to-prompt path/to/directory --ignore "*.log" --ignore "temp*"
  ```

### Example

Suppose you have a directory structure like this:

```
my_directory/
├── file1.txt
├── file2.txt
├── .hidden_file.txt
├── temp.log
└── subdirectory/
    └── file3.txt
```

Running `files-to-prompt my_directory` will output:

```
my_directory/file1.txt
---
Contents of file1.txt
---
my_directory/file2.txt
---
Contents of file2.txt
---
my_directory/subdirectory/file3.txt
---
Contents of file3.txt
---
```

If you run `files-to-prompt my_directory --include-hidden`, the output will also include `.hidden_file.txt`:

```
my_directory/.hidden_file.txt
---
Contents of .hidden_file.txt
---
...
```

If you run `files-to-prompt my_directory --ignore "*.log"`, the output will exclude `temp.log`:

```
my_directory/file1.txt
---
Contents of file1.txt
---
my_directory/file2.txt
---
Contents of file2.txt
---
my_directory/subdirectory/file3.txt
---
Contents of file3.txt
---
```

## Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

```bash
cd files-to-prompt
python -m venv venv
source venv/bin/activate
```

Now install the dependencies and test dependencies:

```bash
pip install -e '.[test]'
```

To run the tests:
```bash
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "files-to-prompt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Simon Willison",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/4a/7e/3f4c51cd4a6b07afecb0179c86c6f223f1bf03f97af3e5e5351cdf3ee578/files-to-prompt-0.2.1.tar.gz",
    "platform": null,
    "description": "# files-to-prompt\n\n[![PyPI](https://img.shields.io/pypi/v/files-to-prompt.svg)](https://pypi.org/project/files-to-prompt/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/files-to-prompt?include_prereleases&label=changelog)](https://github.com/simonw/files-to-prompt/releases)\n[![Tests](https://github.com/simonw/files-to-prompt/actions/workflows/test.yml/badge.svg)](https://github.com/simonw/files-to-prompt/actions/workflows/test.yml)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/files-to-prompt/blob/master/LICENSE)\n\nConcatenate a directory full of files into a single prompt for use with LLMs\n\n## Installation\n\nInstall this tool using `pip`:\n```bash\npip install files-to-prompt\n```\n\n## Usage\n\nTo use `files-to-prompt`, provide the path to one or more files or directories you want to process:\n\n```bash\nfiles-to-prompt path/to/file_or_directory [path/to/another/file_or_directory ...]\n```\n\nThis will output the contents of every file, with each file preceded by its relative path and separated by `---`.\n\n### Options\n\n- `--include-hidden`: Include files and folders starting with `.` (hidden files and directories).\n  ```bash\n  files-to-prompt path/to/directory --include-hidden\n  ```\n\n- `--ignore-gitignore`: Ignore `.gitignore` files and include all files.\n  ```bash\n  files-to-prompt path/to/directory --ignore-gitignore\n  ```\n\n- `--ignore <pattern>`: Specify one or more patterns to ignore. Can be used multiple times.\n  ```bash\n  files-to-prompt path/to/directory --ignore \"*.log\" --ignore \"temp*\"\n  ```\n\n### Example\n\nSuppose you have a directory structure like this:\n\n```\nmy_directory/\n\u251c\u2500\u2500 file1.txt\n\u251c\u2500\u2500 file2.txt\n\u251c\u2500\u2500 .hidden_file.txt\n\u251c\u2500\u2500 temp.log\n\u2514\u2500\u2500 subdirectory/\n    \u2514\u2500\u2500 file3.txt\n```\n\nRunning `files-to-prompt my_directory` will output:\n\n```\nmy_directory/file1.txt\n---\nContents of file1.txt\n---\nmy_directory/file2.txt\n---\nContents of file2.txt\n---\nmy_directory/subdirectory/file3.txt\n---\nContents of file3.txt\n---\n```\n\nIf you run `files-to-prompt my_directory --include-hidden`, the output will also include `.hidden_file.txt`:\n\n```\nmy_directory/.hidden_file.txt\n---\nContents of .hidden_file.txt\n---\n...\n```\n\nIf you run `files-to-prompt my_directory --ignore \"*.log\"`, the output will exclude `temp.log`:\n\n```\nmy_directory/file1.txt\n---\nContents of file1.txt\n---\nmy_directory/file2.txt\n---\nContents of file2.txt\n---\nmy_directory/subdirectory/file3.txt\n---\nContents of file3.txt\n---\n```\n\n## Development\n\nTo contribute to this tool, first checkout the code. Then create a new virtual environment:\n\n```bash\ncd files-to-prompt\npython -m venv venv\nsource venv/bin/activate\n```\n\nNow install the dependencies and test dependencies:\n\n```bash\npip install -e '.[test]'\n```\n\nTo run the tests:\n```bash\npytest\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Concatenate a directory full of files into a single prompt for use with LLMs",
    "version": "0.2.1",
    "project_urls": {
        "CI": "https://github.com/simonw/files-to-prompt/actions",
        "Changelog": "https://github.com/simonw/files-to-prompt/releases",
        "Homepage": "https://github.com/simonw/files-to-prompt",
        "Issues": "https://github.com/simonw/files-to-prompt/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee393d2db6592885a242d232a0c430946cc08a5dce5ab66d529f477f7d2c7902",
                "md5": "fd214aa15f3bc13bba3f7a491e6215b7",
                "sha256": "a84261831591c4a5b7e6401b1e1e6be2dcf4da1af8df518210e28e52bbb26634"
            },
            "downloads": -1,
            "filename": "files_to_prompt-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fd214aa15f3bc13bba3f7a491e6215b7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8296,
            "upload_time": "2024-04-08T06:06:29",
            "upload_time_iso_8601": "2024-04-08T06:06:29.131391Z",
            "url": "https://files.pythonhosted.org/packages/ee/39/3d2db6592885a242d232a0c430946cc08a5dce5ab66d529f477f7d2c7902/files_to_prompt-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a7e3f4c51cd4a6b07afecb0179c86c6f223f1bf03f97af3e5e5351cdf3ee578",
                "md5": "a8e31bffee1b175d9b6447d10b139049",
                "sha256": "a544a4ecbcf02c1ae562a22b9f9901b755860e651879c36c093fe549a6c503c4"
            },
            "downloads": -1,
            "filename": "files-to-prompt-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a8e31bffee1b175d9b6447d10b139049",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8278,
            "upload_time": "2024-04-08T06:06:30",
            "upload_time_iso_8601": "2024-04-08T06:06:30.557107Z",
            "url": "https://files.pythonhosted.org/packages/4a/7e/3f4c51cd4a6b07afecb0179c86c6f223f1bf03f97af3e5e5351cdf3ee578/files-to-prompt-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-08 06:06:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "simonw",
    "github_project": "files-to-prompt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "files-to-prompt"
}
        
Elapsed time: 0.23061s