Simple AI text improvement through research-backed critique with complete observability
Project description
Sifaka
Simple AI text improvement through research-backed critique with complete observability
What is Sifaka?
Sifaka improves AI-generated text through iterative critique using research-backed techniques. Instead of hoping your AI output is good enough, Sifaka provides a transparent feedback loop where AI systems validate and improve their own outputs.
Core Value: See exactly how AI improves your text through research-backed techniques with complete audit trails.
Installation
# Install from PyPI
pip install sifaka
# Or with uv
uv pip install sifaka
Quick Start
1. Set up your API key
Sifaka requires an LLM API key. Set one of these environment variables:
export OPENAI_API_KEY="your-api-key" # For OpenAI (GPT-4, etc.)
# or
export ANTHROPIC_API_KEY="your-api-key" # For Claude
# or
export GEMINI_API_KEY="your-api-key" # For Google Gemini
# or
export GROQ_API_KEY="your-api-key" # For Groq
# or (for local Ollama - no API key needed)
export OLLAMA_BASE_URL="http://localhost:11434/v1" # Optional, defaults to localhost
Or create a .env file in your project:
OPENAI_API_KEY=your-api-key
Using Ollama (Local LLMs):
from sifaka import improve_sync, Config
from sifaka.core.config import LLMConfig
# Use Ollama with specific model (must set critic_model too!)
config = Config(
llm=LLMConfig(
provider="ollama",
model="mistral:latest",
critic_model="mistral:latest" # Important: set this to use Ollama for critiques
)
)
result = improve_sync("Climate change is bad.", config=config)
2. Use Sifaka
from sifaka import improve_sync
# Simple one-liner
result = improve_sync("Climate change is bad.")
print(result.final_text)
Key Features
- 🔬 Research-Backed: Implements Reflexion, Constitutional AI, Self-Refine, and more
- 👁️ Complete Observability: Full audit trail of every improvement
- 🎯 Simple API: One function does everything you need
- 💾 Memory-Safe: Bounded history prevents memory leaks
- ⚡ Fast: Minimal dependencies, maximum performance
Documentation
Getting Started
- Installation - Installation options and setup
- Quickstart Guide - Get up and running in 5 minutes
- Basic Usage - Common usage patterns
- API Reference - Complete API documentation
User Guides
- Critics Guide - Available critics and usage
- Validators Guide - Input validation options
- Configuration - Configuration options
- Advanced Usage - Advanced patterns
Architecture & Development
- Architecture Overview - System design
- Contributing - How to contribute
- Changelog - Version history
Examples
- Working Examples - Code examples for all features
Research Foundation
Sifaka implements these peer-reviewed techniques:
- Reflexion - Self-reflection for iterative improvement
- Constitutional AI - Principle-based evaluation
- Self-Refine - Iterative self-improvement
- N-Critics - Ensemble of diverse perspectives
- Self-RAG - Retrieval-augmented critique
- Meta-Rewarding - Two-stage meta-evaluation
- Self-Consistency - Multiple reasoning paths
- Self-Taught Evaluator - Contrasting outputs with reasoning traces
- Agent4Debate - Multi-agent competitive debate dynamics
- Style - Transform text to match specific writing styles and voices
- Prompt - Simple prompt-engineered critic for simple use cases
Development
git clone https://github.com/sifaka-ai/sifaka
cd sifaka
pip install -e ".[dev]"
pytest
See CONTRIBUTING.md for development guidelines.
License
MIT License - see LICENSE file for details.
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
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 sifaka-0.2.0.tar.gz.
File metadata
- Download URL: sifaka-0.2.0.tar.gz
- Upload date:
- Size: 185.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1140de131dfea322bfe721d3e21beec767d079cefc8619018d5d04c418364403
|
|
| MD5 |
595f6d5e11793af17d0ad45761281541
|
|
| BLAKE2b-256 |
85f0ab3b9da1e7c0cc746e6a0488235f2ccb6dcea1cfa53454556cc3558d7cab
|
File details
Details for the file sifaka-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sifaka-0.2.0-py3-none-any.whl
- Upload date:
- Size: 226.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f09f9f7e9fb79512cb50037e88c7e58ab90cbb082b30892392a29a29f4cd7888
|
|
| MD5 |
effab1143ce0b4b2e6c2beb9fb5ad9e0
|
|
| BLAKE2b-256 |
d6c7a39f8b9cd1e271e4f2eca509ca96f4ffefe366e09cfcb68966a4d9e19e21
|