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.3.tar.gz
(37.7 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.3.tar.gz.
File metadata
- Download URL: nocturnusai-0.2.3.tar.gz
- Upload date:
- Size: 37.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3b2e6d1d4d0216157f5d5d44a81cf890b92245bcfabe1b836a307dafef091bf
|
|
| MD5 |
7d518291418cfcdf30952ff7fdc1ae13
|
|
| BLAKE2b-256 |
48d51eeefbf30d612e47668b3858313a17fb59fbb1c2a7283c764a455113f44a
|
File details
Details for the file nocturnusai-0.2.3-py3-none-any.whl.
File metadata
- Download URL: nocturnusai-0.2.3-py3-none-any.whl
- Upload date:
- Size: 39.7 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 |
20674f2ae4abc19dd6e6b07ab4c1978e25818bf9923c78d0ba094b396d80ed43
|
|
| MD5 |
2ad393f9315ef935fc2775b9925f861d
|
|
| BLAKE2b-256 |
1c14c0498b804afcc142b5248e3b8ffe76f12e61c5d9ef97b89df4b553fddbe9
|