fleet-memory/hindsight-docs/examples/api/memory-banks.py
Nicolò Boschi 1bf90358c3
doc: add blog (#201)
* doc: introduce mental models blog post

Write blog post introducing Mental Models in Hindsight 0.4.0:
- Evolution from observations and opinions
- How mental models work (consolidation, evidence tracking)
- Breaking changes and migration path
- Environment variable to enable (experimental)
- Agentic reflect explanation

* updates

* Update 2026-01-26-learning-capabilities.md

* fix: doc build issues

- Add missing code snippets for versioned docs (recall-opinions-only, recall-include-entities, bank-background)
- Fix broken links by using relative paths for version compatibility
- Update blog post title to sentence case
- Clear versions.json since v0.3 versioned docs don't exist yet
- Enable INCLUDE_CURRENT_VERSION in build script

* fix: update doc links after rebase

- Fix blog post to link to correct pages (/developer/api/mental-models and /developer/observations)
- Fix CLI docs to link to /api-reference instead of /api

* feat: add directives section to blog post

- Update intro to mention three layers of knowledge
- Add concise Directives section for compliance/guardrails
- Add directives to resources section
- Keep focus on learning capabilities (observations and mental models)

* fix: revert intro to focus on learning capabilities only

Directives are a separate feature for compliance/guardrails, not a learning capability. The blog post is about observations and mental models.
2026-01-28 15:42:14 +01:00

88 lines
2.9 KiB
Python

#!/usr/bin/env python3
"""
Memory Banks API examples for Hindsight.
Run: python examples/api/memory-banks.py
"""
import os
import requests
HINDSIGHT_URL = os.getenv("HINDSIGHT_API_URL", "http://localhost:8888")
# =============================================================================
# Setup (not shown in docs)
# =============================================================================
from hindsight_client import Hindsight
client = Hindsight(base_url=HINDSIGHT_URL)
# =============================================================================
# Doc Examples
# =============================================================================
# [docs:create-bank]
client.create_bank(
bank_id="my-bank",
name="Research Assistant",
mission="You're a research assistant specializing in machine learning - keep track of papers, methods, and findings.",
disposition={
"skepticism": 4,
"literalism": 3,
"empathy": 3
}
)
# [/docs:create-bank]
# [docs:bank-mission]
client.create_bank(
bank_id="financial-advisor",
name="Financial Advisor",
mission="""You're a conservative financial advisor - keep track of client risk tolerance,
investment preferences, and market conditions. Prioritize capital preservation over growth."""
)
# [/docs:bank-mission]
# [docs:bank-background]
# Legacy snippet for v0.3 docs (background renamed to mission in v0.4)
client.create_bank(
bank_id="legacy-bank",
name="Legacy Example",
mission="""I'm a personal assistant helping a software engineer. I should track their
project preferences, coding style, and technology choices."""
)
# [/docs:bank-background]
# [docs:bank-with-disposition]
client.create_bank(
bank_id="architect-bank",
mission="You're a senior software architect - keep track of system designs, "
"technology decisions, and architectural patterns. Prefer simplicity over cutting-edge.",
disposition={
"skepticism": 4, # Questions new technologies
"literalism": 4, # Focuses on concrete specs
"empathy": 2 # Prioritizes technical facts
}
)
# [/docs:bank-with-disposition]
# [docs:bank-support-agent]
client.create_bank(
bank_id="support-agent",
mission="You're a customer support agent - keep track of "
"customer preferences, past issues, and communication styles."
)
# [/docs:bank-support-agent]
# =============================================================================
# Cleanup (not shown in docs)
# =============================================================================
requests.delete(f"{HINDSIGHT_URL}/v1/default/banks/my-bank")
requests.delete(f"{HINDSIGHT_URL}/v1/default/banks/financial-advisor")
requests.delete(f"{HINDSIGHT_URL}/v1/default/banks/architect-bank")
requests.delete(f"{HINDSIGHT_URL}/v1/default/banks/support-agent")
print("memory-banks.py: All examples passed")