Skip to main content

Python SDK for the Sigil persona registry - inject personas into LLM system prompts

Project description

sigil-agent

Python SDK for the Sigil persona registry. Pull personas and inject them into LLM system prompts.

Installation

pip install sigil-agent

Quick Start

from sigil import SigilClient

# Initialize client
client = SigilClient(api_key="sk_...", base_url="https://api.sigil.l8ntlabs.com")

# Fetch a persona
persona = client.get("staccato")

# Inject into system prompt
system_prompt = persona.inject()

# Or combine with a base prompt
system_prompt = persona.inject(base="You are a helpful assistant.")

Usage

Fetching Personas

from sigil import SigilClient

client = SigilClient(api_key="sk_...")

# Get latest version
persona = client.get("staccato")

# Pin a specific version
persona = client.get("staccato", version="1.0.0")

Accessing Persona Fields

persona = client.get("staccato")

# Core fields
print(persona.name)      # "staccato"
print(persona.version)   # "1.0.0"
print(persona.soul)      # The full soul/system text

# Voice configuration
print(persona.voice.tone)      # ["direct", "clear"]
print(persona.voice.dos)       # ["Be brief", ...]
print(persona.voice.donts)     # ["Ramble", ...]

# Values (sorted by priority)
for value in persona.values:
    print(f"{value.name}: {value.description} (priority: {value.priority})")

# Behavioral map
for key, behavior in persona.behavioral_map.items():
    print(f"{key}: {behavior.posture}")

Injecting into Prompts

The inject() method composes a well-formatted system prompt:

# Basic injection
system_prompt = persona.inject()

# With a base prompt prepended
system_prompt = persona.inject(base="You are an AI assistant for Acme Corp.")

The inject method combines:

  1. Base prompt (if provided)
  2. Soul text
  3. Voice rules (tone, dos, donts, example phrases)
  4. Values (sorted by priority)
  5. Behavioral guidelines

Configuration

Environment Variables

export SIGIL_API_KEY="sk_..."
export SIGIL_BASE_URL="https://api.sigil.l8ntlabs.com"
# Client will use env vars if not provided
client = SigilClient()

Client Options

client = SigilClient(
    api_key="sk_...",           # Required (or SIGIL_API_KEY env var)
    base_url="http://...",       # Default: http://localhost:8100
    timeout=10,                  # Request timeout in seconds
)

Error Handling

from sigil import SigilClient, SigilError, SigilNotFoundError, SigilAuthError

client = SigilClient(api_key="sk_...")

try:
    persona = client.get("nonexistent")
except SigilNotFoundError:
    print("Persona not found")
except SigilAuthError:
    print("Invalid API key")
except SigilError as e:
    print(f"API error: {e.message} (status: {e.status_code})")

Development

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy sigil

# Linting
ruff check sigil tests

License

MIT

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

sigil_agent-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

sigil_agent-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file sigil_agent-0.1.0.tar.gz.

File metadata

  • Download URL: sigil_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for sigil_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 14335bfde68d5952038ef87ced6800165cb7dbf52df8f33f1ee17f5721599562
MD5 913b3be62cf0a2274213c665ff11fc51
BLAKE2b-256 91135b4edbfc0b7e12742af0cd643c39c1f0b3914c8d3f0effa0c80dc4036c53

See more details on using hashes here.

File details

Details for the file sigil_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sigil_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for sigil_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0110d48ba8e1499bc1f166f22524c06cde9e5cacf2efe1a6e04d3d48cde8364f
MD5 832ee9f14216f558332a5b6304738164
BLAKE2b-256 6bdfce8df9ffdb72095e2fa0329378b43c699f5082de876771ff67ae29a79a58

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