Skip to main content

A simple tool to convert source files to a single prompt file for LLMs

Project description

Source2Prompt

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:
s2p C:\Users\YourName\Documents\MyProject

Replace /path/to/directory with the path to the directory containing the text files you want to combine. For example, if you want to process text files in the C:\Users\YourName\Documents\MyProject directory, run:

  1. Use the current directory:
s2p here

This command will process the text files in your current working directory.

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.

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

source2prompt-0.1.6.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

source2prompt-0.1.6-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file source2prompt-0.1.6.tar.gz.

File metadata

  • Download URL: source2prompt-0.1.6.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.8

File hashes

Hashes for source2prompt-0.1.6.tar.gz
Algorithm Hash digest
SHA256 00115d45fe07892b2ed460184bda6272a179f16285177fc34b6ca29f3ea1e0dd
MD5 0f8a124b7c738ed0a461b612887581b4
BLAKE2b-256 f79820cf7064c14761d5f657400f36f26a8497be16424f552517262425813db1

See more details on using hashes here.

File details

Details for the file source2prompt-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: source2prompt-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.8

File hashes

Hashes for source2prompt-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 74fdb9e7b534c836cb1c83f17355a1e71cc37d57afe13895866ef8219a441b5d
MD5 fe3daba6fa6f98024803d03a34210265
BLAKE2b-256 b5f22cae6b1244e6a38cbdf2c2789a09c16a6460d1ad051db41aa337252dbc61

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