Skip to main content

LLM template loader for Latitude - Load prompts from Latitude as LLM templates

Project description

llm-templates-latitude

CI PyPI version codecov

Template loader for LLM that loads prompts from Latitude.

This plugin allows you to use prompts managed in Latitude as templates in LLM, giving you the best of both worlds: centralized prompt management in Latitude and flexible model execution with LLM.

Installation

From PyPI (when published)

llm install llm-templates-latitude

Development Installation with uv

If you want to install from source or contribute to development:

git clone https://github.com/pcaro/llm-templates-latitude
cd llm-templates-latitude
uv sync
uv pip install -e .

Configuration

Set your Latitude API key:

export LATITUDE_API_KEY="your-api-key"

Or configure it using LLM:

llm keys set latitude
# Enter: your-api-key

Usage

Basic Usage

Load a Latitude prompt as a template and use it with any LLM model:

# Use a Latitude prompt with GPT-4
llm -t lat:my-project/welcome-email -m gpt-4 "New user John just signed up"

# Use with Claude
llm -t lat:my-project/blog-writer -m claude-3.5-sonnet -p topic "AI development" "Write an article"

# Use with local models
llm -t lat:code-reviewer -m llama2 < my-code.py

Template Path Formats

# Full format: project-id/prompt-path
llm -t lat:proj-123/marketing/emails/welcome

# Nested paths supported
llm -t lat:my-project/content/blog/technical-writer

# Just prompt path (uses default project)
llm -t lat:welcome-email

With Parameters

If your Latitude prompt has parameters defined, you can override them:

llm -t lat:email-template -p recipient_name "Alice" -p tone "formal" "Meeting cancelled"

Save Templates Locally

You can save Latitude templates locally for faster access:

# Download and save locally
llm -t lat:my-project/summarizer --save my-summarizer

# Use the saved template
llm -t my-summarizer -m gpt-4 "Content to summarize"

Streaming Responses

Templates work with streaming just like regular LLM usage:

llm -t lat:story-writer -m gpt-4 "Once upon a time..." --stream

Template Features

The plugin automatically extracts from your Latitude prompts:

  • Prompt content: Main prompt text with variables
  • System prompts: If defined in Latitude
  • Default parameters: Parameter defaults from Latitude
  • Model recommendations: Suggested model from Latitude
  • Model configuration: Temperature, max tokens, etc.
  • JSON schemas: For structured output prompts

Examples

Content Generation

# Blog post writer
llm -t lat:content/blog-writer -m gpt-4 -p topic "Python packaging" -p audience "developers"

# Email templates
llm -t lat:emails/customer-support -m claude-3 "Customer wants refund"

Code Tasks

# Code review
llm -t lat:dev/code-reviewer -m gpt-4 < pull-request.diff

# Documentation generator
llm -t lat:dev/doc-generator -m claude-3 -p language "Python" < my-function.py

Data Analysis

# Data summarizer
cat data.csv | llm -t lat:analysis/data-summary -m gpt-4

# Report generator
llm -t lat:reports/quarterly -m claude-3 -p quarter "Q4 2023" -p metrics "revenue,users"

Development

This project uses uv for dependency management.

Setup

git clone https://github.com/pcaro/llm-templates-latitude
cd llm-templates-latitude

# Install dependencies and create virtual environment
uv sync

# Install in development mode
uv pip install -e .

Running Tests

# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov=llm_templates_latitude

Code Formatting and Linting

# Format code
uv run black .

# Lint code
uv run ruff check --fix .

# Type checking
uv run mypy llm_templates_latitude.py

Building

# Build distribution packages
uv build

How It Works

  1. Template Request: When you use -t lat:project/prompt, the plugin calls Latitude's API
  2. Template Download: Retrieves the prompt content, system prompt, and configuration
  3. LLM Integration: Creates an LLM template with the downloaded content
  4. Model Execution: LLM processes your input with the chosen model using the Latitude prompt

This gives you:

  • ✅ Centralized prompt management in Latitude
  • ✅ Version control and A/B testing of prompts
  • ✅ Team collaboration on prompts
  • ✅ Flexibility to use any model with LLM
  • ✅ Local caching and offline usage
  • ✅ Integration with LLM's ecosystem (logs, conversations, etc.)

Author

Created by Pablo Caro Revuelta (@pcaro)

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_latitude-0.1.1.tar.gz (83.1 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_latitude-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_templates_latitude-0.1.1.tar.gz
  • Upload date:
  • Size: 83.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for llm_templates_latitude-0.1.1.tar.gz
Algorithm Hash digest
SHA256 793cb13f69c7f4babfb86d8f02721edca14e472515270584358f78912a7dc568
MD5 85b2d91608077b3753f71d09846ee3ef
BLAKE2b-256 09abeec6a79ee89abc51b5dbfed6ddce925bed3917d79448398c402ac528a87e

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_templates_latitude-0.1.1.tar.gz:

Publisher: publish.yml on pcaro/llm-templates-latitude

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for llm_templates_latitude-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4fb86ac7472ecd3d3d6f34984d3c8589579c9f4246bdb1ce6b131f62bab6457
MD5 ce2f80299c4122b93293d84ca0698755
BLAKE2b-256 0bc7e4ab5d63010779d24a3a6d9f13da83b7924c6c9e2fff8f549c8ccad618f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_templates_latitude-0.1.1-py3-none-any.whl:

Publisher: publish.yml on pcaro/llm-templates-latitude

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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