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.1.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.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sigil_agent-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 5ed002610a8a0b90196dfa4014594e3ecb0e6ae27795625de6cbb070f4443a33
MD5 7a4e9afbb3f3f36332984f2a4fa96e43
BLAKE2b-256 6934de436d212a442b898e2b1ae1c96dcb90e1ff5da71a763f39b13cb955f47b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sigil_agent-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b567b4cc74bad7a36a18e5998f458d1b29c8310a4ca54e096deee28d21580be
MD5 5c049e58abd7405ac643bb50d96c74d1
BLAKE2b-256 6c0e06aa8ed54a91c3fc8d983f94a6f2bebc6c41ebbda41b61722e36a173cfc0

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