快速开始
本指南将引导你完成 Hindsight Cloud 账户的设置,并创建你的第一个记忆库。
前置条件
- 一个 Hindsight Cloud 账户(在 ui.hindsight.vectorize.io 注册)
- 对 REST API 有基本了解,或熟悉 Python/TypeScript
第 1 步:注册并登录
- 访问 ui.hindsight.vectorize.io
- 点击 Sign Up 创建账户
- 验证你的邮箱地址
- 登录以进入仪表盘
第 2 步:创建组织
首次登录时,系统会提示你创建一个组织。组织是所有资源的顶层容器:
- 记忆库
- 团队成员
- API 密钥
- 账单信息
输入组织名称,然后点击 Create。
第 3 步:创建你的第一个记忆库
- 在仪表盘中点击 Create Memory Bank
- 为记忆库输入名称(例如 "My AI Assistant")
第 4 步:获取 API 密钥
- 点击顶部导航栏的 Connect 按钮
- 点击 Create API Key
- 为密钥起一个有描述性的名称
- 选择过期时间(或选择 "Never")
- 重要:立即复制你的 API 密钥——它不会再次显示!
第 5 步:发起你的第一次 API 调用
- Python
- TypeScript
- cURL
pip install hindsight-client
from hindsight_client import Hindsight
client = Hindsight(
base_url="https://api.hindsight.vectorize.io",
api_key="your-api-key"
)
# Create a memory bank
bank = client.create_bank(
bank_id="my-assistant",
name="My Assistant"
)
# Store a memory
client.retain(
bank_id="my-assistant",
content="The user's name is Alice and she prefers Python."
)
# Retrieve relevant memories
result = client.recall(
bank_id="my-assistant",
query="What is the user's name?"
)
for memory in result.results:
print(memory.text)
# Create a mental model - a pre-computed reflection that stays current
result = client.create_mental_model(
bank_id="my-assistant",
name="User Profile",
source_query="What do we know about this user?"
)
print(f"Creating mental model (operation: {result.operation_id})")
# List mental models
models = client.list_mental_models(bank_id="my-assistant")
for m in models.items:
print(f"{m.name}: {m.content}")
client.close()
npm install @vectorize-io/hindsight-client
import { HindsightClient } from '@vectorize-io/hindsight-client';
const client = new HindsightClient({
baseUrl: 'https://api.hindsight.vectorize.io',
apiKey: 'your-api-key'
});
// Create a memory bank
const bank = await client.createBank('my-assistant', {
name: 'My Assistant'
});
// Store a memory
await client.retain(
'my-assistant',
"The user's name is Alice and she prefers Python."
);
// Retrieve relevant memories
const result = await client.recall(
'my-assistant',
"What is the user's name?"
);
result.results.forEach(memory => {
console.log(memory.text);
});
// Create a mental model - a pre-computed reflection that stays current
const mmResult = await client.createMentalModel(
'my-assistant',
'User Profile',
'What do we know about this user?'
);
console.log(`Creating mental model (operation: ${mmResult.operation_id})`);
// List mental models
const models = await client.listMentalModels('my-assistant');
models.items.forEach(m => {
console.log(`${m.name}: ${m.content}`);
});
# Store a memory
curl -X POST https://api.hindsight.vectorize.io/v1/default/banks/{bank_id}/memories \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{"items": [{"content": "The user'\''s name is Alice and she prefers Python."}]}'
# Retrieve memories
curl -X POST https://api.hindsight.vectorize.io/v1/default/banks/{bank_id}/memories/recall \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{"query": "What is the user'\''s name?"}'
# Create a mental model - a pre-computed reflection that stays current
curl -X POST https://api.hindsight.vectorize.io/v1/default/banks/{bank_id}/mental-models \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "User Profile",
"source_query": "What do we know about this user?"
}'