67 lines
2.2 KiB
Python
67 lines
2.2 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-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]
|
|
|
|
|
|
# =============================================================================
|
|
# 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")
|
|
|
|
print("memory-banks.py: All examples passed")
|