Universal tools for prompt engineering and LLM interactions.
Project description
🔧 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_suite-0.2.1.tar.gz.
File metadata
- Download URL: llm_suite-0.2.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edccd8fe1db190d4d7ded3a2741f0617f2e4592c0193be5ef10703fee96c7f37
|
|
| MD5 |
ed2451ddc41da2c872b44d071aecc961
|
|
| BLAKE2b-256 |
b3afe243351c7596b6b8f158bf52ee52be8fe2a097e6cab9a91ad4683b5934d4
|
File details
Details for the file llm_suite-0.2.1-py3-none-any.whl.
File metadata
- Download URL: llm_suite-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2064bddc9ebb7363a826e27f9e061b25a69261819ceefae3f7e7a7e9bd90e02
|
|
| MD5 |
9cbdc8ce4889a81a46d37736ad8eb304
|
|
| BLAKE2b-256 |
152e76ba38512728c17e08dbacdabb225886827c7e41c36ffb6816d4e594af1f
|