@nocobase/plugin-ai 2.0.0-beta.6 → 2.0.0-beta.7
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/client/6a4c1ee12f864e38.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/collections/ai-employees.d.ts +1 -0
- package/dist/collections/ai-employees.js +4 -0
- package/dist/externalVersion.js +11 -11
- package/dist/locale/en-US.json +2 -0
- package/dist/locale/zh-CN.json +2 -0
- package/dist/node_modules/@langchain/anthropic/package.json +1 -1
- package/dist/node_modules/@langchain/core/package.json +1 -1
- package/dist/node_modules/@langchain/deepseek/package.json +1 -1
- package/dist/node_modules/@langchain/google-genai/LICENSE +6 -6
- package/dist/node_modules/@langchain/google-genai/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/node_modules/@langchain/google-genai/dist/chat_models.cjs +680 -842
- package/dist/node_modules/@langchain/google-genai/dist/chat_models.d.cts +581 -0
- package/dist/node_modules/@langchain/google-genai/dist/chat_models.d.ts +196 -157
- package/dist/node_modules/@langchain/google-genai/dist/chat_models.js +678 -837
- package/dist/node_modules/@langchain/google-genai/dist/embeddings.cjs +97 -151
- package/dist/node_modules/@langchain/google-genai/dist/embeddings.d.cts +104 -0
- package/dist/node_modules/@langchain/google-genai/dist/embeddings.d.ts +76 -70
- package/dist/node_modules/@langchain/google-genai/dist/embeddings.js +93 -144
- package/dist/node_modules/@langchain/google-genai/dist/index.cjs +252 -18
- package/dist/node_modules/@langchain/google-genai/dist/index.d.cts +3 -0
- package/dist/node_modules/@langchain/google-genai/dist/index.d.ts +3 -2
- package/dist/node_modules/@langchain/google-genai/dist/index.js +4 -2
- package/dist/node_modules/@langchain/google-genai/dist/output_parsers.cjs +47 -75
- package/dist/node_modules/@langchain/google-genai/dist/output_parsers.js +47 -72
- package/dist/node_modules/@langchain/google-genai/dist/profiles.cjs +345 -0
- package/dist/node_modules/@langchain/google-genai/dist/profiles.js +344 -0
- package/dist/node_modules/@langchain/google-genai/dist/types.d.cts +17 -0
- package/dist/node_modules/@langchain/google-genai/dist/types.d.ts +16 -2
- package/dist/node_modules/@langchain/google-genai/dist/utils/common.cjs +419 -551
- package/dist/node_modules/@langchain/google-genai/dist/utils/common.js +417 -545
- package/dist/node_modules/@langchain/google-genai/dist/utils/tools.cjs +65 -102
- package/dist/node_modules/@langchain/google-genai/dist/utils/tools.js +64 -99
- package/dist/node_modules/@langchain/google-genai/dist/utils/zod_to_genai_parameters.cjs +31 -49
- package/dist/node_modules/@langchain/google-genai/dist/utils/zod_to_genai_parameters.js +29 -45
- package/dist/node_modules/@langchain/google-genai/package.json +1 -1
- package/dist/node_modules/@langchain/ollama/package.json +1 -1
- package/dist/node_modules/@langchain/openai/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/node_modules/zod-to-json-schema/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.js +5 -2
- package/dist/server/llm-providers/anthropic.js +4 -5
- package/dist/server/llm-providers/provider.js +5 -1
- package/dist/server/manager/ai-chat-conversation.js +3 -2
- package/dist/server/manager/built-in-manager.js +3 -3
- package/dist/server/migrations/20260107000000-reset-builtin-about.d.ts +14 -0
- package/dist/server/migrations/20260107000000-reset-builtin-about.js +48 -0
- package/dist/server/resource/ai.js +8 -2
- package/dist/server/resource/aiEmployees.d.ts +0 -1
- package/dist/server/resource/aiEmployees.js +0 -15
- package/dist/server/types/ai-message.type.d.ts +2 -0
- package/package.json +3 -3
- package/dist/client/a7f0550514128d80.js +0 -10
- package/dist/node_modules/@langchain/google-genai/dist/output_parsers.d.ts +0 -20
- package/dist/node_modules/@langchain/google-genai/dist/types.cjs +0 -2
- package/dist/node_modules/@langchain/google-genai/dist/types.js +0 -1
- package/dist/node_modules/@langchain/google-genai/dist/utils/common.d.ts +0 -22
- package/dist/node_modules/@langchain/google-genai/dist/utils/tools.d.ts +0 -10
- package/dist/node_modules/@langchain/google-genai/dist/utils/zod_to_genai_parameters.d.ts +0 -14
- package/dist/node_modules/@langchain/google-genai/index.cjs +0 -252
- package/dist/node_modules/@langchain/google-genai/index.d.cts +0 -1
- package/dist/node_modules/@langchain/google-genai/index.d.ts +0 -1
- package/dist/node_modules/@langchain/google-genai/index.js +0 -1
|
@@ -1,153 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __google_generative_ai = require_rolldown_runtime.__toESM(require("@google/generative-ai"));
|
|
3
|
+
const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env"));
|
|
4
|
+
const __langchain_core_embeddings = require_rolldown_runtime.__toESM(require("@langchain/core/embeddings"));
|
|
5
|
+
const __langchain_core_utils_chunk_array = require_rolldown_runtime.__toESM(require("@langchain/core/utils/chunk_array"));
|
|
6
|
+
|
|
7
|
+
//#region src/embeddings.ts
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
model: this.model,
|
|
99
|
-
}, {
|
|
100
|
-
baseUrl: fields?.baseUrl,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
_convertToContent(text) {
|
|
104
|
-
const cleanedText = this.stripNewLines ? text.replace(/\n/g, " ") : text;
|
|
105
|
-
return {
|
|
106
|
-
content: { role: "user", parts: [{ text: cleanedText }] },
|
|
107
|
-
taskType: this.taskType,
|
|
108
|
-
title: this.title,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
async _embedQueryContent(text) {
|
|
112
|
-
const req = this._convertToContent(text);
|
|
113
|
-
const res = await this.client.embedContent(req);
|
|
114
|
-
return res.embedding.values ?? [];
|
|
115
|
-
}
|
|
116
|
-
async _embedDocumentsContent(documents) {
|
|
117
|
-
const batchEmbedChunks = (0, chunk_array_1.chunkArray)(documents, this.maxBatchSize);
|
|
118
|
-
const batchEmbedRequests = batchEmbedChunks.map((chunk) => ({
|
|
119
|
-
requests: chunk.map((doc) => this._convertToContent(doc)),
|
|
120
|
-
}));
|
|
121
|
-
const responses = await Promise.allSettled(batchEmbedRequests.map((req) => this.client.batchEmbedContents(req)));
|
|
122
|
-
const embeddings = responses.flatMap((res, idx) => {
|
|
123
|
-
if (res.status === "fulfilled") {
|
|
124
|
-
return res.value.embeddings.map((e) => e.values || []);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
return Array(batchEmbedChunks[idx].length).fill([]);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
return embeddings;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Method that takes a document as input and returns a promise that
|
|
134
|
-
* resolves to an embedding for the document. It calls the _embedText
|
|
135
|
-
* method with the document as the input.
|
|
136
|
-
* @param document Document for which to generate an embedding.
|
|
137
|
-
* @returns Promise that resolves to an embedding for the input document.
|
|
138
|
-
*/
|
|
139
|
-
embedQuery(document) {
|
|
140
|
-
return this.caller.call(this._embedQueryContent.bind(this), document);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Method that takes an array of documents as input and returns a promise
|
|
144
|
-
* that resolves to a 2D array of embeddings for each document. It calls
|
|
145
|
-
* the _embedText method for each document in the array.
|
|
146
|
-
* @param documents Array of documents for which to generate embeddings.
|
|
147
|
-
* @returns Promise that resolves to a 2D array of embeddings for each input document.
|
|
148
|
-
*/
|
|
149
|
-
embedDocuments(documents) {
|
|
150
|
-
return this.caller.call(this._embedDocumentsContent.bind(this), documents);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
9
|
+
* Class that extends the Embeddings class and provides methods for
|
|
10
|
+
* generating embeddings using the Google Palm API.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const model = new GoogleGenerativeAIEmbeddings({
|
|
14
|
+
* apiKey: "<YOUR API KEY>",
|
|
15
|
+
* modelName: "embedding-001",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Embed a single query
|
|
19
|
+
* const res = await model.embedQuery(
|
|
20
|
+
* "What would be a good company name for a company that makes colorful socks?"
|
|
21
|
+
* );
|
|
22
|
+
* console.log({ res });
|
|
23
|
+
*
|
|
24
|
+
* // Embed multiple documents
|
|
25
|
+
* const documentRes = await model.embedDocuments(["Hello world", "Bye bye"]);
|
|
26
|
+
* console.log({ documentRes });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
var GoogleGenerativeAIEmbeddings = class extends __langchain_core_embeddings.Embeddings {
|
|
30
|
+
apiKey;
|
|
31
|
+
modelName = "embedding-001";
|
|
32
|
+
model = "embedding-001";
|
|
33
|
+
taskType;
|
|
34
|
+
title;
|
|
35
|
+
stripNewLines = true;
|
|
36
|
+
maxBatchSize = 100;
|
|
37
|
+
client;
|
|
38
|
+
constructor(fields) {
|
|
39
|
+
super(fields ?? {});
|
|
40
|
+
this.modelName = fields?.model?.replace(/^models\//, "") ?? fields?.modelName?.replace(/^models\//, "") ?? this.modelName;
|
|
41
|
+
this.model = this.modelName;
|
|
42
|
+
this.taskType = fields?.taskType ?? this.taskType;
|
|
43
|
+
this.title = fields?.title ?? this.title;
|
|
44
|
+
if (this.title && this.taskType !== "RETRIEVAL_DOCUMENT") throw new Error("title can only be sepcified with TaskType.RETRIEVAL_DOCUMENT");
|
|
45
|
+
this.apiKey = fields?.apiKey ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("GOOGLE_API_KEY");
|
|
46
|
+
if (!this.apiKey) throw new Error("Please set an API key for Google GenerativeAI in the environmentb variable GOOGLE_API_KEY or in the `apiKey` field of the GoogleGenerativeAIEmbeddings constructor");
|
|
47
|
+
this.client = new __google_generative_ai.GoogleGenerativeAI(this.apiKey).getGenerativeModel({ model: this.model }, { baseUrl: fields?.baseUrl });
|
|
48
|
+
}
|
|
49
|
+
_convertToContent(text) {
|
|
50
|
+
const cleanedText = this.stripNewLines ? text.replace(/\n/g, " ") : text;
|
|
51
|
+
return {
|
|
52
|
+
content: {
|
|
53
|
+
role: "user",
|
|
54
|
+
parts: [{ text: cleanedText }]
|
|
55
|
+
},
|
|
56
|
+
taskType: this.taskType,
|
|
57
|
+
title: this.title
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async _embedQueryContent(text) {
|
|
61
|
+
const req = this._convertToContent(text);
|
|
62
|
+
const res = await this.client.embedContent(req);
|
|
63
|
+
return res.embedding.values ?? [];
|
|
64
|
+
}
|
|
65
|
+
async _embedDocumentsContent(documents) {
|
|
66
|
+
const batchEmbedChunks = (0, __langchain_core_utils_chunk_array.chunkArray)(documents, this.maxBatchSize);
|
|
67
|
+
const batchEmbedRequests = batchEmbedChunks.map((chunk) => ({ requests: chunk.map((doc) => this._convertToContent(doc)) }));
|
|
68
|
+
const responses = await Promise.allSettled(batchEmbedRequests.map((req) => this.client.batchEmbedContents(req)));
|
|
69
|
+
const embeddings = responses.flatMap((res, idx) => {
|
|
70
|
+
if (res.status === "fulfilled") return res.value.embeddings.map((e) => e.values || []);
|
|
71
|
+
else return Array(batchEmbedChunks[idx].length).fill([]);
|
|
72
|
+
});
|
|
73
|
+
return embeddings;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Method that takes a document as input and returns a promise that
|
|
77
|
+
* resolves to an embedding for the document. It calls the _embedText
|
|
78
|
+
* method with the document as the input.
|
|
79
|
+
* @param document Document for which to generate an embedding.
|
|
80
|
+
* @returns Promise that resolves to an embedding for the input document.
|
|
81
|
+
*/
|
|
82
|
+
embedQuery(document) {
|
|
83
|
+
return this.caller.call(this._embedQueryContent.bind(this), document);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Method that takes an array of documents as input and returns a promise
|
|
87
|
+
* that resolves to a 2D array of embeddings for each document. It calls
|
|
88
|
+
* the _embedText method for each document in the array.
|
|
89
|
+
* @param documents Array of documents for which to generate embeddings.
|
|
90
|
+
* @returns Promise that resolves to a 2D array of embeddings for each input document.
|
|
91
|
+
*/
|
|
92
|
+
embedDocuments(documents) {
|
|
93
|
+
return this.caller.call(this._embedDocumentsContent.bind(this), documents);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
153
98
|
exports.GoogleGenerativeAIEmbeddings = GoogleGenerativeAIEmbeddings;
|
|
99
|
+
//# sourceMappingURL=embeddings.cjs.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { TaskType } from "@google/generative-ai";
|
|
2
|
+
import { Embeddings, EmbeddingsParams } from "@langchain/core/embeddings";
|
|
3
|
+
|
|
4
|
+
//#region src/embeddings.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Interface that extends EmbeddingsParams and defines additional
|
|
8
|
+
* parameters specific to the GoogleGenerativeAIEmbeddings class.
|
|
9
|
+
*/
|
|
10
|
+
interface GoogleGenerativeAIEmbeddingsParams extends EmbeddingsParams {
|
|
11
|
+
/**
|
|
12
|
+
* Model Name to use
|
|
13
|
+
*
|
|
14
|
+
* Alias for `model`
|
|
15
|
+
*
|
|
16
|
+
* Note: The format must follow the pattern - `{model}`
|
|
17
|
+
*/
|
|
18
|
+
modelName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Model Name to use
|
|
21
|
+
*
|
|
22
|
+
* Note: The format must follow the pattern - `{model}`
|
|
23
|
+
*/
|
|
24
|
+
model?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Type of task for which the embedding will be used
|
|
27
|
+
*
|
|
28
|
+
* Note: currently only supported by `embedding-001` model
|
|
29
|
+
*/
|
|
30
|
+
taskType?: TaskType;
|
|
31
|
+
/**
|
|
32
|
+
* An optional title for the text. Only applicable when TaskType is
|
|
33
|
+
* `RETRIEVAL_DOCUMENT`
|
|
34
|
+
*
|
|
35
|
+
* Note: currently only supported by `embedding-001` model
|
|
36
|
+
*/
|
|
37
|
+
title?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to strip new lines from the input text. Default to true
|
|
40
|
+
*/
|
|
41
|
+
stripNewLines?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Google API key to use
|
|
44
|
+
*/
|
|
45
|
+
apiKey?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Google API base URL to use
|
|
48
|
+
*/
|
|
49
|
+
baseUrl?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Class that extends the Embeddings class and provides methods for
|
|
53
|
+
* generating embeddings using the Google Palm API.
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const model = new GoogleGenerativeAIEmbeddings({
|
|
57
|
+
* apiKey: "<YOUR API KEY>",
|
|
58
|
+
* modelName: "embedding-001",
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // Embed a single query
|
|
62
|
+
* const res = await model.embedQuery(
|
|
63
|
+
* "What would be a good company name for a company that makes colorful socks?"
|
|
64
|
+
* );
|
|
65
|
+
* console.log({ res });
|
|
66
|
+
*
|
|
67
|
+
* // Embed multiple documents
|
|
68
|
+
* const documentRes = await model.embedDocuments(["Hello world", "Bye bye"]);
|
|
69
|
+
* console.log({ documentRes });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare class GoogleGenerativeAIEmbeddings extends Embeddings implements GoogleGenerativeAIEmbeddingsParams {
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
modelName: string;
|
|
75
|
+
model: string;
|
|
76
|
+
taskType?: TaskType;
|
|
77
|
+
title?: string;
|
|
78
|
+
stripNewLines: boolean;
|
|
79
|
+
maxBatchSize: number; // Max batch size for embedDocuments set by GenerativeModel client's batchEmbedContents call
|
|
80
|
+
private client;
|
|
81
|
+
constructor(fields?: GoogleGenerativeAIEmbeddingsParams);
|
|
82
|
+
private _convertToContent;
|
|
83
|
+
protected _embedQueryContent(text: string): Promise<number[]>;
|
|
84
|
+
protected _embedDocumentsContent(documents: string[]): Promise<number[][]>;
|
|
85
|
+
/**
|
|
86
|
+
* Method that takes a document as input and returns a promise that
|
|
87
|
+
* resolves to an embedding for the document. It calls the _embedText
|
|
88
|
+
* method with the document as the input.
|
|
89
|
+
* @param document Document for which to generate an embedding.
|
|
90
|
+
* @returns Promise that resolves to an embedding for the input document.
|
|
91
|
+
*/
|
|
92
|
+
embedQuery(document: string): Promise<number[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Method that takes an array of documents as input and returns a promise
|
|
95
|
+
* that resolves to a 2D array of embeddings for each document. It calls
|
|
96
|
+
* the _embedText method for each document in the array.
|
|
97
|
+
* @param documents Array of documents for which to generate embeddings.
|
|
98
|
+
* @returns Promise that resolves to a 2D array of embeddings for each input document.
|
|
99
|
+
*/
|
|
100
|
+
embedDocuments(documents: string[]): Promise<number[][]>;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { GoogleGenerativeAIEmbeddings, GoogleGenerativeAIEmbeddingsParams };
|
|
104
|
+
//# sourceMappingURL=embeddings.d.cts.map
|
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TaskType } from "@google/generative-ai";
|
|
2
2
|
import { Embeddings, EmbeddingsParams } from "@langchain/core/embeddings";
|
|
3
|
+
|
|
4
|
+
//#region src/embeddings.d.ts
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Interface that extends EmbeddingsParams and defines additional
|
|
5
8
|
* parameters specific to the GoogleGenerativeAIEmbeddings class.
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
10
|
+
interface GoogleGenerativeAIEmbeddingsParams extends EmbeddingsParams {
|
|
11
|
+
/**
|
|
12
|
+
* Model Name to use
|
|
13
|
+
*
|
|
14
|
+
* Alias for `model`
|
|
15
|
+
*
|
|
16
|
+
* Note: The format must follow the pattern - `{model}`
|
|
17
|
+
*/
|
|
18
|
+
modelName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Model Name to use
|
|
21
|
+
*
|
|
22
|
+
* Note: The format must follow the pattern - `{model}`
|
|
23
|
+
*/
|
|
24
|
+
model?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Type of task for which the embedding will be used
|
|
27
|
+
*
|
|
28
|
+
* Note: currently only supported by `embedding-001` model
|
|
29
|
+
*/
|
|
30
|
+
taskType?: TaskType;
|
|
31
|
+
/**
|
|
32
|
+
* An optional title for the text. Only applicable when TaskType is
|
|
33
|
+
* `RETRIEVAL_DOCUMENT`
|
|
34
|
+
*
|
|
35
|
+
* Note: currently only supported by `embedding-001` model
|
|
36
|
+
*/
|
|
37
|
+
title?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to strip new lines from the input text. Default to true
|
|
40
|
+
*/
|
|
41
|
+
stripNewLines?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Google API key to use
|
|
44
|
+
*/
|
|
45
|
+
apiKey?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Google API base URL to use
|
|
48
|
+
*/
|
|
49
|
+
baseUrl?: string;
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* Class that extends the Embeddings class and provides methods for
|
|
@@ -66,33 +69,36 @@ export interface GoogleGenerativeAIEmbeddingsParams extends EmbeddingsParams {
|
|
|
66
69
|
* console.log({ documentRes });
|
|
67
70
|
* ```
|
|
68
71
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
72
|
+
declare class GoogleGenerativeAIEmbeddings extends Embeddings implements GoogleGenerativeAIEmbeddingsParams {
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
modelName: string;
|
|
75
|
+
model: string;
|
|
76
|
+
taskType?: TaskType;
|
|
77
|
+
title?: string;
|
|
78
|
+
stripNewLines: boolean;
|
|
79
|
+
maxBatchSize: number; // Max batch size for embedDocuments set by GenerativeModel client's batchEmbedContents call
|
|
80
|
+
private client;
|
|
81
|
+
constructor(fields?: GoogleGenerativeAIEmbeddingsParams);
|
|
82
|
+
private _convertToContent;
|
|
83
|
+
protected _embedQueryContent(text: string): Promise<number[]>;
|
|
84
|
+
protected _embedDocumentsContent(documents: string[]): Promise<number[][]>;
|
|
85
|
+
/**
|
|
86
|
+
* Method that takes a document as input and returns a promise that
|
|
87
|
+
* resolves to an embedding for the document. It calls the _embedText
|
|
88
|
+
* method with the document as the input.
|
|
89
|
+
* @param document Document for which to generate an embedding.
|
|
90
|
+
* @returns Promise that resolves to an embedding for the input document.
|
|
91
|
+
*/
|
|
92
|
+
embedQuery(document: string): Promise<number[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Method that takes an array of documents as input and returns a promise
|
|
95
|
+
* that resolves to a 2D array of embeddings for each document. It calls
|
|
96
|
+
* the _embedText method for each document in the array.
|
|
97
|
+
* @param documents Array of documents for which to generate embeddings.
|
|
98
|
+
* @returns Promise that resolves to a 2D array of embeddings for each input document.
|
|
99
|
+
*/
|
|
100
|
+
embedDocuments(documents: string[]): Promise<number[][]>;
|
|
98
101
|
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { GoogleGenerativeAIEmbeddings, GoogleGenerativeAIEmbeddingsParams };
|
|
104
|
+
//# sourceMappingURL=embeddings.d.ts.map
|