@capybara-hq/plugin-model-fake 0.1.0-rc.4 → 0.1.0-rc.5
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/.capybara-plugin/plugin.json +2 -2
- package/dist/index.mjs +10 -7
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "model-fake",
|
|
4
|
-
"version": "0.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.5",
|
|
5
5
|
"publisher": "Capybara",
|
|
6
6
|
"description": {
|
|
7
7
|
"en": "Deterministic scripted model provider (model-provider@2) for runtime tests, e2e tests and keyless demos",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"entry": "./dist/index.mjs",
|
|
17
17
|
"manifest": {
|
|
18
18
|
"name": "model-fake",
|
|
19
|
-
"version": "0.1.0-rc.
|
|
19
|
+
"version": "0.1.0-rc.5",
|
|
20
20
|
"sdk": "^0.1.0-rc.0",
|
|
21
21
|
"provides": [
|
|
22
22
|
"model-provider@2"
|
package/dist/index.mjs
CHANGED
|
@@ -109,6 +109,7 @@ function mediaSummary(req) {
|
|
|
109
109
|
}
|
|
110
110
|
return "none";
|
|
111
111
|
}
|
|
112
|
+
var SENDER_LINE = /^From [^\n]+$/;
|
|
112
113
|
function lastUser(req) {
|
|
113
114
|
for (let i = req.messages.length - 1; i >= 0; i--) {
|
|
114
115
|
const m = req.messages[i];
|
|
@@ -116,7 +117,9 @@ function lastUser(req) {
|
|
|
116
117
|
let text = "";
|
|
117
118
|
let result = "";
|
|
118
119
|
let hasToolResult = false;
|
|
119
|
-
|
|
120
|
+
const first = m.content[0];
|
|
121
|
+
const blocks = m.content.length > 1 && first?.type === "text" && SENDER_LINE.test(first.text) ? m.content.slice(1) : m.content;
|
|
122
|
+
for (const b of blocks) {
|
|
120
123
|
if (b.type === "text") text += b.text;
|
|
121
124
|
else if (b.type === "tool_result") {
|
|
122
125
|
hasToolResult = true;
|
|
@@ -179,9 +182,9 @@ function scripted(req) {
|
|
|
179
182
|
if (multi) {
|
|
180
183
|
try {
|
|
181
184
|
const calls = JSON.parse(multi[1]);
|
|
182
|
-
const [
|
|
183
|
-
if (
|
|
184
|
-
return { kind: "tool", name:
|
|
185
|
+
const [first, ...more] = calls;
|
|
186
|
+
if (first === void 0) throw new Error("empty");
|
|
187
|
+
return { kind: "tool", name: first.name, input: first.input, more };
|
|
185
188
|
} catch {
|
|
186
189
|
return {
|
|
187
190
|
kind: "fail",
|
|
@@ -206,8 +209,8 @@ function scripted(req) {
|
|
|
206
209
|
return { kind: "text", text: words.join(" "), chunk: 64, delayMs: 0 };
|
|
207
210
|
}
|
|
208
211
|
if (hasToolResult) return std(`Tool result: ${result}`);
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
212
|
+
const only = req.tools.length === 1 ? req.tools[0] : void 0;
|
|
213
|
+
if (only !== void 0) return { kind: "tool", name: only.name, input: {} };
|
|
211
214
|
return std(`You said: ${text}`);
|
|
212
215
|
}
|
|
213
216
|
function embedVector(text, dim) {
|
|
@@ -403,7 +406,7 @@ var DeploymentConfig = z.object({
|
|
|
403
406
|
});
|
|
404
407
|
var index_default = defineExtension({
|
|
405
408
|
name: "model-fake",
|
|
406
|
-
version: "0.1.0-rc.
|
|
409
|
+
version: "0.1.0-rc.5",
|
|
407
410
|
sdk: "^0.1.0-rc.0",
|
|
408
411
|
provides: [MODEL_PROVIDER_EXTENSION_POINT_V2],
|
|
409
412
|
config: { deployment: DeploymentConfig },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/plugin-model-fake",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Deterministic scripted model provider (model-provider@2) for runtime tests, e2e tests and keyless demos",
|