langchain 0.0.204-rc.0 → 0.0.204-rc.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.
Files changed (61) hide show
  1. package/dist/agents/toolkits/aws_sfn.cjs +3 -75
  2. package/dist/agents/toolkits/aws_sfn.d.ts +2 -45
  3. package/dist/agents/toolkits/aws_sfn.js +2 -73
  4. package/dist/agents/toolkits/base.cjs +15 -9
  5. package/dist/agents/toolkits/base.d.ts +1 -9
  6. package/dist/agents/toolkits/base.js +1 -7
  7. package/dist/agents/toolkits/connery/index.cjs +15 -37
  8. package/dist/agents/toolkits/connery/index.d.ts +1 -23
  9. package/dist/agents/toolkits/connery/index.js +1 -35
  10. package/dist/cache/ioredis.cjs +15 -77
  11. package/dist/cache/ioredis.d.ts +1 -40
  12. package/dist/cache/ioredis.js +1 -75
  13. package/dist/memory/chat_memory.cjs +15 -61
  14. package/dist/memory/chat_memory.d.ts +1 -36
  15. package/dist/memory/chat_memory.js +1 -59
  16. package/dist/memory/motorhead_memory.cjs +15 -161
  17. package/dist/memory/motorhead_memory.d.ts +1 -63
  18. package/dist/memory/motorhead_memory.js +1 -159
  19. package/dist/memory/zep.cjs +15 -222
  20. package/dist/memory/zep.d.ts +1 -86
  21. package/dist/memory/zep.js +1 -220
  22. package/dist/schema/runnable/base.cjs +2 -1
  23. package/dist/schema/runnable/base.d.ts +1 -1
  24. package/dist/schema/runnable/base.js +1 -1
  25. package/dist/stores/message/in_memory.cjs +15 -49
  26. package/dist/stores/message/in_memory.d.ts +1 -28
  27. package/dist/stores/message/in_memory.js +1 -47
  28. package/dist/tools/aws_lambda.cjs +15 -83
  29. package/dist/tools/aws_lambda.d.ts +1 -25
  30. package/dist/tools/aws_lambda.js +1 -82
  31. package/dist/tools/dynamic.cjs +15 -87
  32. package/dist/tools/dynamic.d.ts +1 -48
  33. package/dist/tools/dynamic.js +1 -84
  34. package/dist/util/convex.cjs +15 -75
  35. package/dist/util/convex.d.ts +1 -26
  36. package/dist/util/convex.js +1 -74
  37. package/dist/vectorstores/memory.cjs +143 -15
  38. package/dist/vectorstores/memory.d.ts +92 -1
  39. package/dist/vectorstores/memory.js +141 -1
  40. package/package.json +4 -243
  41. package/dist/types/openai-types.cjs +0 -2
  42. package/dist/types/openai-types.d.ts +0 -135
  43. package/dist/types/openai-types.js +0 -1
  44. package/dist/util/chunk.cjs +0 -11
  45. package/dist/util/chunk.d.ts +0 -1
  46. package/dist/util/chunk.js +0 -7
  47. package/dist/util/googlevertexai-gauth.cjs +0 -36
  48. package/dist/util/googlevertexai-gauth.d.ts +0 -8
  49. package/dist/util/googlevertexai-gauth.js +0 -32
  50. package/dist/util/googlevertexai-webauth.cjs +0 -96
  51. package/dist/util/googlevertexai-webauth.d.ts +0 -22
  52. package/dist/util/googlevertexai-webauth.js +0 -92
  53. package/dist/util/iflytek_websocket_stream.cjs +0 -81
  54. package/dist/util/iflytek_websocket_stream.d.ts +0 -27
  55. package/dist/util/iflytek_websocket_stream.js +0 -77
  56. package/dist/util/llama_cpp.cjs +0 -34
  57. package/dist/util/llama_cpp.d.ts +0 -46
  58. package/dist/util/llama_cpp.js +0 -28
  59. package/dist/util/momento.cjs +0 -26
  60. package/dist/util/momento.d.ts +0 -9
  61. package/dist/util/momento.js +0 -22
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GAuthClient = void 0;
4
- const google_auth_library_1 = require("google-auth-library");
5
- const googlevertexai_connection_js_1 = require("./googlevertexai-connection.cjs");
6
- class GoogleVertexAINodeStream extends googlevertexai_connection_js_1.GoogleVertexAIStream {
7
- constructor(data) {
8
- super();
9
- data.on("data", (data) => this.appendBuffer(data.toString()));
10
- data.on("end", () => this.closeBuffer());
11
- }
12
- }
13
- class GAuthClient {
14
- constructor(options) {
15
- Object.defineProperty(this, "gauth", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: void 0
20
- });
21
- this.gauth = new google_auth_library_1.GoogleAuth(options);
22
- }
23
- async getProjectId() {
24
- return this.gauth.getProjectId();
25
- }
26
- async request(opts) {
27
- const ret = await this.gauth.request(opts);
28
- return opts.responseType !== "stream"
29
- ? ret
30
- : {
31
- ...ret,
32
- data: new GoogleVertexAINodeStream(ret.data),
33
- };
34
- }
35
- }
36
- exports.GAuthClient = GAuthClient;
@@ -1,8 +0,0 @@
1
- import { GoogleAuth, GoogleAuthOptions } from "google-auth-library";
2
- import { GoogleAbstractedClient, GoogleAbstractedClientOps } from "../types/googlevertexai-types.js";
3
- export declare class GAuthClient implements GoogleAbstractedClient {
4
- gauth: GoogleAuth;
5
- constructor(options?: GoogleAuthOptions);
6
- getProjectId(): Promise<string>;
7
- request(opts: GoogleAbstractedClientOps): Promise<unknown>;
8
- }
@@ -1,32 +0,0 @@
1
- import { GoogleAuth } from "google-auth-library";
2
- import { GoogleVertexAIStream } from "./googlevertexai-connection.js";
3
- class GoogleVertexAINodeStream extends GoogleVertexAIStream {
4
- constructor(data) {
5
- super();
6
- data.on("data", (data) => this.appendBuffer(data.toString()));
7
- data.on("end", () => this.closeBuffer());
8
- }
9
- }
10
- export class GAuthClient {
11
- constructor(options) {
12
- Object.defineProperty(this, "gauth", {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: void 0
17
- });
18
- this.gauth = new GoogleAuth(options);
19
- }
20
- async getProjectId() {
21
- return this.gauth.getProjectId();
22
- }
23
- async request(opts) {
24
- const ret = await this.gauth.request(opts);
25
- return opts.responseType !== "stream"
26
- ? ret
27
- : {
28
- ...ret,
29
- data: new GoogleVertexAINodeStream(ret.data),
30
- };
31
- }
32
- }
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebGoogleAuth = void 0;
4
- const google_1 = require("web-auth-library/google");
5
- const env_js_1 = require("./env.cjs");
6
- const googlevertexai_connection_js_1 = require("./googlevertexai-connection.cjs");
7
- class GoogleVertexAIResponseStream extends googlevertexai_connection_js_1.GoogleVertexAIStream {
8
- constructor(body) {
9
- super();
10
- Object.defineProperty(this, "decoder", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: void 0
15
- });
16
- this.decoder = new TextDecoder();
17
- if (body) {
18
- void this.run(body);
19
- }
20
- else {
21
- console.error("Unexpected empty body while streaming");
22
- }
23
- }
24
- async run(body) {
25
- const reader = body.getReader();
26
- let isDone = false;
27
- while (!isDone) {
28
- const { value, done } = await reader.read();
29
- if (!done) {
30
- const svalue = this.decoder.decode(value);
31
- this.appendBuffer(svalue);
32
- }
33
- else {
34
- isDone = done;
35
- this.closeBuffer();
36
- }
37
- }
38
- }
39
- }
40
- class WebGoogleAuth {
41
- constructor(options) {
42
- Object.defineProperty(this, "options", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: void 0
47
- });
48
- const accessToken = options?.accessToken;
49
- const credentials = options?.credentials ??
50
- (0, env_js_1.getEnvironmentVariable)("GOOGLE_VERTEX_AI_WEB_CREDENTIALS");
51
- if (credentials === undefined)
52
- throw new Error(`Credentials not found. Please set the GOOGLE_VERTEX_AI_WEB_CREDENTIALS environment variable or pass credentials into "authOptions.credentials".`);
53
- const scope = options?.scope ?? "https://www.googleapis.com/auth/cloud-platform";
54
- this.options = { ...options, accessToken, credentials, scope };
55
- }
56
- async getProjectId() {
57
- const credentials = (0, google_1.getCredentials)(this.options.credentials);
58
- return credentials.project_id;
59
- }
60
- async request(opts) {
61
- let { accessToken } = this.options;
62
- if (accessToken === undefined) {
63
- accessToken = await (0, google_1.getAccessToken)(this.options);
64
- }
65
- if (opts.url == null)
66
- throw new Error("Missing URL");
67
- const fetchOptions = {
68
- method: opts.method,
69
- headers: {
70
- Authorization: `Bearer ${accessToken}`,
71
- "Content-Type": "application/json",
72
- },
73
- };
74
- if (opts.data !== undefined) {
75
- fetchOptions.body = JSON.stringify(opts.data);
76
- }
77
- const res = await fetch(opts.url, fetchOptions);
78
- if (!res.ok) {
79
- const error = new Error(`Could not get access token for Vertex AI with status code: ${res.status}`);
80
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
- error.response = res;
82
- throw error;
83
- }
84
- return {
85
- data: opts.responseType === "json"
86
- ? await res.json()
87
- : new GoogleVertexAIResponseStream(res.body),
88
- config: {},
89
- status: res.status,
90
- statusText: res.statusText,
91
- headers: res.headers,
92
- request: { responseURL: res.url },
93
- };
94
- }
95
- }
96
- exports.WebGoogleAuth = WebGoogleAuth;
@@ -1,22 +0,0 @@
1
- import { Credentials } from "web-auth-library/google";
2
- import type { GoogleAbstractedClient, GoogleAbstractedClientOps } from "../types/googlevertexai-types.js";
3
- export type WebGoogleAuthOptions = {
4
- credentials: string | Credentials;
5
- scope?: string | string[];
6
- accessToken?: string;
7
- };
8
- export declare class WebGoogleAuth implements GoogleAbstractedClient {
9
- options: WebGoogleAuthOptions;
10
- constructor(options?: WebGoogleAuthOptions);
11
- getProjectId(): Promise<string>;
12
- request(opts: GoogleAbstractedClientOps): Promise<{
13
- data: any;
14
- config: {};
15
- status: number;
16
- statusText: string;
17
- headers: Headers;
18
- request: {
19
- responseURL: string;
20
- };
21
- }>;
22
- }
@@ -1,92 +0,0 @@
1
- import { getAccessToken, getCredentials, } from "web-auth-library/google";
2
- import { getEnvironmentVariable } from "./env.js";
3
- import { GoogleVertexAIStream } from "./googlevertexai-connection.js";
4
- class GoogleVertexAIResponseStream extends GoogleVertexAIStream {
5
- constructor(body) {
6
- super();
7
- Object.defineProperty(this, "decoder", {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value: void 0
12
- });
13
- this.decoder = new TextDecoder();
14
- if (body) {
15
- void this.run(body);
16
- }
17
- else {
18
- console.error("Unexpected empty body while streaming");
19
- }
20
- }
21
- async run(body) {
22
- const reader = body.getReader();
23
- let isDone = false;
24
- while (!isDone) {
25
- const { value, done } = await reader.read();
26
- if (!done) {
27
- const svalue = this.decoder.decode(value);
28
- this.appendBuffer(svalue);
29
- }
30
- else {
31
- isDone = done;
32
- this.closeBuffer();
33
- }
34
- }
35
- }
36
- }
37
- export class WebGoogleAuth {
38
- constructor(options) {
39
- Object.defineProperty(this, "options", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: void 0
44
- });
45
- const accessToken = options?.accessToken;
46
- const credentials = options?.credentials ??
47
- getEnvironmentVariable("GOOGLE_VERTEX_AI_WEB_CREDENTIALS");
48
- if (credentials === undefined)
49
- throw new Error(`Credentials not found. Please set the GOOGLE_VERTEX_AI_WEB_CREDENTIALS environment variable or pass credentials into "authOptions.credentials".`);
50
- const scope = options?.scope ?? "https://www.googleapis.com/auth/cloud-platform";
51
- this.options = { ...options, accessToken, credentials, scope };
52
- }
53
- async getProjectId() {
54
- const credentials = getCredentials(this.options.credentials);
55
- return credentials.project_id;
56
- }
57
- async request(opts) {
58
- let { accessToken } = this.options;
59
- if (accessToken === undefined) {
60
- accessToken = await getAccessToken(this.options);
61
- }
62
- if (opts.url == null)
63
- throw new Error("Missing URL");
64
- const fetchOptions = {
65
- method: opts.method,
66
- headers: {
67
- Authorization: `Bearer ${accessToken}`,
68
- "Content-Type": "application/json",
69
- },
70
- };
71
- if (opts.data !== undefined) {
72
- fetchOptions.body = JSON.stringify(opts.data);
73
- }
74
- const res = await fetch(opts.url, fetchOptions);
75
- if (!res.ok) {
76
- const error = new Error(`Could not get access token for Vertex AI with status code: ${res.status}`);
77
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- error.response = res;
79
- throw error;
80
- }
81
- return {
82
- data: opts.responseType === "json"
83
- ? await res.json()
84
- : new GoogleVertexAIResponseStream(res.body),
85
- config: {},
86
- status: res.status,
87
- statusText: res.statusText,
88
- headers: res.headers,
89
- request: { responseURL: res.url },
90
- };
91
- }
92
- }
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseWebSocketStream = void 0;
4
- /**
5
- * [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
6
- *
7
- * @see https://web.dev/websocketstream/
8
- */
9
- class BaseWebSocketStream {
10
- constructor(url, options = {}) {
11
- Object.defineProperty(this, "url", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: void 0
16
- });
17
- Object.defineProperty(this, "connection", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: void 0
22
- });
23
- Object.defineProperty(this, "closed", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- Object.defineProperty(this, "close", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: void 0
34
- });
35
- if (options.signal?.aborted) {
36
- throw new DOMException("This operation was aborted", "AbortError");
37
- }
38
- this.url = url;
39
- const ws = this.openWebSocket(url, options);
40
- const closeWithInfo = ({ code, reason } = {}) => ws.close(code, reason);
41
- this.connection = new Promise((resolve, reject) => {
42
- ws.onopen = () => {
43
- resolve({
44
- readable: new ReadableStream({
45
- start(controller) {
46
- ws.onmessage = ({ data }) => controller.enqueue(data);
47
- ws.onerror = (e) => controller.error(e);
48
- },
49
- cancel: closeWithInfo,
50
- }),
51
- writable: new WritableStream({
52
- write(chunk) {
53
- ws.send(chunk);
54
- },
55
- abort() {
56
- ws.close();
57
- },
58
- close: closeWithInfo,
59
- }),
60
- protocol: ws.protocol,
61
- extensions: ws.extensions,
62
- });
63
- ws.removeEventListener("error", reject);
64
- };
65
- ws.addEventListener("error", reject);
66
- });
67
- this.closed = new Promise((resolve, reject) => {
68
- ws.onclose = ({ code, reason }) => {
69
- resolve({ code, reason });
70
- ws.removeEventListener("error", reject);
71
- };
72
- ws.addEventListener("error", reject);
73
- });
74
- if (options.signal) {
75
- // eslint-disable-next-line no-param-reassign
76
- options.signal.onabort = () => ws.close();
77
- }
78
- this.close = closeWithInfo;
79
- }
80
- }
81
- exports.BaseWebSocketStream = BaseWebSocketStream;
@@ -1,27 +0,0 @@
1
- export interface WebSocketConnection<T extends Uint8Array | string = Uint8Array | string> {
2
- readable: ReadableStream<T>;
3
- writable: WritableStream<T>;
4
- protocol: string;
5
- extensions: string;
6
- }
7
- export interface WebSocketCloseInfo {
8
- code?: number;
9
- reason?: string;
10
- }
11
- export interface WebSocketStreamOptions {
12
- protocols?: string[];
13
- signal?: AbortSignal;
14
- }
15
- /**
16
- * [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
17
- *
18
- * @see https://web.dev/websocketstream/
19
- */
20
- export declare abstract class BaseWebSocketStream<T extends Uint8Array | string = Uint8Array | string> {
21
- readonly url: string;
22
- readonly connection: Promise<WebSocketConnection<T>>;
23
- readonly closed: Promise<WebSocketCloseInfo>;
24
- readonly close: (closeInfo?: WebSocketCloseInfo) => void;
25
- constructor(url: string, options?: WebSocketStreamOptions);
26
- abstract openWebSocket(url: string, options: WebSocketStreamOptions): WebSocket;
27
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
3
- *
4
- * @see https://web.dev/websocketstream/
5
- */
6
- export class BaseWebSocketStream {
7
- constructor(url, options = {}) {
8
- Object.defineProperty(this, "url", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: void 0
13
- });
14
- Object.defineProperty(this, "connection", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: void 0
19
- });
20
- Object.defineProperty(this, "closed", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: void 0
25
- });
26
- Object.defineProperty(this, "close", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- if (options.signal?.aborted) {
33
- throw new DOMException("This operation was aborted", "AbortError");
34
- }
35
- this.url = url;
36
- const ws = this.openWebSocket(url, options);
37
- const closeWithInfo = ({ code, reason } = {}) => ws.close(code, reason);
38
- this.connection = new Promise((resolve, reject) => {
39
- ws.onopen = () => {
40
- resolve({
41
- readable: new ReadableStream({
42
- start(controller) {
43
- ws.onmessage = ({ data }) => controller.enqueue(data);
44
- ws.onerror = (e) => controller.error(e);
45
- },
46
- cancel: closeWithInfo,
47
- }),
48
- writable: new WritableStream({
49
- write(chunk) {
50
- ws.send(chunk);
51
- },
52
- abort() {
53
- ws.close();
54
- },
55
- close: closeWithInfo,
56
- }),
57
- protocol: ws.protocol,
58
- extensions: ws.extensions,
59
- });
60
- ws.removeEventListener("error", reject);
61
- };
62
- ws.addEventListener("error", reject);
63
- });
64
- this.closed = new Promise((resolve, reject) => {
65
- ws.onclose = ({ code, reason }) => {
66
- resolve({ code, reason });
67
- ws.removeEventListener("error", reject);
68
- };
69
- ws.addEventListener("error", reject);
70
- });
71
- if (options.signal) {
72
- // eslint-disable-next-line no-param-reassign
73
- options.signal.onabort = () => ws.close();
74
- }
75
- this.close = closeWithInfo;
76
- }
77
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLlamaSession = exports.createLlamaContext = exports.createLlamaModel = void 0;
4
- const node_llama_cpp_1 = require("node-llama-cpp");
5
- function createLlamaModel(inputs) {
6
- const options = {
7
- gpuLayers: inputs?.gpuLayers,
8
- modelPath: inputs.modelPath,
9
- useMlock: inputs?.useMlock,
10
- useMmap: inputs?.useMmap,
11
- vocabOnly: inputs?.vocabOnly,
12
- };
13
- return new node_llama_cpp_1.LlamaModel(options);
14
- }
15
- exports.createLlamaModel = createLlamaModel;
16
- function createLlamaContext(model, inputs) {
17
- const options = {
18
- batchSize: inputs?.batchSize,
19
- contextSize: inputs?.contextSize,
20
- embedding: inputs?.embedding,
21
- f16Kv: inputs?.f16Kv,
22
- logitsAll: inputs?.logitsAll,
23
- model,
24
- prependBos: inputs?.prependBos,
25
- seed: inputs?.seed,
26
- threads: inputs?.threads,
27
- };
28
- return new node_llama_cpp_1.LlamaContext(options);
29
- }
30
- exports.createLlamaContext = createLlamaContext;
31
- function createLlamaSession(context) {
32
- return new node_llama_cpp_1.LlamaChatSession({ context });
33
- }
34
- exports.createLlamaSession = createLlamaSession;
@@ -1,46 +0,0 @@
1
- import { LlamaModel, LlamaContext, LlamaChatSession } from "node-llama-cpp";
2
- /**
3
- * Note that the modelPath is the only required parameter. For testing you
4
- * can set this in the environment variable `LLAMA_PATH`.
5
- */
6
- export interface LlamaBaseCppInputs {
7
- /** Prompt processing batch size. */
8
- batchSize?: number;
9
- /** Text context size. */
10
- contextSize?: number;
11
- /** Embedding mode only. */
12
- embedding?: boolean;
13
- /** Use fp16 for KV cache. */
14
- f16Kv?: boolean;
15
- /** Number of layers to store in VRAM. */
16
- gpuLayers?: number;
17
- /** The llama_eval() call computes all logits, not just the last one. */
18
- logitsAll?: boolean;
19
- /** */
20
- maxTokens?: number;
21
- /** Path to the model on the filesystem. */
22
- modelPath: string;
23
- /** Add the begining of sentence token. */
24
- prependBos?: boolean;
25
- /** If null, a random seed will be used. */
26
- seed?: null | number;
27
- /** The randomness of the responses, e.g. 0.1 deterministic, 1.5 creative, 0.8 balanced, 0 disables. */
28
- temperature?: number;
29
- /** Number of threads to use to evaluate tokens. */
30
- threads?: number;
31
- /** Trim whitespace from the end of the generated text Disabled by default. */
32
- trimWhitespaceSuffix?: boolean;
33
- /** Consider the n most likely tokens, where n is 1 to vocabulary size, 0 disables (uses full vocabulary). Note: only applies when `temperature` > 0. */
34
- topK?: number;
35
- /** Selects the smallest token set whose probability exceeds P, where P is between 0 - 1, 1 disables. Note: only applies when `temperature` > 0. */
36
- topP?: number;
37
- /** Force system to keep model in RAM. */
38
- useMlock?: boolean;
39
- /** Use mmap if possible. */
40
- useMmap?: boolean;
41
- /** Only load the vocabulary, no weights. */
42
- vocabOnly?: boolean;
43
- }
44
- export declare function createLlamaModel(inputs: LlamaBaseCppInputs): LlamaModel;
45
- export declare function createLlamaContext(model: LlamaModel, inputs: LlamaBaseCppInputs): LlamaContext;
46
- export declare function createLlamaSession(context: LlamaContext): LlamaChatSession;
@@ -1,28 +0,0 @@
1
- import { LlamaModel, LlamaContext, LlamaChatSession } from "node-llama-cpp";
2
- export function createLlamaModel(inputs) {
3
- const options = {
4
- gpuLayers: inputs?.gpuLayers,
5
- modelPath: inputs.modelPath,
6
- useMlock: inputs?.useMlock,
7
- useMmap: inputs?.useMmap,
8
- vocabOnly: inputs?.vocabOnly,
9
- };
10
- return new LlamaModel(options);
11
- }
12
- export function createLlamaContext(model, inputs) {
13
- const options = {
14
- batchSize: inputs?.batchSize,
15
- contextSize: inputs?.contextSize,
16
- embedding: inputs?.embedding,
17
- f16Kv: inputs?.f16Kv,
18
- logitsAll: inputs?.logitsAll,
19
- model,
20
- prependBos: inputs?.prependBos,
21
- seed: inputs?.seed,
22
- threads: inputs?.threads,
23
- };
24
- return new LlamaContext(options);
25
- }
26
- export function createLlamaSession(context) {
27
- return new LlamaChatSession({ context });
28
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureCacheExists = void 0;
4
- /* eslint-disable no-instanceof/no-instanceof */
5
- const sdk_1 = require("@gomomento/sdk");
6
- /**
7
- * Utility function to ensure that a Momento cache exists.
8
- * If the cache does not exist, it is created.
9
- *
10
- * @param client The Momento cache client.
11
- * @param cacheName The name of the cache to ensure exists.
12
- */
13
- async function ensureCacheExists(client, cacheName) {
14
- const createResponse = await client.createCache(cacheName);
15
- if (createResponse instanceof sdk_1.CreateCache.Success ||
16
- createResponse instanceof sdk_1.CreateCache.AlreadyExists) {
17
- // pass
18
- }
19
- else if (createResponse instanceof sdk_1.CreateCache.Error) {
20
- throw createResponse.innerException();
21
- }
22
- else {
23
- throw new Error(`Unknown response type: ${createResponse.toString()}`);
24
- }
25
- }
26
- exports.ensureCacheExists = ensureCacheExists;
@@ -1,9 +0,0 @@
1
- import { ICacheClient } from "@gomomento/sdk";
2
- /**
3
- * Utility function to ensure that a Momento cache exists.
4
- * If the cache does not exist, it is created.
5
- *
6
- * @param client The Momento cache client.
7
- * @param cacheName The name of the cache to ensure exists.
8
- */
9
- export declare function ensureCacheExists(client: ICacheClient, cacheName: string): Promise<void>;
@@ -1,22 +0,0 @@
1
- /* eslint-disable no-instanceof/no-instanceof */
2
- import { CreateCache } from "@gomomento/sdk";
3
- /**
4
- * Utility function to ensure that a Momento cache exists.
5
- * If the cache does not exist, it is created.
6
- *
7
- * @param client The Momento cache client.
8
- * @param cacheName The name of the cache to ensure exists.
9
- */
10
- export async function ensureCacheExists(client, cacheName) {
11
- const createResponse = await client.createCache(cacheName);
12
- if (createResponse instanceof CreateCache.Success ||
13
- createResponse instanceof CreateCache.AlreadyExists) {
14
- // pass
15
- }
16
- else if (createResponse instanceof CreateCache.Error) {
17
- throw createResponse.innerException();
18
- }
19
- else {
20
- throw new Error(`Unknown response type: ${createResponse.toString()}`);
21
- }
22
- }