Skip to main content

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.

Features

  • Code base formatting:

    • Traverse a directory tree while respecting .gitignore rules.
    • Format the directory structure and file contents into a readable markdown format.
    • Clone a git repository and format its contents.
  • Convert web pages to markdown format

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.

llm-components format-codebase <root_dir_or_repo>

You can also convert a web page to markdown using the CLI:

llm-components web-to-markdown <url>

Example

# For a local directory
llm-components format-codebase /path/to/your/code/base

# For a git repository
llm-components format-codebase https://github.com/your/repo.git

# For a web page
llm-components web-to-markdown https://advanced-stack.com

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.

import tempfile
from pathlib import Path
from llm_components.loaders.code_base import map_codebase_to_text
from llm_components.loaders.git_utils import clone_repository
from llm_components.loaders.web_to_markdown import retrieve_and_convert

# 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)

# For a web page
url = "https://example.com"
markdown_content = retrieve_and_convert(url)
print(markdown_content)

License

This project is licensed under the MIT License.

Release files for llm-components 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-components 1.3.2
File Size Uploaded
llm_components-1.3.2.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-components 1.3.2
File Interpreter ABI Platform
llm_components-1.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / llm_components-1.3.2.tar.gz

Download URL llm_components-1.3.2.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
416c05b07371620867df351fa99d05fe0f84f4f4194c6e55f698e827a019315f
BLAKE2b-256 checksum
How to use checksums
c2262b963dcfc7ec598a3e4d7f76d92de71652f70cb68920fb1ad5b421801ad3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / llm_components-1.3.2-py3-none-any.whl

Download URL llm_components-1.3.2-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9d8f7d6a0116bd196b6687efb9f5b0b855e6b243c5d4874d6a1c89c055540b3
BLAKE2b-256 checksum
How to use checksums
44434c4d90f604dbcd6dccea0df8b912905960f444725c29b1c21d999e30c8ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.3.2 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page