返回顶部
p

pref0自动学习偏好

Learn user preferences from conversations and personalize responses automatically. Preferences compound over time — corrections like "use TypeScript, not JavaScript" are captured and injected into future sessions.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.1
安全检测
已通过
1,445
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

pref0

pref0 — AI代理的偏好学习

你可以访问pref0 API。它能从对话中学习用户偏好,并在推理时提供这些偏好。你追踪的对话越多,效果就越好。

何时使用此技能

对话结束后 → 追踪对话

在完成对话后(或在自然断点处),将消息发送给pref0,以便它提取偏好。当用户纠正你(例如使用pnpm,不要用npm)或明确表达偏好(例如始终使用公制单位)时,这一点尤其有价值。

回复用户前 → 获取他们的偏好

在生成回复之前,获取用户已学习的偏好并遵循它们。这可以防止用户在不同会话中重复表达相同的内容。

API参考

基础URL: https://api.pref0.com
认证: Authorization: Bearer $PREF0APIKEY

追踪对话(POST /v1/track)

发送对话以便pref0从中学习。它会自动提取纠正、明确偏好和行为模式。

bash
curl -X POST https://api.pref0.com/v1/track \
-H Authorization: Bearer $PREF0APIKEY \
-H Content-Type: application/json \
-d {
userId: <用户ID>,
messages: [
{ role: user, content: 帮我设置一个新项目 },
{ role: assistant, content: 这里是一个使用npm和JavaScript的项目... },
{ role: user, content: 使用pnpm,不要用npm。并且用TypeScript。 },
{ role: assistant, content: 已更新为pnpm和TypeScript... }
]
}

响应:
json
{
messagesAnalyzed: 4,
preferences: { created: 2, reinforced: 0, decreased: 0, removed: 0 },
patterns: { created: 1, reinforced: 0 }
}

响应告诉你处理了多少条消息(messagesAnalyzed)以及具体变化:created(学习到的新偏好)、reinforced(再次看到已有偏好,置信度提高)、decreased(用户撤回,置信度降低)、removed(完全撤回并删除)。

获取已学习的偏好(GET /v1/profiles/:userId)

检索用户已学习的偏好配置文件。使用?minConfidence=0.5仅获取适合注入系统提示的、学习充分的偏好。

bash
curl https://api.pref0.com/v1/profiles/<用户ID>?minConfidence=0.5 \
-H Authorization: Bearer $PREF0APIKEY

响应:
json
{
userId: user_abc123,
preferences: [
{
key: language,
value: typescript,
confidence: 0.85,
evidence: 用户说:使用TypeScript,不要用JavaScript,
firstSeen: 2026-01-15T10:00:00.000Z,
lastSeen: 2026-02-05T14:30:00.000Z
},
{
key: package_manager,
value: pnpm,
confidence: 0.85,
evidence: 用户说:使用pnpm代替npm,
firstSeen: 2026-01-15T10:00:00.000Z,
lastSeen: 2026-02-03T09:15:00.000Z
},
{
key: css_framework,
value: tailwind,
confidence: 0.70,
evidence: 用户说:使用Tailwind,不要用Bootstrap,
firstSeen: 2026-01-20T16:45:00.000Z,
lastSeen: 2026-01-20T16:45:00.000Z
}
],
patterns: [
{ pattern: 偏好明确的工具选择而非默认值, confidence: 0.60 }
],
prompt: 以下偏好是从该用户之前的对话中学习到的。除非明确告知,否则请遵循这些偏好:\n- language: typescript\n- packagemanager: pnpm\n- cssframework: tailwind\n\n观察到的行为模式:\n- 偏好明确的工具选择而非默认值
}

每个偏好都包含evidence(触发提取的引用)、firstSeen(首次学习时间)和lastSeen(最后强化时间)。prompt字段是一个可直接追加到系统提示中的即用字符串。

删除用户配置文件(DELETE /v1/profiles/:userId)

重置用户已学习的偏好。用于偏好重置或数据删除请求。

bash
curl -X DELETE https://api.pref0.com/v1/profiles/<用户ID> \
-H Authorization: Bearer $PREF0APIKEY

返回204 No Content。

如何集成到你的工作流程中

  1. 1. 识别用户。 使用稳定的用户ID(电子邮件、账户ID、电话号码——你拥有的任何标识)。
  1. 2. 在会话开始时,获取偏好:
- 调用GET /v1/profiles/{userId}?minConfidence=0.5 - 使用prompt字段直接注入到系统提示中,或使用结构化的preferences数组进行更精细的控制。
  1. 3. 在会话结束时,追踪对话:
- 调用POST /v1/track,传入完整的消息历史记录 - pref0会自动处理提取和置信度评分
  1. 4. 偏好会随时间累积。 纠正的初始置信度为0.70,隐含偏好为0.40。每次重复信号增加+0.15,上限为1.0。

置信度指南

信号类型初始置信度示例
明确纠正0.70使用Tailwind,不要用Bootstrap
隐含偏好
0.40 | 部署到Vercel | | 行为模式 | 0.30 | 用户始终希望简短回复 | | 每次重复 | +0.15 | 跨会话的相同偏好 |

设置

  1. 1. 在pref0.com注册
  2. 在控制面板中创建API密钥
  3. 设置PREF0API_KEY环境变量
  4. 每月前100次请求免费,之后每1,000次请求收费5美元

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 pref0-1776345745 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 pref0-1776345745 技能

通过命令行安装

skillhub install pref0-1776345745

下载

⬇ 下载 pref0 v1.0.1(免费)

文件大小: 3.12 KB | 发布时间: 2026-4-17 14:01

v1.0.1 最新 2026-4-17 14:01
pref0 1.0.1

- Improved API documentation to clarify track and profile endpoints, including more detailed response fields for conversation tracking.
- Added a ready-to-use prompt field to the profile API response for easier system prompt integration.
- Now, the profile endpoint (`GET /v1/profiles/:userId`) returns the `prompt` directly alongside learned preferences and patterns.
- Created notes.txt file (contents not specified in this changelog).

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部