Builds plaintext code prompts for Large Language Models (LLMs) from code bases, suitable for code analysis and assistance.
Project description
code-prompt-builder
A lightweight Python library to construct plain-text code prompts from your code bases, designed for use with Large Language Models (LLMs) in code analysis and assistance tasks.
Description
code-prompt-builder
simplifies the process of feeding code to your LLM. It reads files from your project, optionally filtering by file types and directories, and structures them into a single string suitable for LLM input.
This makes it easy to ask LLMs to analyze your code, identify potential issues, or even generate code suggestions.
Installation
pip install code-prompt-builder
Usage
Here's a simple example of using code-prompt-builder:
from code_prompt_builder.utils import build_code_prompt
# Specify directories containing your code
repo_dir_paths = ["path/to/your/code/directory"]
# Create the code prompt
code_prompt = build_code_prompt(repo_dir_paths=repo_dir_paths)
# Now you can use 'code_prompt' as input to your LLM
print(code_prompt)
Function Parameters
repo_tree_paths
: A list of root directory paths to walk through and collect files.repo_dir_paths
: A list of directories to read files from directly (no recursive walk).repo_file_paths
: A list of specific files to include.include_file_regex
: (Optional) A regular expression to include only matching files.exclude_file_regex
: (Optional) A regular expression to exclude matching files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file code_prompt_builder-0.0.3.tar.gz
.
File metadata
- Download URL: code_prompt_builder-0.0.3.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b1f6810005cb38927bf60b53dd3f9531d939be923d6022f678f513a7ed089b9 |
|
MD5 | 9d0a5d302c1a686a21206f8fdb7a704e |
|
BLAKE2b-256 | 2553993879cf4db03f42dc7bf229f94b28969c03c1916934076939ed990b60e3 |
File details
Details for the file code_prompt_builder-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: code_prompt_builder-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 778f20816a37b950327811104e6fdde037f5c2b25a1f5f01bc150aee6f160312 |
|
MD5 | 69fd1fb0c47671b468b23b25c002a155 |
|
BLAKE2b-256 | 47ee9f4da64d2b19be02984f0df2ff7fc5a5d19f60e57b7baf0f29d80fa4c77d |