langchain 0.0.180 → 0.0.181
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/cache/base.cjs +2 -5
- package/dist/cache/base.js +2 -2
- package/dist/embeddings/cache_backed.cjs +2 -5
- package/dist/embeddings/cache_backed.js +2 -2
- package/dist/embeddings/voyage.cjs +120 -0
- package/dist/embeddings/voyage.d.ts +66 -0
- package/dist/embeddings/voyage.js +116 -0
- package/dist/load/import_map.cjs +3 -2
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -0
- package/dist/util/js-sha1/hash.cjs +358 -0
- package/dist/util/js-sha1/hash.d.ts +1 -0
- package/dist/util/js-sha1/hash.js +355 -0
- package/dist/util/stream.cjs +4 -1
- package/dist/util/stream.d.ts +4 -1
- package/dist/util/stream.js +4 -1
- package/embeddings/voyage.cjs +1 -0
- package/embeddings/voyage.d.ts +1 -0
- package/embeddings/voyage.js +1 -0
- package/package.json +10 -4
package/dist/cache/base.cjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.serializeGeneration = exports.deserializeStoredGeneration = exports.getCacheKey = void 0;
|
|
7
|
-
const
|
|
4
|
+
const hash_js_1 = require("../util/js-sha1/hash.cjs");
|
|
8
5
|
const index_js_1 = require("../schema/index.cjs");
|
|
9
6
|
/**
|
|
10
7
|
* This cache key should be consistent across all versions of langchain.
|
|
@@ -16,7 +13,7 @@ const index_js_1 = require("../schema/index.cjs");
|
|
|
16
13
|
*
|
|
17
14
|
* TODO: Make cache key consistent across versions of langchain.
|
|
18
15
|
*/
|
|
19
|
-
const getCacheKey = (...strings) => (0,
|
|
16
|
+
const getCacheKey = (...strings) => (0, hash_js_1.insecureHash)(strings.join("_"));
|
|
20
17
|
exports.getCacheKey = getCacheKey;
|
|
21
18
|
function deserializeStoredGeneration(storedGeneration) {
|
|
22
19
|
if (storedGeneration.message !== undefined) {
|
package/dist/cache/base.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { insecureHash } from "../util/js-sha1/hash.js";
|
|
2
2
|
import { mapStoredMessageToChatMessage, } from "../schema/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* This cache key should be consistent across all versions of langchain.
|
|
@@ -10,7 +10,7 @@ import { mapStoredMessageToChatMessage, } from "../schema/index.js";
|
|
|
10
10
|
*
|
|
11
11
|
* TODO: Make cache key consistent across versions of langchain.
|
|
12
12
|
*/
|
|
13
|
-
export const getCacheKey = (...strings) =>
|
|
13
|
+
export const getCacheKey = (...strings) => insecureHash(strings.join("_"));
|
|
14
14
|
export function deserializeStoredGeneration(storedGeneration) {
|
|
15
15
|
if (storedGeneration.message !== undefined) {
|
|
16
16
|
return {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CacheBackedEmbeddings = void 0;
|
|
7
|
-
const
|
|
4
|
+
const hash_js_1 = require("../util/js-sha1/hash.cjs");
|
|
8
5
|
const encoder_backed_js_1 = require("../storage/encoder_backed.cjs");
|
|
9
6
|
const base_js_1 = require("./base.cjs");
|
|
10
7
|
/**
|
|
@@ -96,7 +93,7 @@ class CacheBackedEmbeddings extends base_js_1.Embeddings {
|
|
|
96
93
|
const decoder = new TextDecoder();
|
|
97
94
|
const encoderBackedStore = new encoder_backed_js_1.EncoderBackedStore({
|
|
98
95
|
store: documentEmbeddingStore,
|
|
99
|
-
keyEncoder: (key) => (options?.namespace ?? "") + (0,
|
|
96
|
+
keyEncoder: (key) => (options?.namespace ?? "") + (0, hash_js_1.insecureHash)(key),
|
|
100
97
|
valueSerializer: (value) => encoder.encode(JSON.stringify(value)),
|
|
101
98
|
valueDeserializer: (serializedValue) => JSON.parse(decoder.decode(serializedValue)),
|
|
102
99
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { insecureHash } from "../util/js-sha1/hash.js";
|
|
2
2
|
import { EncoderBackedStore } from "../storage/encoder_backed.js";
|
|
3
3
|
import { Embeddings } from "./base.js";
|
|
4
4
|
/**
|
|
@@ -90,7 +90,7 @@ export class CacheBackedEmbeddings extends Embeddings {
|
|
|
90
90
|
const decoder = new TextDecoder();
|
|
91
91
|
const encoderBackedStore = new EncoderBackedStore({
|
|
92
92
|
store: documentEmbeddingStore,
|
|
93
|
-
keyEncoder: (key) => (options?.namespace ?? "") +
|
|
93
|
+
keyEncoder: (key) => (options?.namespace ?? "") + insecureHash(key),
|
|
94
94
|
valueSerializer: (value) => encoder.encode(JSON.stringify(value)),
|
|
95
95
|
valueDeserializer: (serializedValue) => JSON.parse(decoder.decode(serializedValue)),
|
|
96
96
|
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoyageEmbeddings = void 0;
|
|
4
|
+
const chunk_js_1 = require("../util/chunk.cjs");
|
|
5
|
+
const env_js_1 = require("../util/env.cjs");
|
|
6
|
+
const base_js_1 = require("./base.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* A class for generating embeddings using the Voyage AI API.
|
|
9
|
+
*/
|
|
10
|
+
class VoyageEmbeddings extends base_js_1.Embeddings {
|
|
11
|
+
/**
|
|
12
|
+
* Constructor for the VoyageEmbeddings class.
|
|
13
|
+
* @param fields - An optional object with properties to configure the instance.
|
|
14
|
+
*/
|
|
15
|
+
constructor(fields) {
|
|
16
|
+
const fieldsWithDefaults = { ...fields };
|
|
17
|
+
super(fieldsWithDefaults);
|
|
18
|
+
Object.defineProperty(this, "modelName", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: "voyage-01"
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "batchSize", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: 8
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "apiKey", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "basePath", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: "https://api.voyageai.com/v1"
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(this, "apiUrl", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(this, "headers", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: void 0
|
|
53
|
+
});
|
|
54
|
+
const apiKey = fieldsWithDefaults?.apiKey || (0, env_js_1.getEnvironmentVariable)("VOYAGEAI_API_KEY");
|
|
55
|
+
if (!apiKey) {
|
|
56
|
+
throw new Error("Voyage AI API key not found");
|
|
57
|
+
}
|
|
58
|
+
this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
|
|
59
|
+
this.batchSize = fieldsWithDefaults?.batchSize ?? this.batchSize;
|
|
60
|
+
this.apiKey = apiKey;
|
|
61
|
+
this.apiUrl = `${this.basePath}/embeddings`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Generates embeddings for an array of texts.
|
|
65
|
+
* @param texts - An array of strings to generate embeddings for.
|
|
66
|
+
* @returns A Promise that resolves to an array of embeddings.
|
|
67
|
+
*/
|
|
68
|
+
async embedDocuments(texts) {
|
|
69
|
+
const batches = (0, chunk_js_1.chunkArray)(texts, this.batchSize);
|
|
70
|
+
const batchRequests = batches.map((batch) => this.embeddingWithRetry({
|
|
71
|
+
model: this.modelName,
|
|
72
|
+
input: batch,
|
|
73
|
+
}));
|
|
74
|
+
const batchResponses = await Promise.all(batchRequests);
|
|
75
|
+
const embeddings = [];
|
|
76
|
+
for (let i = 0; i < batchResponses.length; i += 1) {
|
|
77
|
+
const batch = batches[i];
|
|
78
|
+
const { data: batchResponse } = batchResponses[i];
|
|
79
|
+
for (let j = 0; j < batch.length; j += 1) {
|
|
80
|
+
embeddings.push(batchResponse[j].embedding);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return embeddings;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Generates an embedding for a single text.
|
|
87
|
+
* @param text - A string to generate an embedding for.
|
|
88
|
+
* @returns A Promise that resolves to an array of numbers representing the embedding.
|
|
89
|
+
*/
|
|
90
|
+
async embedQuery(text) {
|
|
91
|
+
const { data } = await this.embeddingWithRetry({
|
|
92
|
+
model: this.modelName,
|
|
93
|
+
input: text,
|
|
94
|
+
});
|
|
95
|
+
return data[0].embedding;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Makes a request to the Voyage AI API to generate embeddings for an array of texts.
|
|
99
|
+
* @param request - An object with properties to configure the request.
|
|
100
|
+
* @returns A Promise that resolves to the response from the Voyage AI API.
|
|
101
|
+
*/
|
|
102
|
+
async embeddingWithRetry(request) {
|
|
103
|
+
const makeCompletionRequest = async () => {
|
|
104
|
+
const url = `${this.apiUrl}`;
|
|
105
|
+
const response = await fetch(url, {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: {
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
110
|
+
...this.headers,
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify(request),
|
|
113
|
+
});
|
|
114
|
+
const json = await response.json();
|
|
115
|
+
return json;
|
|
116
|
+
};
|
|
117
|
+
return this.caller.call(makeCompletionRequest);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.VoyageEmbeddings = VoyageEmbeddings;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Embeddings, EmbeddingsParams } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interface that extends EmbeddingsParams and defines additional
|
|
4
|
+
* parameters specific to the VoyageEmbeddings class.
|
|
5
|
+
*/
|
|
6
|
+
export interface VoyageEmbeddingsParams extends EmbeddingsParams {
|
|
7
|
+
modelName: string;
|
|
8
|
+
/**
|
|
9
|
+
* The maximum number of documents to embed in a single request. This is
|
|
10
|
+
* limited by the Voyage AI API to a maximum of 8.
|
|
11
|
+
*/
|
|
12
|
+
batchSize?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Interface for the request body to generate embeddings.
|
|
16
|
+
*/
|
|
17
|
+
export interface CreateVoyageEmbeddingRequest {
|
|
18
|
+
/**
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @memberof CreateVoyageEmbeddingRequest
|
|
21
|
+
*/
|
|
22
|
+
model: string;
|
|
23
|
+
/**
|
|
24
|
+
* Text to generate vector expectation
|
|
25
|
+
* @type {CreateEmbeddingRequestInput}
|
|
26
|
+
* @memberof CreateVoyageEmbeddingRequest
|
|
27
|
+
*/
|
|
28
|
+
input: string | string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A class for generating embeddings using the Voyage AI API.
|
|
32
|
+
*/
|
|
33
|
+
export declare class VoyageEmbeddings extends Embeddings implements VoyageEmbeddingsParams {
|
|
34
|
+
modelName: string;
|
|
35
|
+
batchSize: number;
|
|
36
|
+
private apiKey;
|
|
37
|
+
basePath?: string;
|
|
38
|
+
apiUrl: string;
|
|
39
|
+
headers?: Record<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* Constructor for the VoyageEmbeddings class.
|
|
42
|
+
* @param fields - An optional object with properties to configure the instance.
|
|
43
|
+
*/
|
|
44
|
+
constructor(fields?: Partial<VoyageEmbeddingsParams> & {
|
|
45
|
+
verbose?: boolean;
|
|
46
|
+
apiKey?: string;
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Generates embeddings for an array of texts.
|
|
50
|
+
* @param texts - An array of strings to generate embeddings for.
|
|
51
|
+
* @returns A Promise that resolves to an array of embeddings.
|
|
52
|
+
*/
|
|
53
|
+
embedDocuments(texts: string[]): Promise<number[][]>;
|
|
54
|
+
/**
|
|
55
|
+
* Generates an embedding for a single text.
|
|
56
|
+
* @param text - A string to generate an embedding for.
|
|
57
|
+
* @returns A Promise that resolves to an array of numbers representing the embedding.
|
|
58
|
+
*/
|
|
59
|
+
embedQuery(text: string): Promise<number[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Makes a request to the Voyage AI API to generate embeddings for an array of texts.
|
|
62
|
+
* @param request - An object with properties to configure the request.
|
|
63
|
+
* @returns A Promise that resolves to the response from the Voyage AI API.
|
|
64
|
+
*/
|
|
65
|
+
private embeddingWithRetry;
|
|
66
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { chunkArray } from "../util/chunk.js";
|
|
2
|
+
import { getEnvironmentVariable } from "../util/env.js";
|
|
3
|
+
import { Embeddings } from "./base.js";
|
|
4
|
+
/**
|
|
5
|
+
* A class for generating embeddings using the Voyage AI API.
|
|
6
|
+
*/
|
|
7
|
+
export class VoyageEmbeddings extends Embeddings {
|
|
8
|
+
/**
|
|
9
|
+
* Constructor for the VoyageEmbeddings class.
|
|
10
|
+
* @param fields - An optional object with properties to configure the instance.
|
|
11
|
+
*/
|
|
12
|
+
constructor(fields) {
|
|
13
|
+
const fieldsWithDefaults = { ...fields };
|
|
14
|
+
super(fieldsWithDefaults);
|
|
15
|
+
Object.defineProperty(this, "modelName", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: "voyage-01"
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(this, "batchSize", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: 8
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "apiKey", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: void 0
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(this, "basePath", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: "https://api.voyageai.com/v1"
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(this, "apiUrl", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(this, "headers", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
51
|
+
const apiKey = fieldsWithDefaults?.apiKey || getEnvironmentVariable("VOYAGEAI_API_KEY");
|
|
52
|
+
if (!apiKey) {
|
|
53
|
+
throw new Error("Voyage AI API key not found");
|
|
54
|
+
}
|
|
55
|
+
this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
|
|
56
|
+
this.batchSize = fieldsWithDefaults?.batchSize ?? this.batchSize;
|
|
57
|
+
this.apiKey = apiKey;
|
|
58
|
+
this.apiUrl = `${this.basePath}/embeddings`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates embeddings for an array of texts.
|
|
62
|
+
* @param texts - An array of strings to generate embeddings for.
|
|
63
|
+
* @returns A Promise that resolves to an array of embeddings.
|
|
64
|
+
*/
|
|
65
|
+
async embedDocuments(texts) {
|
|
66
|
+
const batches = chunkArray(texts, this.batchSize);
|
|
67
|
+
const batchRequests = batches.map((batch) => this.embeddingWithRetry({
|
|
68
|
+
model: this.modelName,
|
|
69
|
+
input: batch,
|
|
70
|
+
}));
|
|
71
|
+
const batchResponses = await Promise.all(batchRequests);
|
|
72
|
+
const embeddings = [];
|
|
73
|
+
for (let i = 0; i < batchResponses.length; i += 1) {
|
|
74
|
+
const batch = batches[i];
|
|
75
|
+
const { data: batchResponse } = batchResponses[i];
|
|
76
|
+
for (let j = 0; j < batch.length; j += 1) {
|
|
77
|
+
embeddings.push(batchResponse[j].embedding);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return embeddings;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Generates an embedding for a single text.
|
|
84
|
+
* @param text - A string to generate an embedding for.
|
|
85
|
+
* @returns A Promise that resolves to an array of numbers representing the embedding.
|
|
86
|
+
*/
|
|
87
|
+
async embedQuery(text) {
|
|
88
|
+
const { data } = await this.embeddingWithRetry({
|
|
89
|
+
model: this.modelName,
|
|
90
|
+
input: text,
|
|
91
|
+
});
|
|
92
|
+
return data[0].embedding;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Makes a request to the Voyage AI API to generate embeddings for an array of texts.
|
|
96
|
+
* @param request - An object with properties to configure the request.
|
|
97
|
+
* @returns A Promise that resolves to the response from the Voyage AI API.
|
|
98
|
+
*/
|
|
99
|
+
async embeddingWithRetry(request) {
|
|
100
|
+
const makeCompletionRequest = async () => {
|
|
101
|
+
const url = `${this.apiUrl}`;
|
|
102
|
+
const response = await fetch(url, {
|
|
103
|
+
method: "POST",
|
|
104
|
+
headers: {
|
|
105
|
+
"Content-Type": "application/json",
|
|
106
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
107
|
+
...this.headers,
|
|
108
|
+
},
|
|
109
|
+
body: JSON.stringify(request),
|
|
110
|
+
});
|
|
111
|
+
const json = await response.json();
|
|
112
|
+
return json;
|
|
113
|
+
};
|
|
114
|
+
return this.caller.call(makeCompletionRequest);
|
|
115
|
+
}
|
|
116
|
+
}
|
package/dist/load/import_map.cjs
CHANGED
|
@@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
28
|
-
exports.runnables__remote = exports.evaluation = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.util__document = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = exports.schema__prompt_template = exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = void 0;
|
|
27
|
+
exports.chat_models__cloudflare_workersai = exports.chat_models__anthropic = exports.chat_models__openai = exports.chat_models__base = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__web__searchapi = exports.document_loaders__base = exports.document = exports.memory = exports.text_splitter = exports.vectorstores__xata = exports.vectorstores__vectara = exports.vectorstores__prisma = exports.vectorstores__memory = exports.vectorstores__base = exports.prompts = exports.llms__fake = exports.llms__yandex = exports.llms__fireworks = exports.llms__ollama = exports.llms__cloudflare_workersai = exports.llms__aleph_alpha = exports.llms__ai21 = exports.llms__openai = exports.llms__base = exports.embeddings__voyage = exports.embeddings__minimax = exports.embeddings__openai = exports.embeddings__ollama = exports.embeddings__fake = exports.embeddings__cache_backed = exports.embeddings__base = exports.chains__openai_functions = exports.chains__combine_documents__reduce = exports.chains = exports.tools__render = exports.tools = exports.base_language = exports.agents__openai__output_parser = exports.agents__xml__output_parser = exports.agents__react__output_parser = exports.agents__format_scratchpad__log_to_message = exports.agents__format_scratchpad__xml = exports.agents__format_scratchpad__log = exports.agents__format_scratchpad = exports.agents__toolkits = exports.agents = exports.load__serializable = void 0;
|
|
28
|
+
exports.runnables__remote = exports.evaluation = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.util__document = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = exports.schema__prompt_template = exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = exports.chat_models__fireworks = void 0;
|
|
29
29
|
exports.load__serializable = __importStar(require("../load/serializable.cjs"));
|
|
30
30
|
exports.agents = __importStar(require("../agents/index.cjs"));
|
|
31
31
|
exports.agents__toolkits = __importStar(require("../agents/toolkits/index.cjs"));
|
|
@@ -48,6 +48,7 @@ exports.embeddings__fake = __importStar(require("../embeddings/fake.cjs"));
|
|
|
48
48
|
exports.embeddings__ollama = __importStar(require("../embeddings/ollama.cjs"));
|
|
49
49
|
exports.embeddings__openai = __importStar(require("../embeddings/openai.cjs"));
|
|
50
50
|
exports.embeddings__minimax = __importStar(require("../embeddings/minimax.cjs"));
|
|
51
|
+
exports.embeddings__voyage = __importStar(require("../embeddings/voyage.cjs"));
|
|
51
52
|
exports.llms__base = __importStar(require("../llms/base.cjs"));
|
|
52
53
|
exports.llms__openai = __importStar(require("../llms/openai.cjs"));
|
|
53
54
|
exports.llms__ai21 = __importStar(require("../llms/ai21.cjs"));
|
|
@@ -20,6 +20,7 @@ export * as embeddings__fake from "../embeddings/fake.js";
|
|
|
20
20
|
export * as embeddings__ollama from "../embeddings/ollama.js";
|
|
21
21
|
export * as embeddings__openai from "../embeddings/openai.js";
|
|
22
22
|
export * as embeddings__minimax from "../embeddings/minimax.js";
|
|
23
|
+
export * as embeddings__voyage from "../embeddings/voyage.js";
|
|
23
24
|
export * as llms__base from "../llms/base.js";
|
|
24
25
|
export * as llms__openai from "../llms/openai.js";
|
|
25
26
|
export * as llms__ai21 from "../llms/ai21.js";
|
package/dist/load/import_map.js
CHANGED
|
@@ -21,6 +21,7 @@ export * as embeddings__fake from "../embeddings/fake.js";
|
|
|
21
21
|
export * as embeddings__ollama from "../embeddings/ollama.js";
|
|
22
22
|
export * as embeddings__openai from "../embeddings/openai.js";
|
|
23
23
|
export * as embeddings__minimax from "../embeddings/minimax.js";
|
|
24
|
+
export * as embeddings__voyage from "../embeddings/voyage.js";
|
|
24
25
|
export * as llms__base from "../llms/base.js";
|
|
25
26
|
export * as llms__openai from "../llms/openai.js";
|
|
26
27
|
export * as llms__ai21 from "../llms/ai21.js";
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Inlined to deal with portability issues with importing crypto module
|
|
3
|
+
/*
|
|
4
|
+
* [js-sha1]{@link https://github.com/emn178/js-sha1}
|
|
5
|
+
*
|
|
6
|
+
* @version 0.6.0
|
|
7
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
8
|
+
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
/*jslint bitwise: true */
|
|
12
|
+
"use strict";
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.insecureHash = void 0;
|
|
15
|
+
var root = typeof window === "object" ? window : {};
|
|
16
|
+
var HEX_CHARS = "0123456789abcdef".split("");
|
|
17
|
+
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
18
|
+
var SHIFT = [24, 16, 8, 0];
|
|
19
|
+
var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
|
|
20
|
+
var blocks = [];
|
|
21
|
+
function Sha1(sharedMemory) {
|
|
22
|
+
if (sharedMemory) {
|
|
23
|
+
blocks[0] =
|
|
24
|
+
blocks[16] =
|
|
25
|
+
blocks[1] =
|
|
26
|
+
blocks[2] =
|
|
27
|
+
blocks[3] =
|
|
28
|
+
blocks[4] =
|
|
29
|
+
blocks[5] =
|
|
30
|
+
blocks[6] =
|
|
31
|
+
blocks[7] =
|
|
32
|
+
blocks[8] =
|
|
33
|
+
blocks[9] =
|
|
34
|
+
blocks[10] =
|
|
35
|
+
blocks[11] =
|
|
36
|
+
blocks[12] =
|
|
37
|
+
blocks[13] =
|
|
38
|
+
blocks[14] =
|
|
39
|
+
blocks[15] =
|
|
40
|
+
0;
|
|
41
|
+
this.blocks = blocks;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
45
|
+
}
|
|
46
|
+
this.h0 = 0x67452301;
|
|
47
|
+
this.h1 = 0xefcdab89;
|
|
48
|
+
this.h2 = 0x98badcfe;
|
|
49
|
+
this.h3 = 0x10325476;
|
|
50
|
+
this.h4 = 0xc3d2e1f0;
|
|
51
|
+
this.block = this.start = this.bytes = this.hBytes = 0;
|
|
52
|
+
this.finalized = this.hashed = false;
|
|
53
|
+
this.first = true;
|
|
54
|
+
}
|
|
55
|
+
Sha1.prototype.update = function (message) {
|
|
56
|
+
if (this.finalized) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var notString = typeof message !== "string";
|
|
60
|
+
if (notString && message.constructor === root.ArrayBuffer) {
|
|
61
|
+
message = new Uint8Array(message);
|
|
62
|
+
}
|
|
63
|
+
var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
|
|
64
|
+
while (index < length) {
|
|
65
|
+
if (this.hashed) {
|
|
66
|
+
this.hashed = false;
|
|
67
|
+
blocks[0] = this.block;
|
|
68
|
+
blocks[16] =
|
|
69
|
+
blocks[1] =
|
|
70
|
+
blocks[2] =
|
|
71
|
+
blocks[3] =
|
|
72
|
+
blocks[4] =
|
|
73
|
+
blocks[5] =
|
|
74
|
+
blocks[6] =
|
|
75
|
+
blocks[7] =
|
|
76
|
+
blocks[8] =
|
|
77
|
+
blocks[9] =
|
|
78
|
+
blocks[10] =
|
|
79
|
+
blocks[11] =
|
|
80
|
+
blocks[12] =
|
|
81
|
+
blocks[13] =
|
|
82
|
+
blocks[14] =
|
|
83
|
+
blocks[15] =
|
|
84
|
+
0;
|
|
85
|
+
}
|
|
86
|
+
if (notString) {
|
|
87
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
88
|
+
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
93
|
+
code = message.charCodeAt(index);
|
|
94
|
+
if (code < 0x80) {
|
|
95
|
+
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
|
96
|
+
}
|
|
97
|
+
else if (code < 0x800) {
|
|
98
|
+
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
|
|
99
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
100
|
+
}
|
|
101
|
+
else if (code < 0xd800 || code >= 0xe000) {
|
|
102
|
+
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
|
|
103
|
+
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
104
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
code =
|
|
108
|
+
0x10000 +
|
|
109
|
+
(((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
|
110
|
+
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
|
|
111
|
+
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
|
|
112
|
+
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
113
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
this.lastByteIndex = i;
|
|
118
|
+
this.bytes += i - this.start;
|
|
119
|
+
if (i >= 64) {
|
|
120
|
+
this.block = blocks[16];
|
|
121
|
+
this.start = i - 64;
|
|
122
|
+
this.hash();
|
|
123
|
+
this.hashed = true;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.start = i;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (this.bytes > 4294967295) {
|
|
130
|
+
this.hBytes += (this.bytes / 4294967296) << 0;
|
|
131
|
+
this.bytes = this.bytes % 4294967296;
|
|
132
|
+
}
|
|
133
|
+
return this;
|
|
134
|
+
};
|
|
135
|
+
Sha1.prototype.finalize = function () {
|
|
136
|
+
if (this.finalized) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.finalized = true;
|
|
140
|
+
var blocks = this.blocks, i = this.lastByteIndex;
|
|
141
|
+
blocks[16] = this.block;
|
|
142
|
+
blocks[i >> 2] |= EXTRA[i & 3];
|
|
143
|
+
this.block = blocks[16];
|
|
144
|
+
if (i >= 56) {
|
|
145
|
+
if (!this.hashed) {
|
|
146
|
+
this.hash();
|
|
147
|
+
}
|
|
148
|
+
blocks[0] = this.block;
|
|
149
|
+
blocks[16] =
|
|
150
|
+
blocks[1] =
|
|
151
|
+
blocks[2] =
|
|
152
|
+
blocks[3] =
|
|
153
|
+
blocks[4] =
|
|
154
|
+
blocks[5] =
|
|
155
|
+
blocks[6] =
|
|
156
|
+
blocks[7] =
|
|
157
|
+
blocks[8] =
|
|
158
|
+
blocks[9] =
|
|
159
|
+
blocks[10] =
|
|
160
|
+
blocks[11] =
|
|
161
|
+
blocks[12] =
|
|
162
|
+
blocks[13] =
|
|
163
|
+
blocks[14] =
|
|
164
|
+
blocks[15] =
|
|
165
|
+
0;
|
|
166
|
+
}
|
|
167
|
+
blocks[14] = (this.hBytes << 3) | (this.bytes >>> 29);
|
|
168
|
+
blocks[15] = this.bytes << 3;
|
|
169
|
+
this.hash();
|
|
170
|
+
};
|
|
171
|
+
Sha1.prototype.hash = function () {
|
|
172
|
+
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4;
|
|
173
|
+
var f, j, t, blocks = this.blocks;
|
|
174
|
+
for (j = 16; j < 80; ++j) {
|
|
175
|
+
t = blocks[j - 3] ^ blocks[j - 8] ^ blocks[j - 14] ^ blocks[j - 16];
|
|
176
|
+
blocks[j] = (t << 1) | (t >>> 31);
|
|
177
|
+
}
|
|
178
|
+
for (j = 0; j < 20; j += 5) {
|
|
179
|
+
f = (b & c) | (~b & d);
|
|
180
|
+
t = (a << 5) | (a >>> 27);
|
|
181
|
+
e = (t + f + e + 1518500249 + blocks[j]) << 0;
|
|
182
|
+
b = (b << 30) | (b >>> 2);
|
|
183
|
+
f = (a & b) | (~a & c);
|
|
184
|
+
t = (e << 5) | (e >>> 27);
|
|
185
|
+
d = (t + f + d + 1518500249 + blocks[j + 1]) << 0;
|
|
186
|
+
a = (a << 30) | (a >>> 2);
|
|
187
|
+
f = (e & a) | (~e & b);
|
|
188
|
+
t = (d << 5) | (d >>> 27);
|
|
189
|
+
c = (t + f + c + 1518500249 + blocks[j + 2]) << 0;
|
|
190
|
+
e = (e << 30) | (e >>> 2);
|
|
191
|
+
f = (d & e) | (~d & a);
|
|
192
|
+
t = (c << 5) | (c >>> 27);
|
|
193
|
+
b = (t + f + b + 1518500249 + blocks[j + 3]) << 0;
|
|
194
|
+
d = (d << 30) | (d >>> 2);
|
|
195
|
+
f = (c & d) | (~c & e);
|
|
196
|
+
t = (b << 5) | (b >>> 27);
|
|
197
|
+
a = (t + f + a + 1518500249 + blocks[j + 4]) << 0;
|
|
198
|
+
c = (c << 30) | (c >>> 2);
|
|
199
|
+
}
|
|
200
|
+
for (; j < 40; j += 5) {
|
|
201
|
+
f = b ^ c ^ d;
|
|
202
|
+
t = (a << 5) | (a >>> 27);
|
|
203
|
+
e = (t + f + e + 1859775393 + blocks[j]) << 0;
|
|
204
|
+
b = (b << 30) | (b >>> 2);
|
|
205
|
+
f = a ^ b ^ c;
|
|
206
|
+
t = (e << 5) | (e >>> 27);
|
|
207
|
+
d = (t + f + d + 1859775393 + blocks[j + 1]) << 0;
|
|
208
|
+
a = (a << 30) | (a >>> 2);
|
|
209
|
+
f = e ^ a ^ b;
|
|
210
|
+
t = (d << 5) | (d >>> 27);
|
|
211
|
+
c = (t + f + c + 1859775393 + blocks[j + 2]) << 0;
|
|
212
|
+
e = (e << 30) | (e >>> 2);
|
|
213
|
+
f = d ^ e ^ a;
|
|
214
|
+
t = (c << 5) | (c >>> 27);
|
|
215
|
+
b = (t + f + b + 1859775393 + blocks[j + 3]) << 0;
|
|
216
|
+
d = (d << 30) | (d >>> 2);
|
|
217
|
+
f = c ^ d ^ e;
|
|
218
|
+
t = (b << 5) | (b >>> 27);
|
|
219
|
+
a = (t + f + a + 1859775393 + blocks[j + 4]) << 0;
|
|
220
|
+
c = (c << 30) | (c >>> 2);
|
|
221
|
+
}
|
|
222
|
+
for (; j < 60; j += 5) {
|
|
223
|
+
f = (b & c) | (b & d) | (c & d);
|
|
224
|
+
t = (a << 5) | (a >>> 27);
|
|
225
|
+
e = (t + f + e - 1894007588 + blocks[j]) << 0;
|
|
226
|
+
b = (b << 30) | (b >>> 2);
|
|
227
|
+
f = (a & b) | (a & c) | (b & c);
|
|
228
|
+
t = (e << 5) | (e >>> 27);
|
|
229
|
+
d = (t + f + d - 1894007588 + blocks[j + 1]) << 0;
|
|
230
|
+
a = (a << 30) | (a >>> 2);
|
|
231
|
+
f = (e & a) | (e & b) | (a & b);
|
|
232
|
+
t = (d << 5) | (d >>> 27);
|
|
233
|
+
c = (t + f + c - 1894007588 + blocks[j + 2]) << 0;
|
|
234
|
+
e = (e << 30) | (e >>> 2);
|
|
235
|
+
f = (d & e) | (d & a) | (e & a);
|
|
236
|
+
t = (c << 5) | (c >>> 27);
|
|
237
|
+
b = (t + f + b - 1894007588 + blocks[j + 3]) << 0;
|
|
238
|
+
d = (d << 30) | (d >>> 2);
|
|
239
|
+
f = (c & d) | (c & e) | (d & e);
|
|
240
|
+
t = (b << 5) | (b >>> 27);
|
|
241
|
+
a = (t + f + a - 1894007588 + blocks[j + 4]) << 0;
|
|
242
|
+
c = (c << 30) | (c >>> 2);
|
|
243
|
+
}
|
|
244
|
+
for (; j < 80; j += 5) {
|
|
245
|
+
f = b ^ c ^ d;
|
|
246
|
+
t = (a << 5) | (a >>> 27);
|
|
247
|
+
e = (t + f + e - 899497514 + blocks[j]) << 0;
|
|
248
|
+
b = (b << 30) | (b >>> 2);
|
|
249
|
+
f = a ^ b ^ c;
|
|
250
|
+
t = (e << 5) | (e >>> 27);
|
|
251
|
+
d = (t + f + d - 899497514 + blocks[j + 1]) << 0;
|
|
252
|
+
a = (a << 30) | (a >>> 2);
|
|
253
|
+
f = e ^ a ^ b;
|
|
254
|
+
t = (d << 5) | (d >>> 27);
|
|
255
|
+
c = (t + f + c - 899497514 + blocks[j + 2]) << 0;
|
|
256
|
+
e = (e << 30) | (e >>> 2);
|
|
257
|
+
f = d ^ e ^ a;
|
|
258
|
+
t = (c << 5) | (c >>> 27);
|
|
259
|
+
b = (t + f + b - 899497514 + blocks[j + 3]) << 0;
|
|
260
|
+
d = (d << 30) | (d >>> 2);
|
|
261
|
+
f = c ^ d ^ e;
|
|
262
|
+
t = (b << 5) | (b >>> 27);
|
|
263
|
+
a = (t + f + a - 899497514 + blocks[j + 4]) << 0;
|
|
264
|
+
c = (c << 30) | (c >>> 2);
|
|
265
|
+
}
|
|
266
|
+
this.h0 = (this.h0 + a) << 0;
|
|
267
|
+
this.h1 = (this.h1 + b) << 0;
|
|
268
|
+
this.h2 = (this.h2 + c) << 0;
|
|
269
|
+
this.h3 = (this.h3 + d) << 0;
|
|
270
|
+
this.h4 = (this.h4 + e) << 0;
|
|
271
|
+
};
|
|
272
|
+
Sha1.prototype.hex = function () {
|
|
273
|
+
this.finalize();
|
|
274
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;
|
|
275
|
+
return (HEX_CHARS[(h0 >> 28) & 0x0f] +
|
|
276
|
+
HEX_CHARS[(h0 >> 24) & 0x0f] +
|
|
277
|
+
HEX_CHARS[(h0 >> 20) & 0x0f] +
|
|
278
|
+
HEX_CHARS[(h0 >> 16) & 0x0f] +
|
|
279
|
+
HEX_CHARS[(h0 >> 12) & 0x0f] +
|
|
280
|
+
HEX_CHARS[(h0 >> 8) & 0x0f] +
|
|
281
|
+
HEX_CHARS[(h0 >> 4) & 0x0f] +
|
|
282
|
+
HEX_CHARS[h0 & 0x0f] +
|
|
283
|
+
HEX_CHARS[(h1 >> 28) & 0x0f] +
|
|
284
|
+
HEX_CHARS[(h1 >> 24) & 0x0f] +
|
|
285
|
+
HEX_CHARS[(h1 >> 20) & 0x0f] +
|
|
286
|
+
HEX_CHARS[(h1 >> 16) & 0x0f] +
|
|
287
|
+
HEX_CHARS[(h1 >> 12) & 0x0f] +
|
|
288
|
+
HEX_CHARS[(h1 >> 8) & 0x0f] +
|
|
289
|
+
HEX_CHARS[(h1 >> 4) & 0x0f] +
|
|
290
|
+
HEX_CHARS[h1 & 0x0f] +
|
|
291
|
+
HEX_CHARS[(h2 >> 28) & 0x0f] +
|
|
292
|
+
HEX_CHARS[(h2 >> 24) & 0x0f] +
|
|
293
|
+
HEX_CHARS[(h2 >> 20) & 0x0f] +
|
|
294
|
+
HEX_CHARS[(h2 >> 16) & 0x0f] +
|
|
295
|
+
HEX_CHARS[(h2 >> 12) & 0x0f] +
|
|
296
|
+
HEX_CHARS[(h2 >> 8) & 0x0f] +
|
|
297
|
+
HEX_CHARS[(h2 >> 4) & 0x0f] +
|
|
298
|
+
HEX_CHARS[h2 & 0x0f] +
|
|
299
|
+
HEX_CHARS[(h3 >> 28) & 0x0f] +
|
|
300
|
+
HEX_CHARS[(h3 >> 24) & 0x0f] +
|
|
301
|
+
HEX_CHARS[(h3 >> 20) & 0x0f] +
|
|
302
|
+
HEX_CHARS[(h3 >> 16) & 0x0f] +
|
|
303
|
+
HEX_CHARS[(h3 >> 12) & 0x0f] +
|
|
304
|
+
HEX_CHARS[(h3 >> 8) & 0x0f] +
|
|
305
|
+
HEX_CHARS[(h3 >> 4) & 0x0f] +
|
|
306
|
+
HEX_CHARS[h3 & 0x0f] +
|
|
307
|
+
HEX_CHARS[(h4 >> 28) & 0x0f] +
|
|
308
|
+
HEX_CHARS[(h4 >> 24) & 0x0f] +
|
|
309
|
+
HEX_CHARS[(h4 >> 20) & 0x0f] +
|
|
310
|
+
HEX_CHARS[(h4 >> 16) & 0x0f] +
|
|
311
|
+
HEX_CHARS[(h4 >> 12) & 0x0f] +
|
|
312
|
+
HEX_CHARS[(h4 >> 8) & 0x0f] +
|
|
313
|
+
HEX_CHARS[(h4 >> 4) & 0x0f] +
|
|
314
|
+
HEX_CHARS[h4 & 0x0f]);
|
|
315
|
+
};
|
|
316
|
+
Sha1.prototype.toString = Sha1.prototype.hex;
|
|
317
|
+
Sha1.prototype.digest = function () {
|
|
318
|
+
this.finalize();
|
|
319
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;
|
|
320
|
+
return [
|
|
321
|
+
(h0 >> 24) & 0xff,
|
|
322
|
+
(h0 >> 16) & 0xff,
|
|
323
|
+
(h0 >> 8) & 0xff,
|
|
324
|
+
h0 & 0xff,
|
|
325
|
+
(h1 >> 24) & 0xff,
|
|
326
|
+
(h1 >> 16) & 0xff,
|
|
327
|
+
(h1 >> 8) & 0xff,
|
|
328
|
+
h1 & 0xff,
|
|
329
|
+
(h2 >> 24) & 0xff,
|
|
330
|
+
(h2 >> 16) & 0xff,
|
|
331
|
+
(h2 >> 8) & 0xff,
|
|
332
|
+
h2 & 0xff,
|
|
333
|
+
(h3 >> 24) & 0xff,
|
|
334
|
+
(h3 >> 16) & 0xff,
|
|
335
|
+
(h3 >> 8) & 0xff,
|
|
336
|
+
h3 & 0xff,
|
|
337
|
+
(h4 >> 24) & 0xff,
|
|
338
|
+
(h4 >> 16) & 0xff,
|
|
339
|
+
(h4 >> 8) & 0xff,
|
|
340
|
+
h4 & 0xff,
|
|
341
|
+
];
|
|
342
|
+
};
|
|
343
|
+
Sha1.prototype.array = Sha1.prototype.digest;
|
|
344
|
+
Sha1.prototype.arrayBuffer = function () {
|
|
345
|
+
this.finalize();
|
|
346
|
+
var buffer = new ArrayBuffer(20);
|
|
347
|
+
var dataView = new DataView(buffer);
|
|
348
|
+
dataView.setUint32(0, this.h0);
|
|
349
|
+
dataView.setUint32(4, this.h1);
|
|
350
|
+
dataView.setUint32(8, this.h2);
|
|
351
|
+
dataView.setUint32(12, this.h3);
|
|
352
|
+
dataView.setUint32(16, this.h4);
|
|
353
|
+
return buffer;
|
|
354
|
+
};
|
|
355
|
+
const insecureHash = (message) => {
|
|
356
|
+
return new Sha1(true).update(message)["hex"]();
|
|
357
|
+
};
|
|
358
|
+
exports.insecureHash = insecureHash;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const insecureHash: (message: any) => any;
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Inlined to deal with portability issues with importing crypto module
|
|
3
|
+
/*
|
|
4
|
+
* [js-sha1]{@link https://github.com/emn178/js-sha1}
|
|
5
|
+
*
|
|
6
|
+
* @version 0.6.0
|
|
7
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
8
|
+
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
/*jslint bitwise: true */
|
|
12
|
+
"use strict";
|
|
13
|
+
var root = typeof window === "object" ? window : {};
|
|
14
|
+
var HEX_CHARS = "0123456789abcdef".split("");
|
|
15
|
+
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
16
|
+
var SHIFT = [24, 16, 8, 0];
|
|
17
|
+
var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
|
|
18
|
+
var blocks = [];
|
|
19
|
+
function Sha1(sharedMemory) {
|
|
20
|
+
if (sharedMemory) {
|
|
21
|
+
blocks[0] =
|
|
22
|
+
blocks[16] =
|
|
23
|
+
blocks[1] =
|
|
24
|
+
blocks[2] =
|
|
25
|
+
blocks[3] =
|
|
26
|
+
blocks[4] =
|
|
27
|
+
blocks[5] =
|
|
28
|
+
blocks[6] =
|
|
29
|
+
blocks[7] =
|
|
30
|
+
blocks[8] =
|
|
31
|
+
blocks[9] =
|
|
32
|
+
blocks[10] =
|
|
33
|
+
blocks[11] =
|
|
34
|
+
blocks[12] =
|
|
35
|
+
blocks[13] =
|
|
36
|
+
blocks[14] =
|
|
37
|
+
blocks[15] =
|
|
38
|
+
0;
|
|
39
|
+
this.blocks = blocks;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
43
|
+
}
|
|
44
|
+
this.h0 = 0x67452301;
|
|
45
|
+
this.h1 = 0xefcdab89;
|
|
46
|
+
this.h2 = 0x98badcfe;
|
|
47
|
+
this.h3 = 0x10325476;
|
|
48
|
+
this.h4 = 0xc3d2e1f0;
|
|
49
|
+
this.block = this.start = this.bytes = this.hBytes = 0;
|
|
50
|
+
this.finalized = this.hashed = false;
|
|
51
|
+
this.first = true;
|
|
52
|
+
}
|
|
53
|
+
Sha1.prototype.update = function (message) {
|
|
54
|
+
if (this.finalized) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
var notString = typeof message !== "string";
|
|
58
|
+
if (notString && message.constructor === root.ArrayBuffer) {
|
|
59
|
+
message = new Uint8Array(message);
|
|
60
|
+
}
|
|
61
|
+
var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
|
|
62
|
+
while (index < length) {
|
|
63
|
+
if (this.hashed) {
|
|
64
|
+
this.hashed = false;
|
|
65
|
+
blocks[0] = this.block;
|
|
66
|
+
blocks[16] =
|
|
67
|
+
blocks[1] =
|
|
68
|
+
blocks[2] =
|
|
69
|
+
blocks[3] =
|
|
70
|
+
blocks[4] =
|
|
71
|
+
blocks[5] =
|
|
72
|
+
blocks[6] =
|
|
73
|
+
blocks[7] =
|
|
74
|
+
blocks[8] =
|
|
75
|
+
blocks[9] =
|
|
76
|
+
blocks[10] =
|
|
77
|
+
blocks[11] =
|
|
78
|
+
blocks[12] =
|
|
79
|
+
blocks[13] =
|
|
80
|
+
blocks[14] =
|
|
81
|
+
blocks[15] =
|
|
82
|
+
0;
|
|
83
|
+
}
|
|
84
|
+
if (notString) {
|
|
85
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
86
|
+
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
91
|
+
code = message.charCodeAt(index);
|
|
92
|
+
if (code < 0x80) {
|
|
93
|
+
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
|
94
|
+
}
|
|
95
|
+
else if (code < 0x800) {
|
|
96
|
+
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
|
|
97
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
98
|
+
}
|
|
99
|
+
else if (code < 0xd800 || code >= 0xe000) {
|
|
100
|
+
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
|
|
101
|
+
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
102
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
code =
|
|
106
|
+
0x10000 +
|
|
107
|
+
(((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
|
108
|
+
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
|
|
109
|
+
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
|
|
110
|
+
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
111
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
this.lastByteIndex = i;
|
|
116
|
+
this.bytes += i - this.start;
|
|
117
|
+
if (i >= 64) {
|
|
118
|
+
this.block = blocks[16];
|
|
119
|
+
this.start = i - 64;
|
|
120
|
+
this.hash();
|
|
121
|
+
this.hashed = true;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.start = i;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (this.bytes > 4294967295) {
|
|
128
|
+
this.hBytes += (this.bytes / 4294967296) << 0;
|
|
129
|
+
this.bytes = this.bytes % 4294967296;
|
|
130
|
+
}
|
|
131
|
+
return this;
|
|
132
|
+
};
|
|
133
|
+
Sha1.prototype.finalize = function () {
|
|
134
|
+
if (this.finalized) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this.finalized = true;
|
|
138
|
+
var blocks = this.blocks, i = this.lastByteIndex;
|
|
139
|
+
blocks[16] = this.block;
|
|
140
|
+
blocks[i >> 2] |= EXTRA[i & 3];
|
|
141
|
+
this.block = blocks[16];
|
|
142
|
+
if (i >= 56) {
|
|
143
|
+
if (!this.hashed) {
|
|
144
|
+
this.hash();
|
|
145
|
+
}
|
|
146
|
+
blocks[0] = this.block;
|
|
147
|
+
blocks[16] =
|
|
148
|
+
blocks[1] =
|
|
149
|
+
blocks[2] =
|
|
150
|
+
blocks[3] =
|
|
151
|
+
blocks[4] =
|
|
152
|
+
blocks[5] =
|
|
153
|
+
blocks[6] =
|
|
154
|
+
blocks[7] =
|
|
155
|
+
blocks[8] =
|
|
156
|
+
blocks[9] =
|
|
157
|
+
blocks[10] =
|
|
158
|
+
blocks[11] =
|
|
159
|
+
blocks[12] =
|
|
160
|
+
blocks[13] =
|
|
161
|
+
blocks[14] =
|
|
162
|
+
blocks[15] =
|
|
163
|
+
0;
|
|
164
|
+
}
|
|
165
|
+
blocks[14] = (this.hBytes << 3) | (this.bytes >>> 29);
|
|
166
|
+
blocks[15] = this.bytes << 3;
|
|
167
|
+
this.hash();
|
|
168
|
+
};
|
|
169
|
+
Sha1.prototype.hash = function () {
|
|
170
|
+
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4;
|
|
171
|
+
var f, j, t, blocks = this.blocks;
|
|
172
|
+
for (j = 16; j < 80; ++j) {
|
|
173
|
+
t = blocks[j - 3] ^ blocks[j - 8] ^ blocks[j - 14] ^ blocks[j - 16];
|
|
174
|
+
blocks[j] = (t << 1) | (t >>> 31);
|
|
175
|
+
}
|
|
176
|
+
for (j = 0; j < 20; j += 5) {
|
|
177
|
+
f = (b & c) | (~b & d);
|
|
178
|
+
t = (a << 5) | (a >>> 27);
|
|
179
|
+
e = (t + f + e + 1518500249 + blocks[j]) << 0;
|
|
180
|
+
b = (b << 30) | (b >>> 2);
|
|
181
|
+
f = (a & b) | (~a & c);
|
|
182
|
+
t = (e << 5) | (e >>> 27);
|
|
183
|
+
d = (t + f + d + 1518500249 + blocks[j + 1]) << 0;
|
|
184
|
+
a = (a << 30) | (a >>> 2);
|
|
185
|
+
f = (e & a) | (~e & b);
|
|
186
|
+
t = (d << 5) | (d >>> 27);
|
|
187
|
+
c = (t + f + c + 1518500249 + blocks[j + 2]) << 0;
|
|
188
|
+
e = (e << 30) | (e >>> 2);
|
|
189
|
+
f = (d & e) | (~d & a);
|
|
190
|
+
t = (c << 5) | (c >>> 27);
|
|
191
|
+
b = (t + f + b + 1518500249 + blocks[j + 3]) << 0;
|
|
192
|
+
d = (d << 30) | (d >>> 2);
|
|
193
|
+
f = (c & d) | (~c & e);
|
|
194
|
+
t = (b << 5) | (b >>> 27);
|
|
195
|
+
a = (t + f + a + 1518500249 + blocks[j + 4]) << 0;
|
|
196
|
+
c = (c << 30) | (c >>> 2);
|
|
197
|
+
}
|
|
198
|
+
for (; j < 40; j += 5) {
|
|
199
|
+
f = b ^ c ^ d;
|
|
200
|
+
t = (a << 5) | (a >>> 27);
|
|
201
|
+
e = (t + f + e + 1859775393 + blocks[j]) << 0;
|
|
202
|
+
b = (b << 30) | (b >>> 2);
|
|
203
|
+
f = a ^ b ^ c;
|
|
204
|
+
t = (e << 5) | (e >>> 27);
|
|
205
|
+
d = (t + f + d + 1859775393 + blocks[j + 1]) << 0;
|
|
206
|
+
a = (a << 30) | (a >>> 2);
|
|
207
|
+
f = e ^ a ^ b;
|
|
208
|
+
t = (d << 5) | (d >>> 27);
|
|
209
|
+
c = (t + f + c + 1859775393 + blocks[j + 2]) << 0;
|
|
210
|
+
e = (e << 30) | (e >>> 2);
|
|
211
|
+
f = d ^ e ^ a;
|
|
212
|
+
t = (c << 5) | (c >>> 27);
|
|
213
|
+
b = (t + f + b + 1859775393 + blocks[j + 3]) << 0;
|
|
214
|
+
d = (d << 30) | (d >>> 2);
|
|
215
|
+
f = c ^ d ^ e;
|
|
216
|
+
t = (b << 5) | (b >>> 27);
|
|
217
|
+
a = (t + f + a + 1859775393 + blocks[j + 4]) << 0;
|
|
218
|
+
c = (c << 30) | (c >>> 2);
|
|
219
|
+
}
|
|
220
|
+
for (; j < 60; j += 5) {
|
|
221
|
+
f = (b & c) | (b & d) | (c & d);
|
|
222
|
+
t = (a << 5) | (a >>> 27);
|
|
223
|
+
e = (t + f + e - 1894007588 + blocks[j]) << 0;
|
|
224
|
+
b = (b << 30) | (b >>> 2);
|
|
225
|
+
f = (a & b) | (a & c) | (b & c);
|
|
226
|
+
t = (e << 5) | (e >>> 27);
|
|
227
|
+
d = (t + f + d - 1894007588 + blocks[j + 1]) << 0;
|
|
228
|
+
a = (a << 30) | (a >>> 2);
|
|
229
|
+
f = (e & a) | (e & b) | (a & b);
|
|
230
|
+
t = (d << 5) | (d >>> 27);
|
|
231
|
+
c = (t + f + c - 1894007588 + blocks[j + 2]) << 0;
|
|
232
|
+
e = (e << 30) | (e >>> 2);
|
|
233
|
+
f = (d & e) | (d & a) | (e & a);
|
|
234
|
+
t = (c << 5) | (c >>> 27);
|
|
235
|
+
b = (t + f + b - 1894007588 + blocks[j + 3]) << 0;
|
|
236
|
+
d = (d << 30) | (d >>> 2);
|
|
237
|
+
f = (c & d) | (c & e) | (d & e);
|
|
238
|
+
t = (b << 5) | (b >>> 27);
|
|
239
|
+
a = (t + f + a - 1894007588 + blocks[j + 4]) << 0;
|
|
240
|
+
c = (c << 30) | (c >>> 2);
|
|
241
|
+
}
|
|
242
|
+
for (; j < 80; j += 5) {
|
|
243
|
+
f = b ^ c ^ d;
|
|
244
|
+
t = (a << 5) | (a >>> 27);
|
|
245
|
+
e = (t + f + e - 899497514 + blocks[j]) << 0;
|
|
246
|
+
b = (b << 30) | (b >>> 2);
|
|
247
|
+
f = a ^ b ^ c;
|
|
248
|
+
t = (e << 5) | (e >>> 27);
|
|
249
|
+
d = (t + f + d - 899497514 + blocks[j + 1]) << 0;
|
|
250
|
+
a = (a << 30) | (a >>> 2);
|
|
251
|
+
f = e ^ a ^ b;
|
|
252
|
+
t = (d << 5) | (d >>> 27);
|
|
253
|
+
c = (t + f + c - 899497514 + blocks[j + 2]) << 0;
|
|
254
|
+
e = (e << 30) | (e >>> 2);
|
|
255
|
+
f = d ^ e ^ a;
|
|
256
|
+
t = (c << 5) | (c >>> 27);
|
|
257
|
+
b = (t + f + b - 899497514 + blocks[j + 3]) << 0;
|
|
258
|
+
d = (d << 30) | (d >>> 2);
|
|
259
|
+
f = c ^ d ^ e;
|
|
260
|
+
t = (b << 5) | (b >>> 27);
|
|
261
|
+
a = (t + f + a - 899497514 + blocks[j + 4]) << 0;
|
|
262
|
+
c = (c << 30) | (c >>> 2);
|
|
263
|
+
}
|
|
264
|
+
this.h0 = (this.h0 + a) << 0;
|
|
265
|
+
this.h1 = (this.h1 + b) << 0;
|
|
266
|
+
this.h2 = (this.h2 + c) << 0;
|
|
267
|
+
this.h3 = (this.h3 + d) << 0;
|
|
268
|
+
this.h4 = (this.h4 + e) << 0;
|
|
269
|
+
};
|
|
270
|
+
Sha1.prototype.hex = function () {
|
|
271
|
+
this.finalize();
|
|
272
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;
|
|
273
|
+
return (HEX_CHARS[(h0 >> 28) & 0x0f] +
|
|
274
|
+
HEX_CHARS[(h0 >> 24) & 0x0f] +
|
|
275
|
+
HEX_CHARS[(h0 >> 20) & 0x0f] +
|
|
276
|
+
HEX_CHARS[(h0 >> 16) & 0x0f] +
|
|
277
|
+
HEX_CHARS[(h0 >> 12) & 0x0f] +
|
|
278
|
+
HEX_CHARS[(h0 >> 8) & 0x0f] +
|
|
279
|
+
HEX_CHARS[(h0 >> 4) & 0x0f] +
|
|
280
|
+
HEX_CHARS[h0 & 0x0f] +
|
|
281
|
+
HEX_CHARS[(h1 >> 28) & 0x0f] +
|
|
282
|
+
HEX_CHARS[(h1 >> 24) & 0x0f] +
|
|
283
|
+
HEX_CHARS[(h1 >> 20) & 0x0f] +
|
|
284
|
+
HEX_CHARS[(h1 >> 16) & 0x0f] +
|
|
285
|
+
HEX_CHARS[(h1 >> 12) & 0x0f] +
|
|
286
|
+
HEX_CHARS[(h1 >> 8) & 0x0f] +
|
|
287
|
+
HEX_CHARS[(h1 >> 4) & 0x0f] +
|
|
288
|
+
HEX_CHARS[h1 & 0x0f] +
|
|
289
|
+
HEX_CHARS[(h2 >> 28) & 0x0f] +
|
|
290
|
+
HEX_CHARS[(h2 >> 24) & 0x0f] +
|
|
291
|
+
HEX_CHARS[(h2 >> 20) & 0x0f] +
|
|
292
|
+
HEX_CHARS[(h2 >> 16) & 0x0f] +
|
|
293
|
+
HEX_CHARS[(h2 >> 12) & 0x0f] +
|
|
294
|
+
HEX_CHARS[(h2 >> 8) & 0x0f] +
|
|
295
|
+
HEX_CHARS[(h2 >> 4) & 0x0f] +
|
|
296
|
+
HEX_CHARS[h2 & 0x0f] +
|
|
297
|
+
HEX_CHARS[(h3 >> 28) & 0x0f] +
|
|
298
|
+
HEX_CHARS[(h3 >> 24) & 0x0f] +
|
|
299
|
+
HEX_CHARS[(h3 >> 20) & 0x0f] +
|
|
300
|
+
HEX_CHARS[(h3 >> 16) & 0x0f] +
|
|
301
|
+
HEX_CHARS[(h3 >> 12) & 0x0f] +
|
|
302
|
+
HEX_CHARS[(h3 >> 8) & 0x0f] +
|
|
303
|
+
HEX_CHARS[(h3 >> 4) & 0x0f] +
|
|
304
|
+
HEX_CHARS[h3 & 0x0f] +
|
|
305
|
+
HEX_CHARS[(h4 >> 28) & 0x0f] +
|
|
306
|
+
HEX_CHARS[(h4 >> 24) & 0x0f] +
|
|
307
|
+
HEX_CHARS[(h4 >> 20) & 0x0f] +
|
|
308
|
+
HEX_CHARS[(h4 >> 16) & 0x0f] +
|
|
309
|
+
HEX_CHARS[(h4 >> 12) & 0x0f] +
|
|
310
|
+
HEX_CHARS[(h4 >> 8) & 0x0f] +
|
|
311
|
+
HEX_CHARS[(h4 >> 4) & 0x0f] +
|
|
312
|
+
HEX_CHARS[h4 & 0x0f]);
|
|
313
|
+
};
|
|
314
|
+
Sha1.prototype.toString = Sha1.prototype.hex;
|
|
315
|
+
Sha1.prototype.digest = function () {
|
|
316
|
+
this.finalize();
|
|
317
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;
|
|
318
|
+
return [
|
|
319
|
+
(h0 >> 24) & 0xff,
|
|
320
|
+
(h0 >> 16) & 0xff,
|
|
321
|
+
(h0 >> 8) & 0xff,
|
|
322
|
+
h0 & 0xff,
|
|
323
|
+
(h1 >> 24) & 0xff,
|
|
324
|
+
(h1 >> 16) & 0xff,
|
|
325
|
+
(h1 >> 8) & 0xff,
|
|
326
|
+
h1 & 0xff,
|
|
327
|
+
(h2 >> 24) & 0xff,
|
|
328
|
+
(h2 >> 16) & 0xff,
|
|
329
|
+
(h2 >> 8) & 0xff,
|
|
330
|
+
h2 & 0xff,
|
|
331
|
+
(h3 >> 24) & 0xff,
|
|
332
|
+
(h3 >> 16) & 0xff,
|
|
333
|
+
(h3 >> 8) & 0xff,
|
|
334
|
+
h3 & 0xff,
|
|
335
|
+
(h4 >> 24) & 0xff,
|
|
336
|
+
(h4 >> 16) & 0xff,
|
|
337
|
+
(h4 >> 8) & 0xff,
|
|
338
|
+
h4 & 0xff,
|
|
339
|
+
];
|
|
340
|
+
};
|
|
341
|
+
Sha1.prototype.array = Sha1.prototype.digest;
|
|
342
|
+
Sha1.prototype.arrayBuffer = function () {
|
|
343
|
+
this.finalize();
|
|
344
|
+
var buffer = new ArrayBuffer(20);
|
|
345
|
+
var dataView = new DataView(buffer);
|
|
346
|
+
dataView.setUint32(0, this.h0);
|
|
347
|
+
dataView.setUint32(4, this.h1);
|
|
348
|
+
dataView.setUint32(8, this.h2);
|
|
349
|
+
dataView.setUint32(12, this.h3);
|
|
350
|
+
dataView.setUint32(16, this.h4);
|
|
351
|
+
return buffer;
|
|
352
|
+
};
|
|
353
|
+
export const insecureHash = (message) => {
|
|
354
|
+
return new Sha1(true).update(message)["hex"]();
|
|
355
|
+
};
|
package/dist/util/stream.cjs
CHANGED
|
@@ -26,7 +26,10 @@ class IterableReadableStream extends ReadableStream {
|
|
|
26
26
|
const result = await this.reader.read();
|
|
27
27
|
if (result.done)
|
|
28
28
|
this.reader.releaseLock(); // release lock when stream becomes closed
|
|
29
|
-
return
|
|
29
|
+
return {
|
|
30
|
+
done: result.done,
|
|
31
|
+
value: result.value, // Cloudflare Workers typing fix
|
|
32
|
+
};
|
|
30
33
|
}
|
|
31
34
|
catch (e) {
|
|
32
35
|
this.reader.releaseLock(); // release lock when stream becomes errored
|
package/dist/util/stream.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare class IterableReadableStream<T> extends ReadableStream<T> {
|
|
2
2
|
reader: ReadableStreamDefaultReader<T>;
|
|
3
3
|
ensureReader(): void;
|
|
4
|
-
next(): Promise<
|
|
4
|
+
next(): Promise<{
|
|
5
|
+
done: boolean;
|
|
6
|
+
value: T;
|
|
7
|
+
}>;
|
|
5
8
|
return(): Promise<{
|
|
6
9
|
done: boolean;
|
|
7
10
|
value: T;
|
package/dist/util/stream.js
CHANGED
|
@@ -23,7 +23,10 @@ export class IterableReadableStream extends ReadableStream {
|
|
|
23
23
|
const result = await this.reader.read();
|
|
24
24
|
if (result.done)
|
|
25
25
|
this.reader.releaseLock(); // release lock when stream becomes closed
|
|
26
|
-
return
|
|
26
|
+
return {
|
|
27
|
+
done: result.done,
|
|
28
|
+
value: result.value, // Cloudflare Workers typing fix
|
|
29
|
+
};
|
|
27
30
|
}
|
|
28
31
|
catch (e) {
|
|
29
32
|
this.reader.releaseLock(); // release lock when stream becomes errored
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/embeddings/voyage.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/embeddings/voyage.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/embeddings/voyage.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.181",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -145,6 +145,9 @@
|
|
|
145
145
|
"embeddings/minimax.cjs",
|
|
146
146
|
"embeddings/minimax.js",
|
|
147
147
|
"embeddings/minimax.d.ts",
|
|
148
|
+
"embeddings/voyage.cjs",
|
|
149
|
+
"embeddings/voyage.js",
|
|
150
|
+
"embeddings/voyage.d.ts",
|
|
148
151
|
"embeddings/llama_cpp.cjs",
|
|
149
152
|
"embeddings/llama_cpp.js",
|
|
150
153
|
"embeddings/llama_cpp.d.ts",
|
|
@@ -865,7 +868,6 @@
|
|
|
865
868
|
"@types/jsdom": "^21.1.1",
|
|
866
869
|
"@types/lodash": "^4",
|
|
867
870
|
"@types/mozilla-readability": "^0.2.1",
|
|
868
|
-
"@types/object-hash": "^3.0.2",
|
|
869
871
|
"@types/pdf-parse": "^1.1.1",
|
|
870
872
|
"@types/pg": "^8",
|
|
871
873
|
"@types/pg-copy-streams": "^1.2.2",
|
|
@@ -1356,9 +1358,8 @@
|
|
|
1356
1358
|
"js-yaml": "^4.1.0",
|
|
1357
1359
|
"jsonpointer": "^5.0.1",
|
|
1358
1360
|
"langchainhub": "~0.0.6",
|
|
1359
|
-
"langsmith": "~0.0.
|
|
1361
|
+
"langsmith": "~0.0.48",
|
|
1360
1362
|
"ml-distance": "^4.0.0",
|
|
1361
|
-
"object-hash": "^3.0.0",
|
|
1362
1363
|
"openai": "~4.4.0",
|
|
1363
1364
|
"openapi-types": "^12.1.3",
|
|
1364
1365
|
"p-queue": "^6.6.2",
|
|
@@ -1611,6 +1612,11 @@
|
|
|
1611
1612
|
"import": "./embeddings/minimax.js",
|
|
1612
1613
|
"require": "./embeddings/minimax.cjs"
|
|
1613
1614
|
},
|
|
1615
|
+
"./embeddings/voyage": {
|
|
1616
|
+
"types": "./embeddings/voyage.d.ts",
|
|
1617
|
+
"import": "./embeddings/voyage.js",
|
|
1618
|
+
"require": "./embeddings/voyage.cjs"
|
|
1619
|
+
},
|
|
1614
1620
|
"./embeddings/llama_cpp": {
|
|
1615
1621
|
"types": "./embeddings/llama_cpp.d.ts",
|
|
1616
1622
|
"import": "./embeddings/llama_cpp.js",
|