Skip to content

sdk

diapason.sdk

High-level Python SDK for Diapason.

Diapason

High-level Diapason SDK.

Usage::

from diapason import Diapason

with Diapason() as j:
    response = j.ask("Hello, what can you do?")
    print(response)

# Streaming:
import asyncio

async def main():
    j = Diapason()
    async for token in j.ask_stream("Tell me a joke"):
        print(token, end="", flush=True)
    j.close()

asyncio.run(main())

# Or without context manager:
j = Diapason()
response = j.ask("Hello")
j.close()

config property

Return the active configuration.

version property

Return the Diapason version string.

ask(query, *, model=None, agent=None, tools=None, temperature=None, max_tokens=None, context=True, channel=None)

Send a query and return the response text.

ask_full(query, *, model=None, agent=None, tools=None, temperature=None, max_tokens=None, context=True, channel=None)

Send a query and return the full result dict.

Returns a dict with keys: content, usage, tool_results (if agent mode).

ask_full_stream(query, *, model=None, temperature=None, max_tokens=None, context=True) async

Stream token dicts with metadata.

Yields dicts with token and index keys for each token. The final dict has done: True along with the full concatenated content, model, and engine keys.

ask_stream(query, *, model=None, temperature=None, max_tokens=None, context=True) async

Stream tokens as they are generated. Yields token strings.

close()

Release all resources.

list_engines()

Return a list of registered engine keys.

list_models()

Return a list of available model identifiers.

DiapasonSystem dataclass

Fully wired system -- the single source of truth for primitive composition.

act(command)

Execute an explicit low-risk desktop command without inference.

Unlike ask(), this method deliberately authorizes the deterministic action path. Ambiguous or disallowed commands still fall back to the normal configured assistant.

close()

Release resources.

wire_channel(channel_bridge)

Register a message handler on channel_bridge that routes every incoming message through this system (agent or engine) and replies.

Sessions are isolated per "<channel>:<conversation_id>" key so each chat retains its own history.

Parameters

channel_bridge: A connected :class:~diapason.channels._stubs.BaseChannel instance whose on_message method accepts a callable.

MemoryHandle

Proxy for memory operations. Lazily initializes backend.

close()

Release the memory backend.

index(path, *, chunk_size=512, chunk_overlap=64)

Index a file or directory into memory.

search(query, *, top_k=5)

Search memory for relevant chunks.

stats()

Return memory backend statistics.

SystemBuilder

Config-driven fluent builder for DiapasonSystem.

build()

Construct a fully wired DiapasonSystem.

engine_instance(engine, key='openai-compat')

Inject a pre-built engine instance, bypassing engine discovery.

Used by callers that must target one exact endpoint (e.g. diapason eval --base-url). build() health-checks the instance and raises a loud error if it is unreachable — it never silently substitutes a different discovered engine.