Skip to main content

🔧 LLM Suite

A Python package for streamlined interactions with various Large Language Model (LLM) providers, featuring structured output parsing and template-based prompt management.

Features

  • 🤖 Multi-Provider Support: Compatible with OpenAI, Anthropic, Ollama, Groq, Perplexity, and LMStudio
  • 📋 Structured Output: Parse LLM responses directly into Pydantic models
  • 📝 Template Management: Organize and reuse prompts with Jinja2 templating
  • ⚙️ Configurable: Easily adjust model parameters and settings

🔧 LLM Suite

A Python package for streamlined interactions with various Large Language Model (LLM) providers, featuring structured output parsing and template-based prompt management.

Features

  • 🤖 Multi-Provider Support: Compatible with OpenAI, Anthropic, Ollama, Groq, Perplexity, Together, and LMStudio
  • 📋 Structured Output: Parse LLM responses directly into Pydantic models using Instructor
  • 📝 Template Management: Organize and reuse prompts with Jinja2 templating
  • 🖼️ Image Support: Send images to vision-enabled models
  • ⚙️ Configurable: Easily adjust model parameters and settings
  • 🔄 CLI Tool: Built-in command line interface for quick interactions

Getting Started

Install the package using pip:

pip install llm-suite

Alternatively, install from the source:

git clone https://github.com/mmysior/llm-suite.git
cd llm-suite
pip install -e .

Configuration

Configuration is handled through environment variables. Copy the .env.example file to .env and update with your API keys:

# LLM settings
DEFAULT_PROVIDER="openai"
DEFAULT_MODEL="gpt-4.1-mini"

DEFAULT_TEMPERATURE=0.7
DEFAULT_TOP_P=1.0
DEFAULT_MAX_TOKENS=2048

# Provider-specific settings
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here
PERPLEXITY_API_KEY=your_perplexity_key_here
GROQ_API_KEY=your_groq_key_here
TOGETHER_API_KEY=your_together_key_here
TOGETHER_API_KEY=

OLLAMA_BASE_URL=
LMSTUDIO_BASE_URL=

Usage

Basic Usage

import llmsuite

# Initialize a chat model
llm = llmsuite.init_chat_model()  # Uses DEFAULT_PROVIDER and DEFAULT_MODEL from .env
# Or specify explicitly
llm = llmsuite.init_chat_model(provider="anthropic", model="claude-3-opus-20240229")

# Simple conversation
messages = llm.build_messages(
    text="Explain quantum computing briefly", 
    system_prompt="You are a helpful assistant."
)
response = llm.chat(messages)
print(response)

Structured Output with Pydantic

from pydantic import BaseModel

class MovieRecommendation(BaseModel):
    title: str
    year: int
    why: str

messages = llm.build_messages(
    text="Recommend a sci-fi movie", 
    system_prompt="You recommend movies."
)
result = llm.extract(
    messages=messages,
    schema=MovieRecommendation
)
print(f"Title: {result.title}, Year: {result.year}")

Working with Images

from pathlib import Path

# Send an image to a vision model
messages = llm.build_messages(
    text="What's in this image?",
    image_path=Path("path/to/image.jpg")
)
response = llm.chat(messages)

Prompt Templates

from llmsuite import get_prompt

# Get a prompt template from your templates directory
prompt = get_prompt("my_template")

# Render the template with variables
rendered_prompt = prompt.compile(variable1="value1", variable2="value2")

# Use the rendered prompt
messages = llm.build_messages(text="Query", system_prompt=rendered_prompt)
response = llm.chat(messages)

Creating Prompt Templates

Create Jinja2 templates with YAML frontmatter metadata:

---
type: system
version: 1
author: Your Name
labels: 
    - classification
    - sentiment
tags:
    - example
config:
    temperature: 0.1
    model: gpt-4
---
You are a sentiment analyzer that classifies text as positive, negative, or neutral.

Please analyze the following text:
{{ text }}

Command Line Interface

LLM Suite includes a CLI tool:

# Simple chat
llmsuite chat "What is the capital of France?"

# Using specific model and provider
llmsuite chat "Explain relativity" --model gpt-4 --provider openai --temperature 0.2

# View current configuration
llmsuite config

Advanced Configuration

For more control, you can customize model parameters:

response = llm.chat(
    messages=messages,
    temperature=0.2,
    max_tokens=500
)

License

MIT

Metadata

Release files for llm-suite 0.2.1

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-suite 0.2.1
File Size Uploaded Provenance
llm_suite-0.2.1.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-suite 0.2.1
File Interpreter ABI Platform
llm_suite-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.7 kB

Release files / llm_suite-0.2.1.tar.gz

Download URL llm_suite-0.2.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
edccd8fe1db190d4d7ded3a2741f0617f2e4592c0193be5ef10703fee96c7f37
BLAKE2b-256 checksum
How to use checksums
b3afe243351c7596b6b8f158bf52ee52be8fe2a097e6cab9a91ad4683b5934d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release files / llm_suite-0.2.1-py3-none-any.whl

Download URL llm_suite-0.2.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2064bddc9ebb7363a826e27f9e061b25a69261819ceefae3f7e7a7e9bd90e02
BLAKE2b-256 checksum
How to use checksums
152e76ba38512728c17e08dbacdabb225886827c7e41c36ffb6816d4e594af1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Security for llm-suite 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

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