Skip to main content

Python client for the daimon AI sidecar

Project description

daimon-client

Python client for Daimon — a pluggable AI sidecar runtime.

Installation

pip install daimon-client

Quick start

from daimon_client import Client

with Client(base_url="http://localhost:3500") as c:
    reply = c.chat("claude", "What is a daimon?")
    print(reply)

Async

import asyncio
from daimon_client import AsyncClient

async def main():
    async with AsyncClient(base_url="http://localhost:3500") as c:
        reply = await c.chat("claude", "What is a daimon?")
        print(reply)

asyncio.run(main())

Streaming

with Client() as c:
    for text in c.stream("claude", "Tell me a story."):
        print(text, end="", flush=True)

Multi-turn conversations

Pass a list of messages to carry history yourself:

reply = c.chat("claude", [
    {"role": "user",      "content": "My name is Alice."},
    {"role": "assistant", "content": "Nice to meet you, Alice!"},
    {"role": "user",      "content": "What is my name?"},
])

Sessions

Let the sidecar maintain history server-side with a session_id:

c.chat("claude", "My favourite colour is blue.", session_id="chat-1")
reply = c.chat("claude", "What is my favourite colour?", session_id="chat-1")
# reply contains "blue"

c.clear_session("chat-1")

Inference parameters

All sampling parameters are optional and fall back to the component's configured defaults:

reply = c.chat("gpt4o", "Summarise this.", model="gpt-4o", temperature=0.2, max_tokens=256)

Vector store (memory)

Read and write documents in a configured vector store:

mem = c.memory("my-store")

# Upsert a document (returns the assigned ID)
doc_id = mem.upsert("The Eiffel Tower is 330 metres tall.", id="eiffel", metadata={"source": "wikipedia"})

# Semantic search
results = mem.query("tall Paris structures", top_k=3)
for r in results:
    print(f"{r.score:.3f}  {r.content}")

# Delete
mem.delete("eiffel")

Async vector store

async with AsyncClient() as c:
    mem = c.memory("my-store")
    await mem.upsert("Some content")
    results = await mem.query("my query")

Graph store

Interact with a configured graph database using Cypher:

kg = c.graph("knowledge-graph")

# Add nodes
kg.add_node(id="alice", labels=["Person"], props={"name": "Alice", "age": 30})
kg.add_node(id="bob",   labels=["Person"], props={"name": "Bob"})

# Add a relationship
kg.add_edge("alice", "bob", "KNOWS", props={"since": "2020"})

# Run a Cypher query
rows = kg.cypher(
    "MATCH (a:Person)-[:KNOWS]->(b) RETURN a.name AS from, b.name AS to"
)
print(rows)  # [{"from": "Alice", "to": "Bob"}]

# Delete a node (and all its relationships)
kg.delete_node("alice")

API reference

Client(base_url?, timeout?)

Parameter Default
base_url http://127.0.0.1:3500
timeout 120.0 seconds

Use as a context manager (with Client() as c) or call c.close() manually.

c.chat(component, prompt, **kwargs)str

Returns the full response text.

prompt can be a str or a list of {"role": ..., "content": ...} dicts.

c.stream(component, prompt, **kwargs)Iterator[str]

Yields text fragments as they arrive.

c.clear_session(session_id)None

Deletes server-side session history. Safe to call on a non-existent session.

c.memory(store)MemoryStoreClient

Returns a client scoped to the named vector store.

Method Description
upsert(content, *, id?, metadata?) Insert or update a document. Returns the document ID.
query(query, top_k=5) Semantic search. Returns list[MemoryResult] sorted by descending score.
delete(id) Delete a document by ID.

c.graph(store)GraphStoreClient

Returns a client scoped to the named graph store.

Method Description
add_node(*, id?, labels?, props?) Add or update a node. Returns the node ID.
add_edge(from_id, to_id, rel_type, *, props?) Create a directed relationship.
cypher(query, params?) Run a Cypher query. Returns list[dict].
delete_node(id) Delete a node and all its relationships.

Keyword arguments for chat / stream

Argument Description
model Override the component's default model
system System prompt shorthand
max_tokens
temperature
top_p
top_k Anthropic only
stop List of stop sequences
frequency_penalty
presence_penalty
seed
session_id Server-side session ID

AsyncClient mirrors Client with async def methods and async for streaming.

Links

License

Apache-2.0

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

daimon_client-0.2.9.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

daimon_client-0.2.9-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file daimon_client-0.2.9.tar.gz.

File metadata

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

File hashes

Hashes for daimon_client-0.2.9.tar.gz
Algorithm Hash digest
SHA256 f5cbac4b6849f51b9014116c6d4ed16db2247c7ace8a88faede6894ad7054e5d
MD5 407771871f02e75676f88051a7976433
BLAKE2b-256 6afb6e65318541e39059b3a0a75d0fb8f20fcd7a8a5eb01e2fe926484665e07a

See more details on using hashes here.

Provenance

The following attestation bundles were made for daimon_client-0.2.9.tar.gz:

Publisher: publish-python.yml on sonicboom15/daimon

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

File details

Details for the file daimon_client-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: daimon_client-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for daimon_client-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 cf768ddb0b236d8e88416164538626f4275858fab227d95ccd488a23c7b02dd8
MD5 2b0e5cd996e49b7e4ced13c3331f059b
BLAKE2b-256 1bcf84aa03849bd1bc7ae81f08d6717136c09fe9d52c2a8d3cd8b71d1760492b

See more details on using hashes here.

Provenance

The following attestation bundles were made for daimon_client-0.2.9-py3-none-any.whl:

Publisher: publish-python.yml on sonicboom15/daimon

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