Documentation Index
Fetch the complete documentation index at: https://tech.illasoft.com/llms.txt
Use this file to discover all available pages before exploring further.
基础地址:http://kira-memory.internal:8080
POST /inject
核心接口。每轮对话前调用,一次拿到所有需要的记忆上下文。
// Request
{
entity_id: string,
entity_type: 'user' | 'group',
group_id?: string, // 群场景下传群 ID
query: string, // 用户消息,用于 proactive search
limit?: number // 检索条数,默认 5
}
// Response
{
profile: Profile | null, // 用户画像
group_profile: Profile | null, // 群画像(仅群场景)
memories: Memory[], // 相关情景记忆(已合并排序)
}
实现逻辑:
app.post("/inject", async (c) => {
const { entity_id, entity_type, group_id, query, limit = 5 } = await c.req.json();
const queryEmbedding = await embed(query);
const [profile, groupProfile, userMemories, groupMemories] = await Promise.all([
getProfile(entity_id, entity_type), // Dragonfly → fallback Supabase
group_id ? getProfile(group_id, 'group') : null,
searchMemories(entity_id, entity_type, queryEmbedding, limit), // LanceDB
group_id ? searchMemories(group_id, 'group', queryEmbedding, 3) : null,
]);
return c.json({
profile,
group_profile: groupProfile,
memories: mergeAndRank([...userMemories, ...(groupMemories ?? [])]),
});
});
POST /memory/add
Agent 显式存储记忆(用户明确表达偏好时)。
// Request
{
entity_id: string,
entity_type: 'user' | 'group',
content: string, // "用户说所有导出图片都要加水印"
type: 'preference' | 'workflow' | 'instruction' | 'episodic',
metadata?: object
}
// Response
{ id: string, deduplicated: boolean }
写入前自动去重:embedding → LanceDB 查相似 → 相似度 > 0.9 则合并更新。
POST /memory/search
Agent 主动深度查询(备用,大部分情况 /inject 已够)。
// Request
{
entity_id: string,
entity_type: 'user' | 'group',
query: string,
limit?: number,
type_filter?: string // 可选,只查某类记忆
}
// Response
{ memories: Memory[] }
PUT /memory/:id
更新记忆内容,重新 embedding。
DELETE /memory/:id
硬删除。
Admin API
供 kira-cms 运营后台调用,支持按用户查看、搜索、增删改查记忆和画像。路由前缀 /admin,通过 X-Admin-Token 鉴权。
详见 CMS 记忆管理。