Skip to main content

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

Python License Version CI/CD Coverage PyPI Documentation

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)

📚 Full Documentation →

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

User Guides

Architecture & Development

Examples

Research Foundation

Sifaka implements these peer-reviewed techniques:

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

sifaka-0.2.0.tar.gz (185.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sifaka-0.2.0-py3-none-any.whl (226.2 kB view details)

Uploaded Python 3

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

Hashes for sifaka-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1140de131dfea322bfe721d3e21beec767d079cefc8619018d5d04c418364403
MD5 595f6d5e11793af17d0ad45761281541
BLAKE2b-256 85f0ab3b9da1e7c0cc746e6a0488235f2ccb6dcea1cfa53454556cc3558d7cab

See more details on using hashes here.

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

Hashes for sifaka-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f09f9f7e9fb79512cb50037e88c7e58ab90cbb082b30892392a29a29f4cd7888
MD5 effab1143ce0b4b2e6c2beb9fb5ad9e0
BLAKE2b-256 d6c7a39f8b9cd1e271e4f2eca509ca96f4ffefe366e09cfcb68966a4d9e19e21

See more details on using hashes here.

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