Python SDK
The reference implementation of TrueNorth. All features land in Python first. Supports Python 3.9+.
PyPI package name
Install
truenorth-framework — not truenorth (that's a different package on PyPI).Installation
pip install truenorth-frameworkInitialize
Create an engine with your LLM provider:
from truenorth import TrueNorthEngineengine = TrueNorthEngine( provider="openai", # "openai" | "anthropic" | "gemini" | "ollama" model="gpt-4o-mini", api_key="sk-...", # omit for ollama compliance=["dpdp", "gdpr"] # optional compliance modules)Create a Session
# From a YAML filesession = engine.create_session( yaml_path="agents/medical_intake.yaml", session_id="session_abc123", # optional — auto-generated if omitted metadata={"channel": "whatsapp"} # optional)# Or from an inline dictsession = engine.create_session( schema={ "id": "quick_demo", "fields": [ {"name": "name", "type": "text", "required": True}, {"name": "age", "type": "integer", "range": [0, 120]}, ] })Send a Message
response = await session.send("Hi, I'm Priya and I'm 28")print(response.message) # "Thanks Priya! What is your primary goal?"print(response.extracted) # {"name": "Priya", "age": 28}print(response.pending) # ["goal", "height", "weight"]print(response.cost_usd) # 0.000043print(response.stage) # "field_extraction"print(response.complete) # FalseGet Structured Output
# After session.complete is Trueoutput = session.get_output()print(output.json())# {# "patient_name": "Priya",# "age": 28,# "chief_complaint": "chest pain",# ...# }print(output.fields["age"].confidence) # 0.97print(output.fields["age"].source_turn) # 3print(output.total_cost_usd) # 0.0043print(output.turns) # 9API Reference
| Method | Parameters | Returns |
|---|---|---|
| TrueNorthEngine() | provider, model, api_key, compliance? | Engine |
| engine.create_session() | yaml_path | schema, session_id?, metadata? | Session |
| await session.send() | message: str | TurnResponse |
| session.get_output() | — | SessionOutput |
| session.reset() | — | None |
| session.export_json() | path?: str | dict | None |
| engine.load_template() | name: str, version?: str | YAMLSchema |