# LogiLLM
**Program language models with structured inputs and outputs, built for production.**
LogiLLM lets you define what you want from an LLM using Python signatures, then handles prompt engineering, output parsing, and optimization automatically.
## Quick Example
```python
from logillm.core.predict import Predict
from logillm.providers import create_provider, register_provider
# Setup (one time)
provider = create_provider("openai")
register_provider(provider, set_default=True)
# Define what you want
analyzer = Predict("text -> sentiment: str")
# Use it
result = await analyzer(text="I love this new feature!")
print(result.sentiment) # "positive"
```
Instead of crafting prompts and parsing responses, you specify the input/output structure. LogiLLM handles the rest.
## What You Can Build
**📧 Smart Email Processing** - Classify, extract entities, determine urgency
**📝 Document Generation** - Create structured reports from data
**🤖 Reasoning Agents** - Multi-step analysis with external tool integration
**🎮 Interactive Systems** - Games, chatbots, personalized experiences
**💾 Persistent AI** - Systems that remember and learn from interactions
## Key Features
- **🎯 Structured I/O** - Type-safe inputs and outputs with automatic validation
- **⚡ Zero Dependencies** - Core library uses only Python standard library
- **🚀 Production Ready** - Full async support, comprehensive error handling, observability
- **🔧 Auto-Optimization** - Improve performance by optimizing prompts AND hyperparameters
- **💾 Built-in Persistence** - Save and load optimized models instantly
- **📊 JSONL Logging** - Track optimization runs with complete reproducibility
- **🔍 Complete Debug Logging** - Capture full request/response data from LLM APIs
## Installation
```bash
# Core library
pip install logillm
# With LLM providers
pip install logillm[openai] # For GPT models
pip install logillm[anthropic] # For Claude models
```
## Learning Path
### 📚 Complete Documentation
- **[Getting Started Guide](docs/tutorials/getting-started.md)** - Personalized tutorial recommendations
- **[Tutorial Matrix](docs/tutorials/tutorial-matrix.md)** - Difficulty levels and time estimates
- **[Tutorial Examples](examples/tutorials/)** - Complete working code for all tutorials
**→ [Full Tutorial Index](docs/tutorials/README.md)** - 6 complete tutorials from beginner to advanced
## Working Examples
### Basic Classification
```python
# Classify text into categories
classifier = Predict("text -> category: str")
result = await classifier(text="I need help with my billing account")
print(result.category) # "Billing"
```
### Multi-Output Prediction
```python
# Get multiple outputs in one call
analyzer = Predict("text -> sentiment: str, confidence: float")
result = await analyzer(text="This product is amazing!")
print(result.sentiment) # "positive"
print(result.confidence) # 0.97
```
### Complex Type Support (New!)
```python
# Work with lists, dictionaries, and optional types
extractor = Predict("document: str -> entities: dict[str, list[str]], summary: Optional[str]")
result = await extractor(document="Apple Inc. announced iPhone 15 in Cupertino.")
print(result.entities) # {"companies": ["Apple Inc."], "products": ["iPhone 15"], "locations": ["Cupertino"]}
# Use Union types with pipe syntax
processor = Predict("data: str | bytes -> processed: bool, format: str")
```
### Multimodal Capabilities (New!)
```python
from logillm.core.signatures.types import Image, Audio, Tool
# Vision analysis
vision = Predict("image: Image -> description: str, objects: list[str], confidence: float")
result = await vision(image=Image.from_path("photo.jpg"))
print(result.objects) # ["person", "laptop", "coffee"]
# Audio processing
transcriber = Predict("audio: Audio -> transcript: str, language: str")
result = await transcriber(audio=Audio.from_url("https://example.com/speech.mp3"))
# Tool/Function calling
tool_agent = Predict("query: str -> tool_calls: list[Tool], explanation: str")
```
### Structured Signatures with Field Validation (Enhanced!)
```python
from logillm.core.signatures import Signature, InputField, OutputField
class TextAnalysis(Signature):
# Required and optional fields with defaults
text: str = InputField(description="Text to analyze")
max_length: int = InputField(default=100, description="Maximum response length")
# Output fields with type hints
category: str = OutputField(description="Category like support, sales, billing")
priority: int = OutputField(description="Priority 1-5 where 5 is most urgent")
entities: list[str] = OutputField(description="Named entities found")
analyzer = Predict(signature=TextAnalysis)
result = await analyzer(text="My account is locked and I cannot access my files")
# Automatically validates inputs and outputs against field specifications
print(result.category) # "Account Access"
print(result.priority) # 1
```
## Production Features
### Multiple Providers
```python
# Set up multiple LLM providers
openai_provider = create_provider("openai", model="gpt-4.1")
register_provider(openai_provider, "fast")
# Use the registered provider (becomes default)
result = await Predict("text -> summary: str")(text="Long document to summarize...")
print(result.summary) # "This document discusses..."
```
### Optimization (requires training data)
```python
# Optimize performance on your data
from logillm.optimizers import HybridOptimizer
from logillm.core.optimizers import AccuracyMetric
# Your labeled training examples
training_data = [
{"inputs": {"text": "Great service!"}, "outputs": {"sentiment": "positive"}},
{"inputs": {"text": "Poor quality"}, "outputs": {"sentiment": "negative"}},
# ... more examples
]
# Optimize both prompts and hyperparameters
classifier = Predict("text -> sentiment: str")
optimizer = HybridOptimizer(metric=AccuracyMetric(key="sentiment"))
result = await optimizer.optimize(module=classifier, dataset=training_data)
# Save optimized model
result.optimized_module.save("sentiment_model.json")
# Load in production
classifier = Predict.load("sentiment_model.json")
```
### Optimizer Comparison
LogiLLM provides a comprehensive suite of optimizers, each designed for different optimization scenarios:
| Optimizer | Type | What it Optimizes | Best For | Key Features |
|-----------|------|-------------------|----------|--------------|
| **HybridOptimizer** ⭐ | Hybrid | Prompts + Hyperparameters | Production systems | LogiLLM's killer feature - simultaneous optimization |
| **SIMBA** | Hybrid | Hyperparameters + Demos | Complex tasks | Introspective rule generation with mini-batches |
| **MIPROv2** | Prompt | Instructions + Demos | Multi-stage optimization | Bayesian optimization with multi-objective support |
| **COPRO** | Prompt | Instructions | Instruction refinement | Breadth-first search with temperature control |
| **BootstrapFewShot** | Prompt | Few-shot examples | Learning from data | Teacher-student demonstration generation |
| **KNNFewShot** | Prompt | Example selection | Dynamic examples | Semantic similarity-based selection |
| **FormatOptimizer** | Prompt | Output format | Format discovery | Tests JSON vs XML vs Markdown |
| **InstructionOptimizer** | Prompt | Task instructions | Instruction clarity | LLM-based instruction generation |
| **LabeledFewShot** | Prompt | Hand-crafted examples | Baseline comparison | Traditional few-shot approach |
| **HyperparameterOptimizer** | Hyperparameter | Temperature, top_p, etc. | Parameter tuning | Bayesian, Grid, Random search |
| **AvatarOptimizer** | Ensemble | Multiple personas | Complex reasoning | Multi-perspective ensemble |
| **ReflectiveEvolution** | Prompt | Execution traces | Self-improvement | LLM reflection on past runs |
| **MultiObjective** | Hybrid | Multiple metrics | Trade-off optimization | Balance accuracy, cost, latency |
### Optimizer Taxonomy
```mermaid
graph LR
subgraph "Prompt Optimizers"
direction TB
P1[BootstrapFewShot<br/>📚 Teacher-Student Learning]
P2[COPRO<br/>🔄 Instruction Refinement]
P3[KNNFewShot<br/>🎯 Semantic Selection]
P4[FormatOptimizer<br/>📝 JSON/XML/Markdown]
P5[InstructionOptimizer<br/>💡 LLM Generation]
P6[LabeledFewShot<br/>✋ Manual Examples]
end
subgraph "Hyperparameter Optimizers"
direction TB
H1[HyperparameterOptimizer<br/>🎛️ Bayesian Search]
H2[GridSearch<br/>📊 Systematic]
H3[RandomSearch<br/>🎲 Stochastic]
end
subgraph "Hybrid Optimizers"
direction TB
Y1[HybridOptimizer ⭐<br/>🚀 Prompts + Params]
Y2[SIMBA<br/>🧠 Rules + Params]
Y3[MIPROv2<br/>🔀 Multi-stage Pipeline]
Y4[MultiObjective<br/>⚖️ Balance Metrics]
end
subgraph "Specialized"
direction TB
S1[AvatarOptimizer<br/>👥 Multi-persona]
S2[ReflectiveEvolution<br/>🔍 Self-improvement]
end
style Y1 fill:#f96,stroke:#333,stroke-width:3px
style Y2 fill:#fcc,stroke:#333,stroke-width:2px
style Y3 fill:#fcc,stroke:#333,stroke-width:2px
```
### Optimization Workflow
```mermaid
graph LR
A[📊 Training Data] --> B{Choose Optimizer}
B -->|Simple Task| C[Prompt Only]
B -->|Parameter Tuning| D[Hyperparameter Only]
B -->|Best Results| E[Hybrid Strategy ⭐]
E --> F{Select Strategy}
F -->|Alternating| G[Prompts → Params → Repeat]
F -->|Joint| H[Simultaneous Optimization]
F -->|Sequential| I[Params → Then Prompts]
C --> J[Evaluate Performance]
D --> J
G --> J
H --> J
I --> J
J --> K{Good Enough?}
K -->|No| L[Adjust & Retry]
K -->|Yes| M[💾 Save Model]
L --> B
M --> N[🚀 Deploy to Production]
N --> O[Load & Use]
O --> P[Monitor Performance]
style E fill:#f96,stroke:#333,stroke-width:3px
style M fill:#9f9,stroke:#333,stroke-width:2px
style N fill:#9f9,stroke:#333,stroke-width:2px
```
### Choosing the Right Optimizer
**For most use cases:** Start with `HybridOptimizer` - it optimizes both prompts and hyperparameters:
```python
optimizer = HybridOptimizer(
metric=your_metric,
strategy="alternating" # or "joint", "sequential"
)
```
**For specific scenarios:**
- **Limited training data?** → Use `LabeledFewShot` with hand-crafted examples
- **Need dynamic examples?** → Use `KNNFewShot` for semantic similarity selection
- **Complex multi-step tasks?** → Use `MIPROv2` for sophisticated pipeline optimization
- **Want to understand why it works?** → Use `SIMBA` for introspective rule generation
- **Multiple competing objectives?** → Use `MultiObjective` to balance trade-offs
### JSONL Logging for Optimization Tracking
```python
# Track and analyze optimization runs
from logillm.core.jsonl_logger import OptimizationLogger
logger = OptimizationLogger(filepath="optimization.jsonl")
result = await logger.log_optimization(
optimizer=optimizer,
module=classifier,
dataset=training_data,
validation_set=validation_data
)
# Analyze the log
import json
with open("optimization.jsonl") as f:
events = [json.loads(line) for line in f]
# See score progression, hyperparameters, prompts, and more
for event in events:
if event['event_type'] == 'evaluation_end':
print(f"Score: {event['score']:.2%}")
```
**[→ Full JSONL Logging Documentation](docs/features/jsonl-logging.md)**
## Why LogiLLM?
**Coming from prompt engineering?** Stop writing brittle string templates. Define structured inputs/outputs and let LogiLLM handle prompt construction.
**Coming from dspy?** Get better performance through hybrid optimization (prompts + hyperparameters), zero-dependency deployment, and more modern Python standards.
**Building production systems?** Native async support, comprehensive error handling, automatic retries, and observability built-in.
## What's Different from DSPy?
- **Hybrid Optimization** - Optimize both prompts AND hyperparameters simultaneously
- **Zero Dependencies** - Core framework uses only Python standard library
- **Production First** - Built for scaling, monitoring, and maintenance from day one
- **Type Safety** - Full Pydantic integration with IDE support
- **Modern Python** - Async/await throughout, Python 3.9+ features
## Getting Help
- **📚 [Start with Tutorials](docs/tutorials/README.md)** - 6 hands-on tutorials, 15-40 minutes each
- **🤔 [Getting Started Guide](docs/tutorials/getting-started.md)** - Personalized recommendations
- **⚡ [Quick Examples](examples/tutorials/)** - Working code for common patterns
- **🐛 Issues** - Report bugs or request features on GitHub
---
**Ready to build?** Start with the **[LLM Text Generation tutorial](docs/tutorials/llms-txt-generation.md)** (15 minutes) or browse **[all tutorials](docs/tutorials/README.md)** to find your perfect starting point.
Raw data
{
"_id": null,
"home_page": null,
"name": "logillm",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "ai, dspy-inspired, language-models, llm, machine-learning, optimization, prompt-engineering",
"author": null,
"author_email": "Michael Bommarito <michael.bommarito@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d1/7d/9f1dde5118e4b183d22fdd4ba091682d381e563c8df9cae19ad31dbd8240/logillm-0.2.17.tar.gz",
"platform": null,
"description": "# LogiLLM\n\n**Program language models with structured inputs and outputs, built for production.**\n\nLogiLLM lets you define what you want from an LLM using Python signatures, then handles prompt engineering, output parsing, and optimization automatically.\n\n## Quick Example\n\n```python\nfrom logillm.core.predict import Predict\nfrom logillm.providers import create_provider, register_provider\n\n# Setup (one time)\nprovider = create_provider(\"openai\")\nregister_provider(provider, set_default=True)\n\n# Define what you want\nanalyzer = Predict(\"text -> sentiment: str\")\n\n# Use it\nresult = await analyzer(text=\"I love this new feature!\")\nprint(result.sentiment) # \"positive\"\n```\n\nInstead of crafting prompts and parsing responses, you specify the input/output structure. LogiLLM handles the rest.\n\n## What You Can Build\n\n**\ud83d\udce7 Smart Email Processing** - Classify, extract entities, determine urgency \n**\ud83d\udcdd Document Generation** - Create structured reports from data \n**\ud83e\udd16 Reasoning Agents** - Multi-step analysis with external tool integration \n**\ud83c\udfae Interactive Systems** - Games, chatbots, personalized experiences \n**\ud83d\udcbe Persistent AI** - Systems that remember and learn from interactions\n\n## Key Features\n\n- **\ud83c\udfaf Structured I/O** - Type-safe inputs and outputs with automatic validation\n- **\u26a1 Zero Dependencies** - Core library uses only Python standard library\n- **\ud83d\ude80 Production Ready** - Full async support, comprehensive error handling, observability\n- **\ud83d\udd27 Auto-Optimization** - Improve performance by optimizing prompts AND hyperparameters\n- **\ud83d\udcbe Built-in Persistence** - Save and load optimized models instantly\n- **\ud83d\udcca JSONL Logging** - Track optimization runs with complete reproducibility\n- **\ud83d\udd0d Complete Debug Logging** - Capture full request/response data from LLM APIs\n\n## Installation\n\n```bash\n# Core library \npip install logillm\n\n# With LLM providers\npip install logillm[openai] # For GPT models\npip install logillm[anthropic] # For Claude models\n```\n\n## Learning Path\n\n### \ud83d\udcda Complete Documentation\n- **[Getting Started Guide](docs/tutorials/getting-started.md)** - Personalized tutorial recommendations\n- **[Tutorial Matrix](docs/tutorials/tutorial-matrix.md)** - Difficulty levels and time estimates \n- **[Tutorial Examples](examples/tutorials/)** - Complete working code for all tutorials\n\n**\u2192 [Full Tutorial Index](docs/tutorials/README.md)** - 6 complete tutorials from beginner to advanced\n\n## Working Examples\n\n### Basic Classification\n```python\n# Classify text into categories\nclassifier = Predict(\"text -> category: str\")\nresult = await classifier(text=\"I need help with my billing account\")\nprint(result.category) # \"Billing\"\n```\n\n### Multi-Output Prediction\n```python\n# Get multiple outputs in one call\nanalyzer = Predict(\"text -> sentiment: str, confidence: float\")\nresult = await analyzer(text=\"This product is amazing!\")\nprint(result.sentiment) # \"positive\" \nprint(result.confidence) # 0.97\n```\n\n### Complex Type Support (New!)\n```python\n# Work with lists, dictionaries, and optional types\nextractor = Predict(\"document: str -> entities: dict[str, list[str]], summary: Optional[str]\")\nresult = await extractor(document=\"Apple Inc. announced iPhone 15 in Cupertino.\")\nprint(result.entities) # {\"companies\": [\"Apple Inc.\"], \"products\": [\"iPhone 15\"], \"locations\": [\"Cupertino\"]}\n\n# Use Union types with pipe syntax\nprocessor = Predict(\"data: str | bytes -> processed: bool, format: str\")\n```\n\n### Multimodal Capabilities (New!)\n```python\nfrom logillm.core.signatures.types import Image, Audio, Tool\n\n# Vision analysis\nvision = Predict(\"image: Image -> description: str, objects: list[str], confidence: float\")\nresult = await vision(image=Image.from_path(\"photo.jpg\"))\nprint(result.objects) # [\"person\", \"laptop\", \"coffee\"]\n\n# Audio processing\ntranscriber = Predict(\"audio: Audio -> transcript: str, language: str\")\nresult = await transcriber(audio=Audio.from_url(\"https://example.com/speech.mp3\"))\n\n# Tool/Function calling\ntool_agent = Predict(\"query: str -> tool_calls: list[Tool], explanation: str\")\n```\n\n### Structured Signatures with Field Validation (Enhanced!)\n```python\nfrom logillm.core.signatures import Signature, InputField, OutputField\n\nclass TextAnalysis(Signature):\n # Required and optional fields with defaults\n text: str = InputField(description=\"Text to analyze\")\n max_length: int = InputField(default=100, description=\"Maximum response length\")\n \n # Output fields with type hints\n category: str = OutputField(description=\"Category like support, sales, billing\")\n priority: int = OutputField(description=\"Priority 1-5 where 5 is most urgent\")\n entities: list[str] = OutputField(description=\"Named entities found\")\n\nanalyzer = Predict(signature=TextAnalysis)\nresult = await analyzer(text=\"My account is locked and I cannot access my files\")\n# Automatically validates inputs and outputs against field specifications\nprint(result.category) # \"Account Access\"\nprint(result.priority) # 1\n```\n\n## Production Features\n\n### Multiple Providers\n```python\n# Set up multiple LLM providers \nopenai_provider = create_provider(\"openai\", model=\"gpt-4.1\")\nregister_provider(openai_provider, \"fast\")\n\n# Use the registered provider (becomes default)\nresult = await Predict(\"text -> summary: str\")(text=\"Long document to summarize...\")\nprint(result.summary) # \"This document discusses...\"\n```\n\n### Optimization (requires training data)\n```python\n# Optimize performance on your data\nfrom logillm.optimizers import HybridOptimizer\nfrom logillm.core.optimizers import AccuracyMetric\n\n# Your labeled training examples\ntraining_data = [\n {\"inputs\": {\"text\": \"Great service!\"}, \"outputs\": {\"sentiment\": \"positive\"}},\n {\"inputs\": {\"text\": \"Poor quality\"}, \"outputs\": {\"sentiment\": \"negative\"}},\n # ... more examples\n]\n\n# Optimize both prompts and hyperparameters \nclassifier = Predict(\"text -> sentiment: str\")\noptimizer = HybridOptimizer(metric=AccuracyMetric(key=\"sentiment\"))\nresult = await optimizer.optimize(module=classifier, dataset=training_data)\n\n# Save optimized model\nresult.optimized_module.save(\"sentiment_model.json\")\n\n# Load in production\nclassifier = Predict.load(\"sentiment_model.json\")\n```\n\n### Optimizer Comparison\n\nLogiLLM provides a comprehensive suite of optimizers, each designed for different optimization scenarios:\n\n| Optimizer | Type | What it Optimizes | Best For | Key Features |\n|-----------|------|-------------------|----------|--------------|\n| **HybridOptimizer** \u2b50 | Hybrid | Prompts + Hyperparameters | Production systems | LogiLLM's killer feature - simultaneous optimization |\n| **SIMBA** | Hybrid | Hyperparameters + Demos | Complex tasks | Introspective rule generation with mini-batches |\n| **MIPROv2** | Prompt | Instructions + Demos | Multi-stage optimization | Bayesian optimization with multi-objective support |\n| **COPRO** | Prompt | Instructions | Instruction refinement | Breadth-first search with temperature control |\n| **BootstrapFewShot** | Prompt | Few-shot examples | Learning from data | Teacher-student demonstration generation |\n| **KNNFewShot** | Prompt | Example selection | Dynamic examples | Semantic similarity-based selection |\n| **FormatOptimizer** | Prompt | Output format | Format discovery | Tests JSON vs XML vs Markdown |\n| **InstructionOptimizer** | Prompt | Task instructions | Instruction clarity | LLM-based instruction generation |\n| **LabeledFewShot** | Prompt | Hand-crafted examples | Baseline comparison | Traditional few-shot approach |\n| **HyperparameterOptimizer** | Hyperparameter | Temperature, top_p, etc. | Parameter tuning | Bayesian, Grid, Random search |\n| **AvatarOptimizer** | Ensemble | Multiple personas | Complex reasoning | Multi-perspective ensemble |\n| **ReflectiveEvolution** | Prompt | Execution traces | Self-improvement | LLM reflection on past runs |\n| **MultiObjective** | Hybrid | Multiple metrics | Trade-off optimization | Balance accuracy, cost, latency |\n\n### Optimizer Taxonomy\n\n```mermaid\ngraph LR\n subgraph \"Prompt Optimizers\"\n direction TB\n P1[BootstrapFewShot<br/>\ud83d\udcda Teacher-Student Learning]\n P2[COPRO<br/>\ud83d\udd04 Instruction Refinement]\n P3[KNNFewShot<br/>\ud83c\udfaf Semantic Selection]\n P4[FormatOptimizer<br/>\ud83d\udcdd JSON/XML/Markdown]\n P5[InstructionOptimizer<br/>\ud83d\udca1 LLM Generation]\n P6[LabeledFewShot<br/>\u270b Manual Examples]\n end\n \n subgraph \"Hyperparameter Optimizers\"\n direction TB\n H1[HyperparameterOptimizer<br/>\ud83c\udf9b\ufe0f Bayesian Search]\n H2[GridSearch<br/>\ud83d\udcca Systematic]\n H3[RandomSearch<br/>\ud83c\udfb2 Stochastic]\n end\n \n subgraph \"Hybrid Optimizers\"\n direction TB\n Y1[HybridOptimizer \u2b50<br/>\ud83d\ude80 Prompts + Params]\n Y2[SIMBA<br/>\ud83e\udde0 Rules + Params]\n Y3[MIPROv2<br/>\ud83d\udd00 Multi-stage Pipeline]\n Y4[MultiObjective<br/>\u2696\ufe0f Balance Metrics]\n end\n \n subgraph \"Specialized\"\n direction TB\n S1[AvatarOptimizer<br/>\ud83d\udc65 Multi-persona]\n S2[ReflectiveEvolution<br/>\ud83d\udd0d Self-improvement]\n end\n \n style Y1 fill:#f96,stroke:#333,stroke-width:3px\n style Y2 fill:#fcc,stroke:#333,stroke-width:2px\n style Y3 fill:#fcc,stroke:#333,stroke-width:2px\n```\n\n### Optimization Workflow\n\n```mermaid\ngraph LR\n A[\ud83d\udcca Training Data] --> B{Choose Optimizer}\n B -->|Simple Task| C[Prompt Only]\n B -->|Parameter Tuning| D[Hyperparameter Only]\n B -->|Best Results| E[Hybrid Strategy \u2b50]\n \n E --> F{Select Strategy}\n F -->|Alternating| G[Prompts \u2192 Params \u2192 Repeat]\n F -->|Joint| H[Simultaneous Optimization]\n F -->|Sequential| I[Params \u2192 Then Prompts]\n \n C --> J[Evaluate Performance]\n D --> J\n G --> J\n H --> J\n I --> J\n \n J --> K{Good Enough?}\n K -->|No| L[Adjust & Retry]\n K -->|Yes| M[\ud83d\udcbe Save Model]\n \n L --> B\n M --> N[\ud83d\ude80 Deploy to Production]\n \n N --> O[Load & Use]\n O --> P[Monitor Performance]\n \n style E fill:#f96,stroke:#333,stroke-width:3px\n style M fill:#9f9,stroke:#333,stroke-width:2px\n style N fill:#9f9,stroke:#333,stroke-width:2px\n```\n\n### Choosing the Right Optimizer\n\n**For most use cases:** Start with `HybridOptimizer` - it optimizes both prompts and hyperparameters:\n```python\noptimizer = HybridOptimizer(\n metric=your_metric,\n strategy=\"alternating\" # or \"joint\", \"sequential\"\n)\n```\n\n**For specific scenarios:**\n- **Limited training data?** \u2192 Use `LabeledFewShot` with hand-crafted examples\n- **Need dynamic examples?** \u2192 Use `KNNFewShot` for semantic similarity selection\n- **Complex multi-step tasks?** \u2192 Use `MIPROv2` for sophisticated pipeline optimization\n- **Want to understand why it works?** \u2192 Use `SIMBA` for introspective rule generation\n- **Multiple competing objectives?** \u2192 Use `MultiObjective` to balance trade-offs\n\n### JSONL Logging for Optimization Tracking\n```python\n# Track and analyze optimization runs\nfrom logillm.core.jsonl_logger import OptimizationLogger\n\nlogger = OptimizationLogger(filepath=\"optimization.jsonl\")\nresult = await logger.log_optimization(\n optimizer=optimizer,\n module=classifier,\n dataset=training_data,\n validation_set=validation_data\n)\n\n# Analyze the log\nimport json\nwith open(\"optimization.jsonl\") as f:\n events = [json.loads(line) for line in f]\n \n# See score progression, hyperparameters, prompts, and more\nfor event in events:\n if event['event_type'] == 'evaluation_end':\n print(f\"Score: {event['score']:.2%}\")\n```\n\n**[\u2192 Full JSONL Logging Documentation](docs/features/jsonl-logging.md)**\n\n## Why LogiLLM?\n\n**Coming from prompt engineering?** Stop writing brittle string templates. Define structured inputs/outputs and let LogiLLM handle prompt construction.\n\n**Coming from dspy?** Get better performance through hybrid optimization (prompts + hyperparameters), zero-dependency deployment, and more modern Python standards.\n\n**Building production systems?** Native async support, comprehensive error handling, automatic retries, and observability built-in.\n\n## What's Different from DSPy?\n\n- **Hybrid Optimization** - Optimize both prompts AND hyperparameters simultaneously \n- **Zero Dependencies** - Core framework uses only Python standard library\n- **Production First** - Built for scaling, monitoring, and maintenance from day one\n- **Type Safety** - Full Pydantic integration with IDE support\n- **Modern Python** - Async/await throughout, Python 3.9+ features\n\n## Getting Help\n\n- **\ud83d\udcda [Start with Tutorials](docs/tutorials/README.md)** - 6 hands-on tutorials, 15-40 minutes each\n- **\ud83e\udd14 [Getting Started Guide](docs/tutorials/getting-started.md)** - Personalized recommendations \n- **\u26a1 [Quick Examples](examples/tutorials/)** - Working code for common patterns\n- **\ud83d\udc1b Issues** - Report bugs or request features on GitHub\n\n---\n\n**Ready to build?** Start with the **[LLM Text Generation tutorial](docs/tutorials/llms-txt-generation.md)** (15 minutes) or browse **[all tutorials](docs/tutorials/README.md)** to find your perfect starting point.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A generic, high-performance, low-dependency LLM programming framework inspired by dspy",
"version": "0.2.17",
"project_urls": {
"Documentation": "https://michaelbommarito.com/",
"Homepage": "https://github.com/mjbommar/logillm",
"Issues": "https://github.com/mjbommar/logillm/issues",
"Repository": "https://github.com/mjbommar/logillm"
},
"split_keywords": [
"ai",
" dspy-inspired",
" language-models",
" llm",
" machine-learning",
" optimization",
" prompt-engineering"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e09be8a09b70de2857c6712deb816f00861a342b682839139b6d3749342c2d49",
"md5": "a934b6c823fa187d58972eaa4f85ee05",
"sha256": "b68d004436bacfaeabe3af0af18d1c9101cdf7c4a9d8e8865ef3c685ad0c5a02"
},
"downloads": -1,
"filename": "logillm-0.2.17-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a934b6c823fa187d58972eaa4f85ee05",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 281648,
"upload_time": "2025-09-04T03:11:56",
"upload_time_iso_8601": "2025-09-04T03:11:56.468389Z",
"url": "https://files.pythonhosted.org/packages/e0/9b/e8a09b70de2857c6712deb816f00861a342b682839139b6d3749342c2d49/logillm-0.2.17-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d17d9f1dde5118e4b183d22fdd4ba091682d381e563c8df9cae19ad31dbd8240",
"md5": "cdd702ef9372bb8e03759411429f5566",
"sha256": "e55c3cb27eba6d2151fa3b844a6d2a37e2783d41ed72d0f5926229d04f590fa1"
},
"downloads": -1,
"filename": "logillm-0.2.17.tar.gz",
"has_sig": false,
"md5_digest": "cdd702ef9372bb8e03759411429f5566",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 473164,
"upload_time": "2025-09-04T03:11:58",
"upload_time_iso_8601": "2025-09-04T03:11:58.069750Z",
"url": "https://files.pythonhosted.org/packages/d1/7d/9f1dde5118e4b183d22fdd4ba091682d381e563c8df9cae19ad31dbd8240/logillm-0.2.17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-04 03:11:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mjbommar",
"github_project": "logillm",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "logillm"
}