UltraDebug

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: A C D R G Y M Z X S P
公益项目,接受捐赠
查看: 2346|回复: 0
收起左侧

[Python] 将一个目录中的文件合并成一个更完整的提示文本files-to-prompt

[复制链接]
Thresher

主题

0

回帖

UD

新手上路

UID
26
积分
21
注册时间
2022-2-12
最后登录
1970-1-1
2024-3-31 04:17:29 | 显示全部楼层 |阅读模式

files-to-prompt

将一个装满文件的目录连接到一个提示中,以便与LLM一起使用

安装

使用安装此工具 pip:

pip install files-to-prompt

用法

使用 files-to-prompt, 提供要处理的目录的路径:

files-to-prompt path/to/directory

这将输出目录及其子目录中每个文件的内容,每个文件前面都有其相对路径,并用分隔 ---.

选项

  • --include-hidden: 包括以开头的文件和文件夹 . (隐藏的文件和目录).

    files-to-prompt path/to/directory --include-hidden
  • --ignore-gitignore: Ignore .gitignore files and include all files.

    files-to-prompt path/to/directory --ignore-gitignore

实例

假设您有这样的目录结构:

my_directory/
├── file1.txt
├── file2.txt
├── .hidden_file.txt
└── 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
---
...

例子

要对此工具做出贡献,请首先签出代码。然后创建一个新的虚拟环境:

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

现在安装依赖项和测试依赖项:

pip install -e '.[test]'

运行测试:

pytest

files-to-prompt-main.zip

9 KB, 下载次数: 0, 下载积分: UD -2

UltraDebug免责声明
✅以上内容均来自网友转发或原创,如存在侵权请发送到站方邮件9003554@qq.com处理。
✅The above content is forwarded or original by netizens. If there is infringement, please send the email to the destination 9003554@qq.com handle.
回复 打印

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|站点地图|UltraDebug ( 滇ICP备2022002049号-2 滇公网安备 53032102000034号)

GMT+8, 2025-6-20 15:07 , Processed in 0.033115 second(s), 11 queries , Redis On.

Powered by Discuz X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表