3.8 KiB
3.8 KiB
| sidebar_position |
|---|
| 0 |
Quick Start
Get up and running with Hindsight in 60 seconds.
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Installation
The hindsight-all package includes everything you need: embedded PostgreSQL, HTTP API server, and Python client.
pip install hindsight-all
If you already have a Hindsight server running, install just the client:
pip install hindsight-client
Basic Usage
import os
from hindsight import HindsightServer, HindsightClient
# Start embedded server (PostgreSQL + HTTP API)
with HindsightServer(
llm_provider="openai",
llm_model="gpt-4.1-mini",
llm_api_key=os.environ["OPENAI_API_KEY"]
) as server:
client = HindsightClient(base_url=server.url)
# Store memories
client.put(agent_id="my-agent", content="Alice works at Google")
client.put(agent_id="my-agent", content="Bob prefers Python over JavaScript")
# Search memories
results = client.search(agent_id="my-agent", query="What does Alice do?")
for r in results:
print(r["text"])
# Generate response with personality
response = client.think(agent_id="my-agent", query="Tell me about Alice")
print(response["text"])
from hindsight_client import Hindsight
client = Hindsight(base_url="http://localhost:8888")
# Store memories
client.put(agent_id="my-agent", content="Alice works at Google")
client.put(agent_id="my-agent", content="Bob prefers Python over JavaScript")
# Search memories
results = client.search(agent_id="my-agent", query="What does Alice do?")
for r in results:
print(r["text"])
# Generate response with personality
response = client.think(agent_id="my-agent", query="Tell me about Alice")
print(response["text"])
What's Happening
- Store — Content is processed, facts are extracted, and entities are linked in a knowledge graph
- Search — Four search strategies (semantic, keyword, graph, temporal) run in parallel and results are fused
- Think — Retrieved memories are used to generate a personality-aware response
Server Options
When using HindsightServer, you can configure:
from hindsight import HindsightServer
server = HindsightServer(
# Database
db_url="pg0", # "pg0" for embedded PostgreSQL, or a connection URL
# LLM Configuration
llm_provider="openai", # "openai", "groq", or "ollama"
llm_api_key="your-api-key",
llm_model="gpt-4.1-mini",
llm_base_url=None, # Custom endpoint (for ollama or proxies)
# Server
host="127.0.0.1",
port=None, # Auto-select free port if None
mcp_enabled=False, # Enable MCP API
)
server.start()
print(f"Server running at {server.url}")
# ... use server ...
server.stop()
Environment Variables
For production, use environment variables:
export OPENAI_API_KEY=sk-...
# or
export GROQ_API_KEY=gsk_...
import os
from hindsight import HindsightServer, HindsightClient
with HindsightServer(
llm_provider="openai",
llm_api_key=os.environ["OPENAI_API_KEY"],
llm_model="gpt-4.1-mini"
) as server:
client = HindsightClient(base_url=server.url)
# ...
Next Steps
- Ingest Data — Store memories, conversations, and documents
- Search Facts — Multi-strategy retrieval
- Think — Personality-aware response generation
- Agent Identity — Configure agent personality and background