@rei-standard/amsg-client 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +23 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -93,6 +93,29 @@ await client.sendInstant({
93
93
 
94
94
  旧路径 `scheduleMessage({ ...payload, messageType: 'instant' })` 仍然可用(兼容保留,多一次 DB 来回)。
95
95
 
96
+ ### `messages` 模式(多轮上下文 / 带 system role,对接 amsg-instant 0.5.0+ / amsg-server 2.2.0+)
97
+
98
+ 需要 system role、保留多轮历史、tool role 这些场景时,把 `completePrompt` 换成标准 OpenAI 格式的 `messages` 数组。client 本身**完全透传**,所以 SDK 端零额外配置:
99
+
100
+ ```js
101
+ await client.sendInstant({
102
+ contactName: 'Rei',
103
+ messages: [
104
+ { role: 'system', content: '你是 Rei,回复要简短自然。' },
105
+ { role: 'user', content: '今天会下雨吗?' },
106
+ { role: 'assistant', content: '看了下,下午有阵雨。' },
107
+ { role: 'user', content: '那提醒我一下带伞' },
108
+ ],
109
+ apiUrl: 'https://api.openai.com/v1/chat/completions',
110
+ apiKey: '...',
111
+ primaryModel: 'gpt-4o-mini',
112
+ temperature: 0.7, // 可选
113
+ pushSubscription: subscription.toJSON(),
114
+ });
115
+ ```
116
+
117
+ 注意 `completePrompt` 和 `messages` **必须恰好二选一**——两者同时给会被 Worker / Server 端返回 `400 INVALID_PAYLOAD_FORMAT` / `INVALID_PARAMETERS`。`scheduleMessage` 也接受同样的 `messages` 字段(amsg-server 2.2.0+ 起持久化层一并支持),用法相同。
118
+
96
119
  ## 导出 API(Exports)
97
120
 
98
121
  - `ReiClient`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rei-standard/amsg-client",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "ReiStandard Active Messaging browser client SDK",
5
5
  "repository": {
6
6
  "type": "git",