@kybernesis/brain-testkit 0.8.1 → 0.8.2
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/dist/llm-stub.d.ts +13 -1
- package/dist/llm-stub.d.ts.map +1 -1
- package/dist/llm-stub.js +7 -1
- package/dist/llm-stub.js.map +1 -1
- package/package.json +2 -2
package/dist/llm-stub.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
interface LLMProvider {
|
|
2
2
|
call(prompt: string, opts?: unknown): Promise<string | null>;
|
|
3
3
|
}
|
|
4
|
+
/** One recorded invocation of the stub. */
|
|
5
|
+
export interface RecordedCall {
|
|
6
|
+
prompt: string;
|
|
7
|
+
opts?: unknown;
|
|
8
|
+
}
|
|
9
|
+
/** The stub plus the recorded-calls log, so tests can assert on prompt AND opts. */
|
|
10
|
+
export interface LLMStub extends LLMProvider {
|
|
11
|
+
readonly calls: RecordedCall[];
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* Test double for LLMProvider. `responses` is a map from prompt substring to
|
|
6
15
|
* the string the stub should return. '*' is a special wildcard fallback — it
|
|
7
16
|
* only fires when no other key matches (regardless of insertion order).
|
|
17
|
+
*
|
|
18
|
+
* Every invocation is recorded on `.calls` (prompt + opts) so tests can assert
|
|
19
|
+
* that callers pass through model / system / etc.
|
|
8
20
|
*/
|
|
9
|
-
export declare function makeLLMStub(responses?: Record<string, string>):
|
|
21
|
+
export declare function makeLLMStub(responses?: Record<string, string>): LLMStub;
|
|
10
22
|
export {};
|
|
11
23
|
//# sourceMappingURL=llm-stub.d.ts.map
|
package/dist/llm-stub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-stub.d.ts","sourceRoot":"","sources":["../src/llm-stub.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW;IACnB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9D;AAED
|
|
1
|
+
{"version":3,"file":"llm-stub.d.ts","sourceRoot":"","sources":["../src/llm-stub.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW;IACnB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9D;AAED,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,oFAAoF;AACpF,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAC1C,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,OAAO,CAY3E"}
|
package/dist/llm-stub.js
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
* Test double for LLMProvider. `responses` is a map from prompt substring to
|
|
3
3
|
* the string the stub should return. '*' is a special wildcard fallback — it
|
|
4
4
|
* only fires when no other key matches (regardless of insertion order).
|
|
5
|
+
*
|
|
6
|
+
* Every invocation is recorded on `.calls` (prompt + opts) so tests can assert
|
|
7
|
+
* that callers pass through model / system / etc.
|
|
5
8
|
*/
|
|
6
9
|
export function makeLLMStub(responses = {}) {
|
|
10
|
+
const calls = [];
|
|
7
11
|
return {
|
|
8
|
-
|
|
12
|
+
calls,
|
|
13
|
+
async call(prompt, opts) {
|
|
14
|
+
calls.push({ prompt, opts });
|
|
9
15
|
for (const [key, value] of Object.entries(responses)) {
|
|
10
16
|
if (key !== '*' && prompt.includes(key))
|
|
11
17
|
return value;
|
package/dist/llm-stub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-stub.js","sourceRoot":"","sources":["../src/llm-stub.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"llm-stub.js","sourceRoot":"","sources":["../src/llm-stub.ts"],"names":[],"mappings":"AAiBA;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,YAAoC,EAAE;IAChE,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,OAAO;QACL,KAAK;QACL,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,IAAc;YACvC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;gBACrD,IAAI,GAAG,KAAK,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAAE,OAAO,KAAK,CAAC;YACxD,CAAC;YACD,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;QAChC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kybernesis/brain-testkit",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "In-memory fakes and parity harness for testing brain-* consumers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David Cruwys (AppyDave)",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"README.md"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@kybernesis/brain-contracts": "0.8.
|
|
42
|
+
"@kybernesis/brain-contracts": "0.8.2"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|