Skip to main content

Explicit LLM client and router with append-only history and controllable context.

Project description

republic

Release Build status codecov Commit activity License

An explicit LLM client and router with append-only history and controllable context.

Republic has one state primitive: a tape. A tape is an append-only log of messages and anchors. You decide what goes into context, where a phase starts, and how handoff works. No hidden memory.

The idea is inspired by punch tape: a linear, immutable record you can slice into deterministic context windows. It keeps the system simple, auditable, and easy to hand off between humans and agents.

Visit https://getrepublic.org for concepts, guides, and API reference.

  • One entry point (LLM) with predictable behavior
  • Tape-first state with explicit anchors and selection
  • Provider-agnostic routing, retries, and fallbacks
  • Typed tools with optional execution
  • Streaming-first ergonomics
  • Clear extension points for storage and observability

We like LitAI's pragmatic feel. Republic is derived from it, and we hope you like it too.

This project is derived from lightning-ai/litai.

Requirements

  • Python 3.11+

Installation

pip install republic
# Or, with uv
uv add republic

Quick Start

import os

from republic import LLM

llm = LLM(
    model="openrouter:openrouter/free",
    api_key=os.environ["LLM_API_KEY"],
    client_args={
        "default_headers": {
            "HTTP-Referer": "https://getrepublic.org",
            "X-Title": "republic docs",
        }
    },
)

print(llm.chat("Give me a one-sentence overview of Republic."))

notes = llm.tape("notes")
print(notes("Remember this for later."))
print(notes.messages())

for chunk in llm.chat.stream("Write a 5-word line about light."):
    print(chunk, end="")

Tool calling requires a tool-capable model. See the docs for tool examples and model guidance.

Development

See CONTRIBUTING.md for local setup, testing, and release guidance.

License

Apache 2.0

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

republic-0.2.0.tar.gz (108.8 kB view details)

Uploaded Source

Built Distribution

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

republic-0.2.0-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file republic-0.2.0.tar.gz.

File metadata

  • Download URL: republic-0.2.0.tar.gz
  • Upload date:
  • Size: 108.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for republic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2a3399647e953f3fcc8eba0bd8d9b489ddb90ca46d2d321400822ad96451f02e
MD5 c44e9486f354323a5e996645999a0e21
BLAKE2b-256 fe415c04b7748094d314349e2915f2e76847027a136059855d94f41171baa2c3

See more details on using hashes here.

File details

Details for the file republic-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: republic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for republic-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f1ad9a973447fc1b32b2cc0520b4f701d92c4df3bd2a47826389631d1232750
MD5 bec44cfd31e14829d3f1fc636aaf5420
BLAKE2b-256 65e551366d2fa357a65298a528770cf43a3204bd9de56391069e76ed73d065c8

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