Skip to main content

Load LLM templates from local paths and cloud storage (S3, GCS, Azure) using any supported fsspec URL scheme.

Project description

llm-templates-fsspec

Load LLM templates from local paths and cloud storage (S3, GCS, Azure) using any supported fsspec URL scheme.

Lear more about Filesystem Spec (fsspec) and it's features in https://filesystem-spec.readthedocs.io/

Installation

Install this plugin in the same environment as LLM.

llm install llm-templates-fsspec

or add it along your project if using a environment manager like poetry or uv

# with Poetry
poetry add llm llm-templates-fsspec
# with UV
uv add llm llm-templates-fsspec

Usage

Load templates from local filesystem

llm -t fsspec:file:///home/user/templates/summary.yaml

Load templates from AWS S3

# Configure AWS credentials first
export AWS_ACCESS_KEY_ID=your-key
export AWS_SECRET_ACCESS_KEY=your-secret

llm -t fsspec:s3://my-bucket/templates/analyze.yaml

Load templates from Google Cloud Storage

# Configure GCP credentials
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json

llm -t fsspec:gs://my-bucket/templates/review.yaml

Load templates from Azure Blob Storage

# Configure Azure credentials
export AZURE_STORAGE_ACCOUNT_NAME=myaccount
export AZURE_STORAGE_ACCOUNT_KEY=mykey

llm -t fsspec:az://my-container/templates/report.yaml

Load templates from HTTP/HTTPS

llm -t fsspec:https://example.com/templates/chatbot.yaml

Load templates from FTP

llm -t fsspec:ftp://ftp.example.com/templates/assistant.yaml

Why fsspec?

The llm-templates-fsspec plugin leverages the robust fsspec library to provide:

  • Universal Access: Single interface for templates stored anywhere - local files, S3, GCS, Azure, FTP, HTTP, and more built-in implementations
  • Production Ready: Battle-tested library used by pandas, dask, and other major data tools
  • Credential Management: Integrates with standard credential chains (AWS CLI, gcloud, environment variables)
  • Caching: Built-in caching support for remote templates to improve performance
  • Extensibility: Support for new storage backends

Examples

Using templates from a private S3 bucket

# Template in private bucket with AWS CLI credentials configured
curl https://example.com/data.json | \
  llm -t fsspec:s3://private-bucket/templates/analyze-json.yaml

Caching remote templates locally

# Set cache directory for better performance with remote templates
export LLM_TEMPLATES_FSSPEC_CACHE_DIR=/tmp/llm-template-cache

# First run downloads and caches the template
llm -t fsspec:https://raw.githubusercontent.com/org/repo/main/template.yaml "Analyze this"

# Subsequent runs use the cached versio
llm -t fsspec:https://raw.githubusercontent.com/org/repo/main/template.yaml "Analyze that"

Using templates from a corporate GCS bucket

# With service account key file
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
llm -t fsspec:gs://company-ai-assets/templates/legal-review.yaml < contract.txt

Loading templates with custom storage options

# Pass additional storage options via environment variable
export LLM_TEMPLATES_FSSPEC_STORAGE_OPTIONS='{"client_kwargs": {"region_name": "eu-west-1"}}'
llm -t fsspec:s3://eu-bucket/templates/gdpr-check.yaml

Configuration

Environment Variables

  • LLM_TEMPLATES_FSSPEC_CACHE_DIR: Directory for caching remote templates (optional)
  • LLM_TEMPLATES_FSSPEC_STORAGE_OPTIONS: JSON string of additional fsspec storage options (optional)

Credential Configuration

This plugin uses standard credential chains for each cloud provider:

  • AWS S3: AWS CLI configuration, environment variables, or IAM roles
  • Google Cloud Storage: Application default credentials or service account key file
  • Azure Blob Storage: Environment variables or Azure CLI credentials

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment using UV

cd llm-templates-fsspec
uv venv
uv sync
source venv/bin/activate

Now install the dependencies and test dependencies:

llm install -e '.[test]'

To run the tests:

pytest

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

Apache 2.0

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

llm_templates_fsspec-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_templates_fsspec-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file llm_templates_fsspec-0.1.0.tar.gz.

File metadata

File hashes

Hashes for llm_templates_fsspec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 305524831a023ea480b09ee0ea2bce69699c63f5828bfaa42fbcefc4c4c3732d
MD5 e202f80691b4cc60c29056442748db19
BLAKE2b-256 90f11bbdba706fb8d7ab59f3cdac7ca825cb5b3353ec878f6e9e1da46fc3d3f8

See more details on using hashes here.

File details

Details for the file llm_templates_fsspec-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_templates_fsspec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab245d28bc0bf9beb2ca4fe032ca2ec8a3c0559a16ceb3164688777acddfcb72
MD5 f940654d773071bc2c935f07543e512b
BLAKE2b-256 a919aca82506166c059d426d7013b4f6a90bc1c23a6a597d3e52e020a458d396

See more details on using hashes here.

Supported by

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