@cilow/sdk 0.2.0 → 0.3.0
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/LICENSE +201 -21
- package/README.md +109 -279
- package/dist/abstain.d.ts +43 -0
- package/dist/abstain.d.ts.map +1 -0
- package/dist/abstain.js +42 -0
- package/dist/abstain.js.map +1 -0
- package/dist/adapters/anthropic.d.ts +57 -0
- package/dist/adapters/anthropic.d.ts.map +1 -0
- package/dist/adapters/anthropic.js +57 -0
- package/dist/adapters/anthropic.js.map +1 -0
- package/dist/adapters/index.d.ts +16 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +16 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/langchain.d.ts +62 -0
- package/dist/adapters/langchain.d.ts.map +1 -0
- package/dist/adapters/langchain.js +68 -0
- package/dist/adapters/langchain.js.map +1 -0
- package/dist/adapters/memory.d.ts +105 -0
- package/dist/adapters/memory.d.ts.map +1 -0
- package/dist/adapters/memory.js +105 -0
- package/dist/adapters/memory.js.map +1 -0
- package/dist/adapters/openai.d.ts +56 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +64 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/adapters/remaining.d.ts +52 -0
- package/dist/adapters/remaining.d.ts.map +1 -0
- package/dist/adapters/remaining.js +67 -0
- package/dist/adapters/remaining.js.map +1 -0
- package/dist/client.d.ts +563 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +653 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -0
- package/dist/hash.d.ts +13 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +92 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +17 -404
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -482
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +817 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -46
- package/dist/index.d.mts +0 -407
- package/dist/index.mjs +0 -449
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI SDK binding — two thin surfaces over {@link CilowMemory}, no `openai` dependency required
|
|
3
|
+
* (the framework's shapes are structural interfaces, so this typechecks offline).
|
|
4
|
+
*
|
|
5
|
+
* 1. `base_url` swap — point the OpenAI client at the Cilow proxy; recall→inject→forward is automatic
|
|
6
|
+
* and every response carries `x-cilow-memory-grounded`. Read it with {@link groundedFromHeaders}.
|
|
7
|
+
* 2. memory tool-use — hand `cilowRecallTool` to `tools:[...]` and execute calls with
|
|
8
|
+
* {@link runRecallTool}; the tool result carries the abstained/grounded branch so the model never
|
|
9
|
+
* fabricates past a calibrated abstain.
|
|
10
|
+
*/
|
|
11
|
+
import type { CilowMemory, RecallResult } from "./memory.js";
|
|
12
|
+
/** The `x-cilow-memory-grounded` response header — grounded-in-memory vs the model's own output. */
|
|
13
|
+
export declare const GROUNDED_HEADER = "x-cilow-memory-grounded";
|
|
14
|
+
/** Structural shape of an OpenAI function tool (no `openai` import needed). */
|
|
15
|
+
export interface OpenAiTool {
|
|
16
|
+
type: "function";
|
|
17
|
+
function: {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
parameters: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Config to spread into `new OpenAI({ ...cilowProxyConfig(...) })`. The base URL is the Cilow proxy's
|
|
25
|
+
* OpenAI-compatible `/v1`; the bearer becomes the OpenAI `apiKey`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function cilowProxyConfig(memory: CilowMemory, token: string): {
|
|
28
|
+
baseURL: string;
|
|
29
|
+
apiKey: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Read the grounded signal off an OpenAI raw response's headers (from `client….withResponse()`),
|
|
33
|
+
* a `Headers`, or a plain header record. Returns `undefined` when the header is absent (non-proxy).
|
|
34
|
+
*/
|
|
35
|
+
export declare function groundedFromHeaders(headers: Headers | Record<string, string | undefined> | {
|
|
36
|
+
get(name: string): string | null;
|
|
37
|
+
}): boolean | undefined;
|
|
38
|
+
/** The OpenAI-format memory-recall tool. Register it in `tools:[cilowRecallTool]`. */
|
|
39
|
+
export declare const cilowRecallTool: OpenAiTool;
|
|
40
|
+
/** The parsed shape of a `cilow_recall` tool call's `arguments` JSON. */
|
|
41
|
+
export interface RecallToolArgs {
|
|
42
|
+
query: string;
|
|
43
|
+
anchor?: string;
|
|
44
|
+
attribute?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Execute one `cilow_recall` tool call. Returns the `content` string to feed back as the tool result
|
|
48
|
+
* plus the raw {@link RecallResult} so the caller can branch (`result.grounded` /
|
|
49
|
+
* `result.abstained` / `result.reason_code`). On an abstain the content is an explicit
|
|
50
|
+
* "memory does not know" so the model is instructed not to fabricate.
|
|
51
|
+
*/
|
|
52
|
+
export declare function runRecallTool(memory: CilowMemory, rawArgs: string | RecallToolArgs): Promise<{
|
|
53
|
+
content: string;
|
|
54
|
+
result: RecallResult;
|
|
55
|
+
}>;
|
|
56
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,oGAAoG;AACpG,eAAO,MAAM,eAAe,4BAA4B,CAAC;AAEzD,+EAA+E;AAC/E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CACtF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAExG;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG;IAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,GAC3F,OAAO,GAAG,SAAS,CAUrB;AAED,sFAAsF;AACtF,eAAO,MAAM,eAAe,EAAE,UAiB7B,CAAC;AAEF,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GAAG,cAAc,GAC/B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,CAAC,CAYpD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** The `x-cilow-memory-grounded` response header — grounded-in-memory vs the model's own output. */
|
|
2
|
+
export const GROUNDED_HEADER = "x-cilow-memory-grounded";
|
|
3
|
+
/**
|
|
4
|
+
* Config to spread into `new OpenAI({ ...cilowProxyConfig(...) })`. The base URL is the Cilow proxy's
|
|
5
|
+
* OpenAI-compatible `/v1`; the bearer becomes the OpenAI `apiKey`.
|
|
6
|
+
*/
|
|
7
|
+
export function cilowProxyConfig(memory, token) {
|
|
8
|
+
return { baseURL: memory.proxyBaseUrl(), apiKey: token };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Read the grounded signal off an OpenAI raw response's headers (from `client….withResponse()`),
|
|
12
|
+
* a `Headers`, or a plain header record. Returns `undefined` when the header is absent (non-proxy).
|
|
13
|
+
*/
|
|
14
|
+
export function groundedFromHeaders(headers) {
|
|
15
|
+
let raw;
|
|
16
|
+
if (typeof headers.get === "function") {
|
|
17
|
+
raw = headers.get(GROUNDED_HEADER);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const rec = headers;
|
|
21
|
+
raw = rec[GROUNDED_HEADER] ?? rec[GROUNDED_HEADER.toUpperCase()];
|
|
22
|
+
}
|
|
23
|
+
if (raw == null)
|
|
24
|
+
return undefined;
|
|
25
|
+
return raw.trim().toLowerCase() === "true";
|
|
26
|
+
}
|
|
27
|
+
/** The OpenAI-format memory-recall tool. Register it in `tools:[cilowRecallTool]`. */
|
|
28
|
+
export const cilowRecallTool = {
|
|
29
|
+
type: "function",
|
|
30
|
+
function: {
|
|
31
|
+
name: "cilow_recall",
|
|
32
|
+
description: "Recall grounded facts from verifiable long-term memory. Returns memory-grounded results, or a " +
|
|
33
|
+
"calibrated abstain when memory genuinely does not know — in which case DO NOT fabricate.",
|
|
34
|
+
parameters: {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
query: { type: "string", description: "What to look up in memory." },
|
|
38
|
+
anchor: { type: "string", description: "Optional exact entity hint, e.g. a person's name." },
|
|
39
|
+
attribute: { type: "string", description: "Optional exact predicate hint, e.g. 'employer'." },
|
|
40
|
+
},
|
|
41
|
+
required: ["query"],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Execute one `cilow_recall` tool call. Returns the `content` string to feed back as the tool result
|
|
47
|
+
* plus the raw {@link RecallResult} so the caller can branch (`result.grounded` /
|
|
48
|
+
* `result.abstained` / `result.reason_code`). On an abstain the content is an explicit
|
|
49
|
+
* "memory does not know" so the model is instructed not to fabricate.
|
|
50
|
+
*/
|
|
51
|
+
export async function runRecallTool(memory, rawArgs) {
|
|
52
|
+
const args = typeof rawArgs === "string" ? JSON.parse(rawArgs) : rawArgs;
|
|
53
|
+
const result = await memory.recall(args.query, { anchor: args.anchor, attribute: args.attribute });
|
|
54
|
+
if (result.abstained || !result.grounded) {
|
|
55
|
+
const kind = result.reason_code === "provider_unavailable" ? "temporarily unavailable" : "no grounded facts";
|
|
56
|
+
return {
|
|
57
|
+
content: `MEMORY ABSTAINED (${kind}): ${result.reason ?? "memory does not know"}. Do not fabricate; ask the user or say you don't know.`,
|
|
58
|
+
result,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const lines = result.results.map((h) => `- ${h.text}`).join("\n");
|
|
62
|
+
return { content: `MEMORY-GROUNDED FACTS:\n${lines}`, result };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAYA,oGAAoG;AACpG,MAAM,CAAC,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAQzD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAmB,EAAE,KAAa;IACjE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAA4F;IAE5F,IAAI,GAA8B,CAAC;IACnC,IAAI,OAAQ,OAA6B,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QAC7D,GAAG,GAAI,OAAgD,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,OAA6C,CAAC;QAC1D,GAAG,GAAG,GAAG,CAAC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sBAAsB,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,mBAAmB,CAAC;QAC7G,OAAO;YACL,OAAO,EAAE,qBAAqB,IAAI,MAAM,MAAM,CAAC,MAAM,IAAI,sBAAsB,yDAAyD;YACxI,MAAM;SACP,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,EAAE,OAAO,EAAE,2BAA2B,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The remaining six framework bindings — same {@link CilowMemory} contract, same ≤150-line-shim
|
|
3
|
+
* pattern as `openai.ts` / `anthropic.ts` / `langchain.ts`. Each entry documents the framework's
|
|
4
|
+
* integration point and the exact mapping onto the five contract verbs. Where the framework interface
|
|
5
|
+
* is a plain function/protocol we ship a working stub; where it requires extending a framework base
|
|
6
|
+
* class we leave a typed TODO so the shim lands the moment the dep is added.
|
|
7
|
+
*
|
|
8
|
+
* THE INVARIANT (all nine): map the framework's memory/retriever/tool onto
|
|
9
|
+
* `ingest` / `recall` / `answer` / `reset` / `health` (+ `proxyBaseUrl()` for base_url swaps) and
|
|
10
|
+
* re-expose `abstained` + `reason_code` + `grounded` unchanged. An abstain is ALWAYS surfaced, never
|
|
11
|
+
* fabricated past.
|
|
12
|
+
*/
|
|
13
|
+
import type { CilowMemory } from "./memory.js";
|
|
14
|
+
/** One row of the remaining-adapter plan (mirrors the design doc §2.2 table). */
|
|
15
|
+
export interface AdapterPlan {
|
|
16
|
+
framework: string;
|
|
17
|
+
integrationPoint: string;
|
|
18
|
+
mapping: string;
|
|
19
|
+
status: "stub" | "todo";
|
|
20
|
+
}
|
|
21
|
+
export declare const REMAINING_ADAPTERS: readonly AdapterPlan[];
|
|
22
|
+
/**
|
|
23
|
+
* LlamaIndex stub — a retriever whose `retrieve` returns NodeWithScore-shaped hits (abstain ⇒ []).
|
|
24
|
+
* When `llamaindex` is added, extend `BaseRetriever` and delegate to this.
|
|
25
|
+
*/
|
|
26
|
+
export interface LlamaNodeWithScore {
|
|
27
|
+
node: {
|
|
28
|
+
text: string;
|
|
29
|
+
metadata: Record<string, unknown>;
|
|
30
|
+
};
|
|
31
|
+
score: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function makeLlamaIndexRetriever(memory: CilowMemory, opts?: {
|
|
34
|
+
k?: number;
|
|
35
|
+
anchor?: string;
|
|
36
|
+
}): {
|
|
37
|
+
retrieve(query: string): Promise<LlamaNodeWithScore[]>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* AutoGen stub — the `Memory` protocol surface (`add` / `query`). `query` returns grounded content
|
|
41
|
+
* strings; an abstain yields an empty list (never a fabricated memory).
|
|
42
|
+
*/
|
|
43
|
+
export declare function makeAutoGenMemory(memory: CilowMemory, opts?: {
|
|
44
|
+
subjectHint?: string;
|
|
45
|
+
}): {
|
|
46
|
+
add(content: string): Promise<void>;
|
|
47
|
+
query(query: string): Promise<{
|
|
48
|
+
results: string[];
|
|
49
|
+
grounded: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=remaining.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remaining.d.ts","sourceRoot":"","sources":["../../src/adapters/remaining.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,kBAAkB,EAAE,SAAS,WAAW,EAqC3C,CAAC;AAEX;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;CACf;AACD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO;oBAE7E,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;EAS/D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO;iBAEnE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;iBAGtB,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;EAKhF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const REMAINING_ADAPTERS = [
|
|
2
|
+
{
|
|
3
|
+
framework: "LlamaIndex",
|
|
4
|
+
integrationPoint: "BaseRetriever.retrieve(QueryBundle) -> NodeWithScore[]",
|
|
5
|
+
mapping: "recall → NodeWithScore[]; abstain ⇒ []. Near-identical to CilowRetriever (langchain.ts).",
|
|
6
|
+
status: "stub",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
framework: "Vercel AI SDK",
|
|
10
|
+
integrationPoint: "wrapLanguageModel middleware",
|
|
11
|
+
mapping: "proxyBaseUrl() as the provider base URL; surface `grounded` in stream metadata (R2.1: streaming tool-call capture pending).",
|
|
12
|
+
status: "todo",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
framework: "CrewAI",
|
|
16
|
+
integrationPoint: "Storage / memory_backend",
|
|
17
|
+
mapping: "save→ingest, search→recall; branch on abstained before use.",
|
|
18
|
+
status: "todo",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
framework: "AutoGen",
|
|
22
|
+
integrationPoint: "Memory protocol (add / query)",
|
|
23
|
+
mapping: "add→ingest, query→recall; abstain ⇒ empty MemoryQueryResult.",
|
|
24
|
+
status: "stub",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
framework: "Composio",
|
|
28
|
+
integrationPoint: "connector / tool bundle",
|
|
29
|
+
mapping: "the five CilowMemory verbs as Composio actions (recall/remember/answer/reset).",
|
|
30
|
+
status: "todo",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
framework: "MCP",
|
|
34
|
+
integrationPoint: "native /mcp recall/answer/remember (already shipped)",
|
|
35
|
+
mapping: "no shim needed — add cilow-mcp to .mcp.json.",
|
|
36
|
+
status: "stub",
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
export function makeLlamaIndexRetriever(memory, opts = {}) {
|
|
40
|
+
return {
|
|
41
|
+
async retrieve(query) {
|
|
42
|
+
const r = await memory.recall(query, { k: opts.k, anchor: opts.anchor });
|
|
43
|
+
if (!r.grounded)
|
|
44
|
+
return [];
|
|
45
|
+
return r.results.map((h) => ({
|
|
46
|
+
node: { text: h.text, metadata: { id: h.id, entity: h.entity, grounded: true } },
|
|
47
|
+
score: h.score,
|
|
48
|
+
}));
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* AutoGen stub — the `Memory` protocol surface (`add` / `query`). `query` returns grounded content
|
|
54
|
+
* strings; an abstain yields an empty list (never a fabricated memory).
|
|
55
|
+
*/
|
|
56
|
+
export function makeAutoGenMemory(memory, opts = {}) {
|
|
57
|
+
return {
|
|
58
|
+
async add(content) {
|
|
59
|
+
await memory.ingest(content, { subjectHint: opts.subjectHint });
|
|
60
|
+
},
|
|
61
|
+
async query(query) {
|
|
62
|
+
const r = await memory.recall(query);
|
|
63
|
+
return { results: r.grounded ? r.results.map((h) => h.text) : [], grounded: r.grounded };
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=remaining.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remaining.js","sourceRoot":"","sources":["../../src/adapters/remaining.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACxD;QACE,SAAS,EAAE,YAAY;QACvB,gBAAgB,EAAE,wDAAwD;QAC1E,OAAO,EAAE,0FAA0F;QACnG,MAAM,EAAE,MAAM;KACf;IACD;QACE,SAAS,EAAE,eAAe;QAC1B,gBAAgB,EAAE,8BAA8B;QAChD,OAAO,EAAE,6HAA6H;QACtI,MAAM,EAAE,MAAM;KACf;IACD;QACE,SAAS,EAAE,QAAQ;QACnB,gBAAgB,EAAE,0BAA0B;QAC5C,OAAO,EAAE,6DAA6D;QACtE,MAAM,EAAE,MAAM;KACf;IACD;QACE,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,+BAA+B;QACjD,OAAO,EAAE,8DAA8D;QACvE,MAAM,EAAE,MAAM;KACf;IACD;QACE,SAAS,EAAE,UAAU;QACrB,gBAAgB,EAAE,yBAAyB;QAC3C,OAAO,EAAE,gFAAgF;QACzF,MAAM,EAAE,MAAM;KACf;IACD;QACE,SAAS,EAAE,KAAK;QAChB,gBAAgB,EAAE,sDAAsD;QACxE,OAAO,EAAE,8CAA8C;QACvD,MAAM,EAAE,MAAM;KACf;CACO,CAAC;AAUX,MAAM,UAAU,uBAAuB,CAAC,MAAmB,EAAE,OAAwC,EAAE;IACrG,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,KAAa;YAC1B,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,C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