Skip to main content

LangGraph-based runtime for emotionally adaptive AI companions.

Project description

Untamed Companion Runtime

LangGraph-based runtime primitives for emotionally adaptive AI companions.

This package exposes reusable graph builders, SSE event adapters, provider interfaces, store interfaces, prompt overrides, FastAPI routes, deterministic tests, and a local demo showcase. It is product-agnostic by design: application copy, private prompts, production deployment config, billing, and secrets stay outside this repository.

Release Status

This package is a stable 1.0 runtime. The public compatibility surface is the SSE event contract, graph builders, provider/store/prompt protocols, FastAPI route factory, and optional extras documented in this repository. Breaking changes require a future major version.

The FastAPI router is intentionally unauthenticated by default. Production applications must pass auth_hook to create_chat_router(...) and enforce their own ownership, session, API key, or tenant policy.

Install

From source:

git clone https://github.com/wkddns40/untamedai-runtime.git
cd untamedai-runtime
pip install -e ".[fastapi,dev]"

From PyPI:

pip install untamedai-runtime

Optional extras:

pip install "untamedai-runtime[fastapi]"
pip install "untamedai-runtime[openai]"
pip install "untamedai-runtime[supabase]"
pip install "untamedai-runtime[postgres]"

Verify:

python -m pytest

Quickstart

from untamed_companion.graph import GraphRuntime, build_chat_graph
from untamed_companion.providers import FakeLLMProvider

runtime = GraphRuntime(llm_provider=FakeLLMProvider())
graph = build_chat_graph(runtime=runtime)

result = await graph.ainvoke(
    {
        "companion_id": "demo",
        "last_user_message": "your name is Luna",
        "user_lang": "en",
        "companion": {"name": "???"},
    }
)

print(result["emit"])

FastAPI

from fastapi import FastAPI

from untamed_companion.fastapi import ChatRouterSettings, create_chat_router
from untamed_companion.graph import GraphRuntime
from untamed_companion.store import InMemoryCompanionStore

app = FastAPI()
runtime = GraphRuntime(companion_store=InMemoryCompanionStore())
app.include_router(
    create_chat_router(
        runtime=runtime,
        prefix="/api",
        settings=ChatRouterSettings(history_limit_default=20, history_limit_max=50),
    )
)

Routes:

  • GET /api/chat/{companion_id}/history
  • GET /api/chat/{companion_id}/greeting
  • POST /api/chat/{companion_id}/stream

Auth is app-owned. Pass auth_hook to create_chat_router(...) to enforce ownership, sessions, API keys, or any other policy.

Demo Showcase

pip install -e ".[fastapi,dev]"
python examples/demo_showcase/backend/app.py

Open:

http://127.0.0.1:8000/demo

The showcase uses the public FastAPI router, in-memory store, fake providers, scenario presets, SSE event inspector, Korean/English language toggle, reset endpoint, and daily emotion dry-run.

Prompt Override

from untamed_companion.graph import GraphRuntime
from untamed_companion.prompts import StaticPromptProvider

runtime = GraphRuntime(
    prompt_provider=StaticPromptProvider(chat_prompt="Your app-owned prompt.")
)

Event Contract

SSE frames are emitted as JSON in data: lines:

data: {"type": "stream", "content": "Hello"}

Stable event types:

Type Purpose
stream Assistant text chunk or complete deterministic message.
end Stream completion marker. May include final content and intent.
greeting First greeting response.
name_reveal Companion name accepted.
user_name_set User display name accepted.
naming_prompt Runtime asks user to name the companion.
coffee_request Coffee-turn shortcut event.
error Stream failure frame.

Golden fixtures live under tests/golden/fixtures. They compare public event order and payloads with whitespace-tolerant diffs, using only fake providers and in-memory state.

Documentation

Intended Scope

  • LangGraph chat, greeting, and daily emotion graph builders
  • naming ceremony state machine
  • SSE event adapter
  • store/provider interfaces
  • neutral prompt provider with app-owned override support
  • in-memory demo and tests
  • optional FastAPI, OpenAI, Supabase, and Postgres integrations

Out of Scope

  • product frontend
  • private prompts and brand copy
  • production deployment config
  • billing/webhooks
  • service role keys or project-specific environment values

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

untamedai_runtime-1.0.0.tar.gz (50.4 kB view details)

Uploaded Source

Built Distribution

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

untamedai_runtime-1.0.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file untamedai_runtime-1.0.0.tar.gz.

File metadata

  • Download URL: untamedai_runtime-1.0.0.tar.gz
  • Upload date:
  • Size: 50.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for untamedai_runtime-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dbb52e2298477534f1aa4b3ab661531f9398476d89d2f1c29bd40c8cc3ced55f
MD5 616bbd12fa325470d6d875096eba58de
BLAKE2b-256 53865f3b6e1e256e8ddf171e54d57ea36ef8add3b246d42b5d0a856e5bd63218

See more details on using hashes here.

Provenance

The following attestation bundles were made for untamedai_runtime-1.0.0.tar.gz:

Publisher: publish.yml on wkddns40/untamedai-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file untamedai_runtime-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for untamedai_runtime-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd97b95bd719e06738cae65fb27e7dc9fb58a5cb0e3bf38c9fb259919397bd38
MD5 d72b64f0edecbfb283dbe9427f8f9702
BLAKE2b-256 5b5f91a6809ba1a67b53c9b0fb4fc4457f101bab7bdc609178deda09bacea3f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for untamedai_runtime-1.0.0-py3-none-any.whl:

Publisher: publish.yml on wkddns40/untamedai-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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