Python SDK for NocturnusAI — a logic-based inference engine and knowledge database
Project description
NocturnusAI Python SDK
Python SDK for NocturnusAI.
The primary use case is context reduction for agent applications:
- ingest raw text or turns
- build a smaller working set
- narrow by goal
- reuse diffs on later turns
Lower-level fact, rule, inference, and memory APIs are still available when you need backend mechanics.
Install
pip install nocturnusai
pip install "nocturnusai[langchain]" # optional LangChain tools
Context-first quick start
from nocturnusai import SyncNocturnusAIClient
with SyncNocturnusAIClient("http://localhost:9300") as client:
ctx = client.ingest_and_optimize(
text="""
user: Customer says they are enterprise and blocked on SLA credits.
tool: CRM says account is Acme Corp with a 2M ARR contract.
tool: Billing note says renewal is due next month.
""",
goals=[{"predicate": "eligible_for_sla", "args": ["acme_corp"]}],
max_facts=12,
session_id="ticket-42",
)
diff = client.diff_context(
session_id="ticket-42",
goals=[{"predicate": "eligible_for_sla", "args": ["acme_corp"]}],
max_facts=12,
)
client.clear_context_session("ticket-42")
print(ctx.total_facts_included, len(diff.added))
Key context methods
context_window()->POST /memory/contextoptimize_context()->POST /context/optimizediff_context()->POST /context/diffsummarize_context()->POST /context/summaryclear_context_session()->POST /context/session/clearingest_and_optimize()-> extract text, assert, then optimize
Lower-level logic methods
from nocturnusai import SyncNocturnusAIClient
with SyncNocturnusAIClient("http://localhost:9300") as client:
client.assert_fact("parent", ["alice", "bob"])
client.assert_rule(
head={"predicate": "grandparent", "args": ["?x", "?z"]},
body=[
{"predicate": "parent", "args": ["?x", "?y"]},
{"predicate": "parent", "args": ["?y", "?z"]},
],
)
print(client.infer("grandparent", ["?who", "bob"]))
LangChain integration
from nocturnusai import SyncNocturnusAIClient
from nocturnusai.langchain import get_nocturnusai_tools
client = SyncNocturnusAIClient("http://localhost:9300")
tools = get_nocturnusai_tools(client)
MCP helper
from nocturnusai.mcp import NocturnusAIMCPClient
async with NocturnusAIMCPClient("http://localhost:9300") as mcp:
await mcp.initialize()
tools = await mcp.list_tools()
result = await mcp.call_tool("context", {"maxFacts": 10, "minSalience": 0.1})
print(result.text)
Start the server
# Docker
docker run -p 9300:9300 ghcr.io/auctalis/nocturnusai:latest
# or installer
curl -fsSL https://raw.githubusercontent.com/Auctalis/nocturnusai/main/install.sh | bash
Docs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nocturnusai-0.2.1.tar.gz
(24.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nocturnusai-0.2.1.tar.gz.
File metadata
- Download URL: nocturnusai-0.2.1.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4e0e6daa51bd67e080add08e4dc28d5102874a3fdfcfb6013423e65a772e716
|
|
| MD5 |
0b55d3e07841e5ddf313864b61226afd
|
|
| BLAKE2b-256 |
2b8fe921deef1992bce975fc1977bc870e7f4fd22319306e8113962075d3aaed
|
File details
Details for the file nocturnusai-0.2.1-py3-none-any.whl.
File metadata
- Download URL: nocturnusai-0.2.1-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a70fc466a6f61b182297c1d29ef503c4ae1978b54c3120dee535be33dfe4a801
|
|
| MD5 |
3707c8d66d4e781943441a13ab930b82
|
|
| BLAKE2b-256 |
518e9c869351bbcc4ede1433d35a474951ccfc8fae8de3c696fed4007c836fb2
|