Skip to main content

Documentation Index

Fetch the complete documentation index at: https://ahvn.top/llms.txt

Use this file to discover all available pages before exploring further.

hb.LLM is intentionally stateless. Conversation state lives in the messages you pass to chat or stream, which keeps the LLM client simple and easy to serialize.
messages = [
    {"role": "user", "content": "Remember the code word is hb-ok."},
    {"role": "assistant", "content": "Remembered."},
    {"role": "user", "content": "What is the code word?"},
]

answer = hb.LLM(preset="chat").chat(messages)
This design makes session storage an application concern. Store message lists in a HeavenBase workspace, file, database row, or task object, then pass the list back into chat when you need another turn.

Inspect resolved state

Use spec when you need to see how a client resolved:
llm = hb.LLM(model="ds-flash", provider="deepseek")

print(llm.spec.to_dict())
print(llm.spec.materialize())
spec.to_dict() omits runtime secrets. spec.to_dict(secrets=True) includes the materialized runtime dictionary and should only be used in trusted debugging contexts.

Deterministic spec keys

Resolved specs can produce stable hash keys for deduplication and future response caching:
llm = hb.LLM(model="ds-flash", provider="deepseek")

spec_key = llm.spec.hash_key()
litellm_key = llm.spec.hash_key("litellm")
client_key = llm.spec.client_key()
client_key() includes only the gateway client construction fields, so duplicate LLM instances can reuse the same in-memory OpenAI-compatible SDK client.