@oyasmi/pipiclaw 0.5.6 → 0.5.7
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.
- package/README.md +19 -3
- package/dist/agent/command-extension.js +6 -6
- package/dist/agent/commands.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/utils.d.ts +4 -0
- package/dist/models/utils.js +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -327,6 +327,9 @@ pipiclaw
|
|
|
327
327
|
|
|
328
328
|
确认当前可见模型和默认模型都符合预期后,再发送一条普通消息,例如:
|
|
329
329
|
|
|
330
|
+
- `/model` 会列出当前模型和可用模型
|
|
331
|
+
- 切换时支持精确的 `provider/modelId`、精确的 `modelId`,以及能唯一命中的片段字符串,例如 `/model turbo`
|
|
332
|
+
|
|
330
333
|
```text
|
|
331
334
|
请介绍一下你自己,并说明你现在能做什么
|
|
332
335
|
```
|
|
@@ -394,9 +397,22 @@ Pipiclaw 有两层命令。
|
|
|
394
397
|
| `/new` | 开启一个新的会话 |
|
|
395
398
|
| `/compact [instructions]` | 手动压缩当前会话上下文,可附带额外说明 |
|
|
396
399
|
| `/session` | 查看当前会话状态、消息统计、token 使用量和当前模型 |
|
|
397
|
-
| `/model [provider/modelId|modelId]` | 查看当前模型,或切换到指定模型 |
|
|
400
|
+
| `/model [provider/modelId|modelId|substring]` | 查看当前模型,或切换到指定模型 |
|
|
401
|
+
|
|
402
|
+
`/model` 的匹配顺序是:
|
|
403
|
+
|
|
404
|
+
1. 精确匹配 `provider/modelId`
|
|
405
|
+
2. 精确匹配 `modelId`
|
|
406
|
+
3. 对完整的 `provider/modelId` 做子字符串匹配
|
|
407
|
+
|
|
408
|
+
只有当片段字符串能唯一命中一个可用模型时才会切换。例如:
|
|
409
|
+
|
|
410
|
+
- `/model qwen`
|
|
411
|
+
- `/model k2.5`
|
|
412
|
+
- `/model turbo`
|
|
413
|
+
- `/model zpai`
|
|
398
414
|
|
|
399
|
-
`/model`
|
|
415
|
+
像 `/model glm5` 这种不构成子字符串的输入不会命中。
|
|
400
416
|
|
|
401
417
|
## 工作区结构(Workspace Layout)
|
|
402
418
|
|
|
@@ -502,7 +518,7 @@ Pipiclaw 不会把所有历史对话无上限地塞进 prompt,而是按层管
|
|
|
502
518
|
- 如果是 OpenAI-compatible 服务,是否需要:
|
|
503
519
|
- `"supportsDeveloperRole": false`
|
|
504
520
|
- `"supportsReasoningEffort": false`
|
|
505
|
-
- 给机器人发送 `/model
|
|
521
|
+
- 给机器人发送 `/model`,确认当前可见模型和默认模型是否正确;如需切换,也可以用唯一命中的片段,例如 `/model turbo`
|
|
506
522
|
|
|
507
523
|
### 机器人能收到消息,但没有回复(The Bot Receives Messages but Does Not Reply)
|
|
508
524
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename } from "path";
|
|
2
|
-
import {
|
|
2
|
+
import { findModelReferenceMatch, formatModelList, formatModelReference } from "../models/utils.js";
|
|
3
3
|
export const COMMAND_RESULT_CUSTOM_TYPE = "pipiclaw.command_result";
|
|
4
4
|
function buildSessionText(stats, currentModel, thinkingLevel) {
|
|
5
5
|
const modelText = currentModel ? `\`${formatModelReference(currentModel)}\`` : "(none)";
|
|
@@ -43,7 +43,7 @@ export function createCommandExtension(options) {
|
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
pi.registerCommand("model", {
|
|
46
|
-
description: "Show the current model or switch models using an exact
|
|
46
|
+
description: "Show the current model or switch models using an exact or uniquely matching substring",
|
|
47
47
|
handler: async (args) => {
|
|
48
48
|
const availableModels = await options.getAvailableModels();
|
|
49
49
|
const currentModel = options.getCurrentModel();
|
|
@@ -54,13 +54,13 @@ export function createCommandExtension(options) {
|
|
|
54
54
|
|
|
55
55
|
Current model: ${current}
|
|
56
56
|
|
|
57
|
-
Use \`/model <provider/modelId
|
|
57
|
+
Use \`/model <provider/modelId>\`, \`/model <modelId>\`, or any uniquely matching substring to switch.
|
|
58
58
|
|
|
59
59
|
Available models:
|
|
60
60
|
${available}`);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
const match =
|
|
63
|
+
const match = findModelReferenceMatch(args, availableModels);
|
|
64
64
|
const available = availableModels.length > 0 ? formatModelList(availableModels, currentModel, 10) : "- (none)";
|
|
65
65
|
if (match.match) {
|
|
66
66
|
await options.switchModel(match.match);
|
|
@@ -68,13 +68,13 @@ ${available}`);
|
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
if (match.ambiguous) {
|
|
71
|
-
sendCommandResult(pi, `未切换模型:\`${args.trim()}\`
|
|
71
|
+
sendCommandResult(pi, `未切换模型:\`${args.trim()}\` 匹配到多个模型。请提供更精确的 \`provider/modelId\`、\`modelId\` 或更长的片段。
|
|
72
72
|
|
|
73
73
|
Available models:
|
|
74
74
|
${available}`);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
sendCommandResult(pi, `未找到模型 \`${args.trim()}\`。请使用精确的 \`provider/modelId
|
|
77
|
+
sendCommandResult(pi, `未找到模型 \`${args.trim()}\`。请使用精确的 \`provider/modelId\`、唯一的 \`modelId\`,或能唯一命中的片段字符串。
|
|
78
78
|
|
|
79
79
|
Available models:
|
|
80
80
|
${available}`);
|
package/dist/agent/commands.js
CHANGED
|
@@ -29,7 +29,7 @@ These are handled inside the Pipiclaw session layer:
|
|
|
29
29
|
Show current session state, message stats, token usage, and model info
|
|
30
30
|
Example: \`/session\`
|
|
31
31
|
- \`/model [provider/modelId|modelId]\`
|
|
32
|
-
Show the current model, or switch models using an exact match
|
|
32
|
+
Show the current model, or switch models using an exact match or a uniquely matching substring
|
|
33
33
|
Example: \`/model\`
|
|
34
34
|
Example: \`/model anthropic/claude-opus-4-6\`
|
|
35
35
|
- \`/new\`
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { type RecalledMemory, type RecallRequest, type RecallResult, recallRelev
|
|
|
11
11
|
export { renderSessionMemory, type SessionMemoryState, type SessionMemoryUpdateOptions, updateChannelSessionMemory, } from "./memory/session.js";
|
|
12
12
|
export { runSidecarTask, type SidecarResult, type SidecarTask, } from "./memory/sidecar-worker.js";
|
|
13
13
|
export { getApiKeyForModel } from "./models/api-keys.js";
|
|
14
|
-
export { findExactModelReferenceMatch, formatModelList, formatModelReference, resolveInitialModel, } from "./models/utils.js";
|
|
14
|
+
export { findExactModelReferenceMatch, findModelReferenceMatch, formatModelList, formatModelReference, resolveInitialModel, } from "./models/utils.js";
|
|
15
15
|
export { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, MODELS_CONFIG_PATH, SETTINGS_CONFIG_PATH, SUB_AGENTS_DIR, SUB_AGENTS_DIR_NAME, WORKSPACE_DIR, } from "./paths.js";
|
|
16
16
|
export { ensureChannelDir, getChannelDir, getChannelDirName, } from "./runtime/channel-paths.js";
|
|
17
17
|
export { createDingTalkContext } from "./runtime/delivery.js";
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { recallRelevantMemory, } from "./memory/recall.js";
|
|
|
11
11
|
export { renderSessionMemory, updateChannelSessionMemory, } from "./memory/session.js";
|
|
12
12
|
export { runSidecarTask, } from "./memory/sidecar-worker.js";
|
|
13
13
|
export { getApiKeyForModel } from "./models/api-keys.js";
|
|
14
|
-
export { findExactModelReferenceMatch, formatModelList, formatModelReference, resolveInitialModel, } from "./models/utils.js";
|
|
14
|
+
export { findExactModelReferenceMatch, findModelReferenceMatch, formatModelList, formatModelReference, resolveInitialModel, } from "./models/utils.js";
|
|
15
15
|
export { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, MODELS_CONFIG_PATH, SETTINGS_CONFIG_PATH, SUB_AGENTS_DIR, SUB_AGENTS_DIR_NAME, WORKSPACE_DIR, } from "./paths.js";
|
|
16
16
|
export { ensureChannelDir, getChannelDir, getChannelDirName, } from "./runtime/channel-paths.js";
|
|
17
17
|
export { createDingTalkContext } from "./runtime/delivery.js";
|
package/dist/models/utils.d.ts
CHANGED
|
@@ -6,5 +6,9 @@ export declare function findExactModelReferenceMatch(modelReference: string, ava
|
|
|
6
6
|
match?: Model<Api>;
|
|
7
7
|
ambiguous: boolean;
|
|
8
8
|
};
|
|
9
|
+
export declare function findModelReferenceMatch(modelReference: string, availableModels: Model<Api>[]): {
|
|
10
|
+
match?: Model<Api>;
|
|
11
|
+
ambiguous: boolean;
|
|
12
|
+
};
|
|
9
13
|
export declare function formatModelList(models: Model<Api>[], currentModel: Model<Api> | undefined, limit?: number): string;
|
|
10
14
|
export declare function resolveInitialModel(modelRegistry: ModelRegistry, settingsManager: PipiclawSettingsManager): Model<Api>;
|
package/dist/models/utils.js
CHANGED
|
@@ -38,6 +38,21 @@ export function findExactModelReferenceMatch(modelReference, availableModels) {
|
|
|
38
38
|
}
|
|
39
39
|
return { ambiguous: idMatches.length > 1 };
|
|
40
40
|
}
|
|
41
|
+
export function findModelReferenceMatch(modelReference, availableModels) {
|
|
42
|
+
const exactMatch = findExactModelReferenceMatch(modelReference, availableModels);
|
|
43
|
+
if (exactMatch.match || exactMatch.ambiguous) {
|
|
44
|
+
return exactMatch;
|
|
45
|
+
}
|
|
46
|
+
const normalizedReference = modelReference.trim().toLowerCase();
|
|
47
|
+
if (!normalizedReference) {
|
|
48
|
+
return { ambiguous: false };
|
|
49
|
+
}
|
|
50
|
+
const substringMatches = availableModels.filter((model) => formatModelReference(model).toLowerCase().includes(normalizedReference));
|
|
51
|
+
if (substringMatches.length === 1) {
|
|
52
|
+
return { match: substringMatches[0], ambiguous: false };
|
|
53
|
+
}
|
|
54
|
+
return { ambiguous: substringMatches.length > 1 };
|
|
55
|
+
}
|
|
41
56
|
export function formatModelList(models, currentModel, limit = 20) {
|
|
42
57
|
const refs = models
|
|
43
58
|
.slice()
|
package/package.json
CHANGED