将一个目录中的所有文件合并成一个用于LLMs的单一提示
项目描述
files-to-prompt
将一个目录中的所有文件合并成一个用于LLMs的单一提示
关于此项目的背景信息,请参阅 使用Claude 3 Opus完全构建files-to-prompt。
安装
使用pip
安装此工具
pip install files-to-prompt
用法
要使用files-to-prompt
,提供要处理的文件或目录的路径
files-to-prompt path/to/file_or_directory [path/to/another/file_or_directory ...]
这将输出每个文件的内容,每个文件前都包含其相对路径,并用---
分隔。
选项
-
--include-hidden
:包含以.
开始的文件和文件夹(隐藏文件和目录)。files-to-prompt path/to/directory --include-hidden
-
--ignore-gitignore
:忽略.gitignore
文件并包含所有文件。files-to-prompt path/to/directory --ignore-gitignore
-
--ignore <pattern>
:指定一个或多个要忽略的模式。可多次使用。files-to-prompt path/to/directory --ignore "*.log" --ignore "temp*"
-
c/--cxml
:以Claude XML格式输出。files-to-prompt path/to/directory --cxml
-
-o/--output <file>
:将输出写入文件而不是打印到控制台。files-to-prompt path/to/directory -o output.txt
示例
假设您有一个类似这样的目录结构
my_directory/
├── file1.txt
├── file2.txt
├── .hidden_file.txt
├── temp.log
└── subdirectory/
└── file3.txt
运行files-to-prompt my_directory
将输出
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
---
如果您运行files-to-prompt my_directory --include-hidden
,输出也将包括.hidden_file.txt
my_directory/.hidden_file.txt
---
Contents of .hidden_file.txt
---
...
如果您运行files-to-prompt my_directory --ignore "*.log"
,输出将排除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
---
克莱德XML输出
Anthropic提供了特定指南,以优化提示结构,充分利用克莱德扩展的上下文窗口。
要以这种方式构建输出,请使用可选的--cxml
标志,这将生成类似以下内容的输出
<documents>
<document index="1">
<source>my_directory/file1.txt</source>
<document_content>
Contents of file1.txt
</document_content>
</document>
<document index="2">
<source>my_directory/file2.txt</source>
<document_content>
Contents of file2.txt
</document_content>
</document>
</documents>
开发
要为此工具做出贡献,首先检出代码。然后创建一个新的虚拟环境
cd files-to-prompt
python -m venv venv
source venv/bin/activate
现在安装依赖项并测试依赖项
pip install -e '.[test]'
要运行测试
pytest
项目详情
关闭
files_to_prompt-0.3.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 309ecc23fa7aa1298bbccd86c83fb6d44f9a2ba9f4e2a09dbbea56761899c1cc |
|
MD5 | 9be04e73ab38076f5b710050c9d3e8b0 |
|
BLAKE2b-256 | 84c070c353ae957c8322d7dd9d524c60b8ab4185980fd82a0bab4c460f612b02 |
关闭
files_to_prompt-0.3-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 47492ff2e99883d325c72478ccc05adb19af7edb2abc004de6e99dddeed1ca60 |
|
MD5 | f11607fbb69c9b0ca22a0ea5dc8f3e9c |
|
BLAKE2b-256 | f0c8d538d9076e15235967003be77976ed312be6a697dc384d8b0125e3c481a8 |