A library of ready-to-use LLM components
Project description
LLM Components
Overview
llm-components
is a Python library designed to feed large language models with data from different sources. The library formats content in a structured markdown format.
The first data source implemented is a code base (a folder containing a gitignore file).
Features
- Traverse a directory tree while respecting
.gitignore
rules. - Format the directory structure and file contents into a readable markdown format.
- Command-line interface for easy usage.
- Clone a git repository and format its contents.
Installation
To install the llm-components
library, you can use pip:
pip install llm-components
Usage
Command-Line Interface
You can use the command-line interface to map a code base to markdown. The CLI takes the root directory of the code base or a git repository URL as an argument.
format-codebase <root_dir_or_repo>
Example
# For a local directory
format-codebase /path/to/your/code/base
# For a git repository
format-codebase https://github.com/your/repo.git
This will output the directory structure and file contents in a structured markdown format.
Programmatic Usage
You can also use the library programmatically by importing the necessary functions.
from pathlib import Path
from llm_components.loaders.code_base import map_codebase_to_text
from llm_components.loaders.git_utils import clone_repository
# For a local directory
root_dir = Path("/path/to/your/code/base")
result = map_codebase_to_text(root_dir)
print(result)
# For a git repository
repo_url = "https://github.com/your/repo.git"
with tempfile.TemporaryDirectory() as temp_dir:
clone_dir = Path(temp_dir) / "repo"
clone_repository(repo_url, clone_dir)
result = map_codebase_to_text(clone_dir)
print(result)
License
This project is licensed under the MIT License.
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
Built Distribution
Hashes for llm_components-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4431866c3aa92a53aa50711c9f770097707ac36261b97458f0c7bb6506abbb96 |
|
MD5 | b66713268aebc1f63f501109af916785 |
|
BLAKE2b-256 | ac8e88eba2f0a315ffabaa95bcdad69a0046d2d270e7d8cc35ff58ddfc68f3d9 |