Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_prompt_builder-0.0.2.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

code_prompt_builder-0.0.2-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file code_prompt_builder-0.0.2.tar.gz.

File metadata

  • Download URL: code_prompt_builder-0.0.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.6

File hashes

Hashes for code_prompt_builder-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a69389a06b1d7b29ae85d3a20b3eec2471d75e0aa8b9889913e9da1568461fca
MD5 50f85671c781a84e9b7c08532463e2f8
BLAKE2b-256 df88f29c7a26b30f0780c2814d0464ab41a355193e711e061582af5ed71cce01

See more details on using hashes here.

File details

Details for the file code_prompt_builder-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for code_prompt_builder-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9443f7d651b747927043b339d4b856418607a405f897b3cbcd23a410665f773d
MD5 2d41485ff8428b587c7b976313ce64e1
BLAKE2b-256 326dfa21e4a7cb8dbd02796e9f74b144f51b86e3397874a6ce0d7d9673a387bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page