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 local

# Assuming your on this repository cloned in your computer.
cat README.md | llm -t "fsspec:file://$(pwd)/demo/template-demo.yaml"

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.1.tar.gz (3.9 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.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llm_templates_fsspec-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1f1f23c6ebeda3390fc9d745f3b719649b7b0dd329750e05c3ee84ee50504afc
MD5 0b99d64ea1093e2e34e377c5af6563e5
BLAKE2b-256 9ec3e9c9b8ef7d318b34f25eae92a7de1b036f213e981c6e9ade1069681a8517

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llm_templates_fsspec-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b1b1992f81506e23563f2a49acf6473fa92ea094a62323262e28a530950e42c
MD5 214e05168e33ff40581393f9d0b8b22c
BLAKE2b-256 bc936dec706d7e074d6ccd963590f5bcb449c961fa89536cf3c43620ecba47b8

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