* Add documentation code validation system - Create runnable example scripts in examples/api/ (19 files) - Add CodeSnippet component for extracting marked sections - Add raw-loader dependency for importing source files - Create sample retain-new.mdx showing new approach - Add README documenting coverage and gaps * Fix wheel glob expansion in test-doc-examples CI job * Fix CI issue * Fix wheel path - uv build outputs to repo root dist/ * Fix: use explicit shell expansion for wheel install * Fix: run cd in subshell so install runs from repo root * Add documentation code validation CI job - Use uv sync + uv run pattern (matches existing CI) - Add requests to test dependencies for cleanup scripts * Fix async API client usage in documents.py example * Fix main-methods.py: RecallResult and ReflectFact don't have weight attribute * Fix opinions.py: use actual API attributes instead of non-existent ones * Fix example scripts: remove non-existent API attributes - recall.py: remove .weight, fix entities iteration (dict not list) - retain.mjs: remove result.async check
52 lines
1.6 KiB
Python
52 lines
1.6 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",
|
|
background="I am a research assistant specializing in machine learning",
|
|
disposition={
|
|
"skepticism": 4,
|
|
"literalism": 3,
|
|
"empathy": 3
|
|
}
|
|
)
|
|
# [/docs:create-bank]
|
|
|
|
|
|
# [docs:bank-background]
|
|
client.create_bank(
|
|
bank_id="financial-advisor",
|
|
background="""I am a conservative financial advisor with 20 years of experience.
|
|
I prioritize capital preservation over aggressive growth.
|
|
I have seen multiple market crashes and believe in diversification."""
|
|
)
|
|
# [/docs:bank-background]
|
|
|
|
|
|
# =============================================================================
|
|
# 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")
|
|
|
|
print("memory-banks.py: All examples passed")
|