Skip to main content

Source2Prompt

PyPI Downloads

Source2Prompt is a Python package that converts all text files in a directory into a single prompt file for use with Large Language Models (LLMs). It recursively scans the specified directory and its subdirectories, identifies text files based on their MIME types, and combines their contents into a single prompt.txt file.

Installation

You can install Source2Prompt using pip:

pip install source2prompt

Usage

To use Source2Prompt, open a terminal or command prompt and run the following command:

  1. Specify a directory:
    For example, if you want to process text files in the C:\Users\YourName\Documents\MyProject directory, run this:
s2p C:\Users\YourName\Documents\MyProject
  1. Use the current directory: This command will process the text files in your current working directory:
s2p here

You can split the output into multiple prompt files using the --cut option:

s2p <directory> --cut <number>

After running the command, Source2Prompt will generate a prompt.txt file in the specified directory. This file will contain the contents of all text files found in the directory and its subdirectories.

Supported File Types

Source2Prompt identifies text files based on their MIME types. It supports a wide range of text file formats, including but not limited to:

  • Plain text files (.txt)
  • Python files (.py)
  • Markdown files (.md)
  • JSON files (.json)
  • CSV files (.csv)
  • HTML files (.html, .htm)
  • CSS files (.css)
  • JavaScript files (.js)

Any file with a MIME type starting with text/ will be considered a text file and included in the prompt.txt file.

s2p Output Format

The generated prompt.txt file will have the following format:

path/to/file1.txt:
Contents of file1.txt

path/to/file2.md:
Contents of file2.md

...

Each file's content is preceded by its relative path within the specified directory, followed by a colon and a newline. The file contents are then included, followed by two newline characters to separate it from the next file.

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

Metadata

Release files for source2prompt 0.3.2

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

Source distribution (sdist)

Source distribution for source2prompt 0.3.2
File Size Uploaded
source2prompt-0.3.2.tar.gz 12.4 kB Details

Built distribution (wheel)

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

Total release size: 23.9 kB

Release files / source2prompt-0.3.2.tar.gz

Download URL source2prompt-0.3.2.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e3fbf14e0e1e0816ef025853454304bcee8ec4cc8067ea02e8fe220fba2aa4d2
BLAKE2b-256 checksum
How to use checksums
27ab899d9d2906597d168c111e5d7a6b0157bb944cef4dfe6f0efe6ad8667150
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.6

Release files / source2prompt-0.3.2-py3-none-any.whl

Download URL source2prompt-0.3.2-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3799746e4ad1ef282d9b25ba0c3e2773ae13198279c521e1fb17686b6e84158d
BLAKE2b-256 checksum
How to use checksums
7aea9e17137d7738af2d51b52286cb959904a82f88b08cdf18ebab1bd7b070e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

2 release files

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