@nocobase/plugin-ai 2.2.0-beta.8 → 2.2.0-beta.9
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/ai/docs/nocobase/api/app/env.md +28 -1
- package/dist/ai/docs/nocobase/api/cli/config/delete.md +8 -6
- package/dist/ai/docs/nocobase/api/cli/config/get.md +8 -6
- package/dist/ai/docs/nocobase/api/cli/config/index.md +37 -26
- package/dist/ai/docs/nocobase/api/cli/config/set.md +14 -8
- package/dist/ai/docs/nocobase/file-manager/field-attachment.md +6 -0
- package/dist/ai/docs/nocobase/file-manager/file-preview/index.md +3 -12
- package/dist/ai/docs/nocobase/file-manager/storage/aliyun-oss.md +9 -0
- package/dist/ai/docs/nocobase/file-manager/storage/amazon-s3.md +9 -0
- package/dist/ai/docs/nocobase/file-manager/storage/index.md +23 -0
- package/dist/ai/docs/nocobase/file-manager/storage/local.md +9 -0
- package/dist/ai/docs/nocobase/file-manager/storage/migrate-to-s3-pro.md +269 -0
- package/dist/ai/docs/nocobase/file-manager/storage/tencent-cos.md +9 -0
- package/dist/ai/docs/nocobase/get-started/installation/docker-caddy.mdx +175 -0
- package/dist/ai/docs/nocobase/get-started/installation/docker-nginx.mdx +176 -0
- package/dist/ai/docs/nocobase/get-started/installation/docker.mdx +94 -1
- package/dist/ai/docs/nocobase/get-started/installation/env.md +14 -4
- package/dist/ai/docs/nocobase/ops-management/version-control/index.md +1 -0
- package/dist/client/{428.e9f38da3b0d8b498.js → 428.5eb4f53ddbb6a3b8.js} +1 -1
- package/dist/client/559.9f97ebcdb0bd6231.js +10 -0
- package/dist/client/index.js +3 -3
- package/dist/client/llm-providers/mistral/ModelSettings.d.ts +10 -0
- package/dist/client/llm-providers/mistral/index.d.ts +10 -0
- package/dist/client/llm-services/utils.d.ts +5 -0
- package/dist/client-v2/index.d.ts +0 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +16 -16
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/@langchain/mistralai/LICENSE +21 -0
- package/dist/node_modules/@langchain/mistralai/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/node_modules/@langchain/mistralai/dist/chat_models.cjs +859 -0
- package/dist/node_modules/@langchain/mistralai/dist/chat_models.d.cts +541 -0
- package/dist/node_modules/@langchain/mistralai/dist/chat_models.d.ts +541 -0
- package/dist/node_modules/@langchain/mistralai/dist/chat_models.js +857 -0
- package/dist/node_modules/@langchain/mistralai/dist/embeddings.cjs +140 -0
- package/dist/node_modules/@langchain/mistralai/dist/embeddings.d.cts +116 -0
- package/dist/node_modules/@langchain/mistralai/dist/embeddings.d.ts +116 -0
- package/dist/node_modules/@langchain/mistralai/dist/embeddings.js +139 -0
- package/dist/node_modules/@langchain/mistralai/dist/index.cjs +21 -0
- package/dist/node_modules/@langchain/mistralai/dist/index.d.cts +4 -0
- package/dist/node_modules/@langchain/mistralai/dist/index.d.ts +4 -0
- package/dist/node_modules/@langchain/mistralai/dist/index.js +5 -0
- package/dist/node_modules/@langchain/mistralai/dist/llms.cjs +275 -0
- package/dist/node_modules/@langchain/mistralai/dist/llms.d.cts +147 -0
- package/dist/node_modules/@langchain/mistralai/dist/llms.d.ts +147 -0
- package/dist/node_modules/@langchain/mistralai/dist/llms.js +274 -0
- package/dist/node_modules/@langchain/mistralai/dist/utils.cjs +61 -0
- package/dist/node_modules/@langchain/mistralai/dist/utils.js +59 -0
- package/dist/node_modules/@langchain/mistralai/package.json +1 -0
- package/dist/node_modules/@langchain/xai/dist/index.cjs +2 -2
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.js +7 -5
- package/dist/server/ai-employees/checkpoints/cleaner.d.ts +2 -0
- package/dist/server/ai-employees/checkpoints/cleaner.js +11 -1
- package/dist/server/ai-employees/middleware/conversation.d.ts +2 -0
- package/dist/server/ai-employees/middleware/conversation.js +2 -1
- package/dist/server/ai-employees/utils.d.ts +3 -1
- package/dist/server/ai-employees/utils.js +2 -0
- package/dist/server/llm-providers/mistral.d.ts +62 -0
- package/dist/server/llm-providers/mistral.js +265 -0
- package/dist/server/llm-providers/provider.d.ts +6 -2
- package/dist/server/llm-providers/provider.js +27 -14
- package/dist/server/plugin.js +2 -0
- package/dist/server/workflow/nodes/employee/index.js +92 -46
- package/dist/server/workflow/nodes/employee/tools.js +8 -1
- package/package.json +3 -2
- package/dist/client/559.a0f2f1cc2be3c039.js +0 -10
- package/dist/client-v2/ai-employees/flow/models/AIEmployeeButtonModel.d.ts +0 -32
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChatMistralAI, ChatMistralAICallOptions, ChatMistralAIInput, convertMessagesToMistralMessages } from "./chat_models.cjs";
|
|
2
|
+
import { MistralAIEmbeddings, MistralAIEmbeddingsParams } from "./embeddings.cjs";
|
|
3
|
+
import { MistralAI, MistralAICallOptions, MistralAIInput } from "./llms.cjs";
|
|
4
|
+
export { ChatMistralAI, ChatMistralAICallOptions, ChatMistralAIInput, MistralAI, MistralAICallOptions, MistralAIEmbeddings, MistralAIEmbeddingsParams, MistralAIInput, convertMessagesToMistralMessages };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChatMistralAI, ChatMistralAICallOptions, ChatMistralAIInput, convertMessagesToMistralMessages } from "./chat_models.js";
|
|
2
|
+
import { MistralAIEmbeddings, MistralAIEmbeddingsParams } from "./embeddings.js";
|
|
3
|
+
import { MistralAI, MistralAICallOptions, MistralAIInput } from "./llms.js";
|
|
4
|
+
export { ChatMistralAI, ChatMistralAICallOptions, ChatMistralAIInput, MistralAI, MistralAICallOptions, MistralAIEmbeddings, MistralAIEmbeddingsParams, MistralAIInput, convertMessagesToMistralMessages };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ChatMistralAI, convertMessagesToMistralMessages } from "./chat_models.js";
|
|
2
|
+
import { MistralAIEmbeddings } from "./embeddings.js";
|
|
3
|
+
import { MistralAI } from "./llms.js";
|
|
4
|
+
|
|
5
|
+
export { ChatMistralAI, MistralAI, MistralAIEmbeddings, convertMessagesToMistralMessages };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __mistralai_mistralai_lib_http_js = require_rolldown_runtime.__toESM(require("@mistralai/mistralai/lib/http.js"));
|
|
3
|
+
const __langchain_core_outputs = require_rolldown_runtime.__toESM(require("@langchain/core/outputs"));
|
|
4
|
+
const __langchain_core_utils_async_caller = require_rolldown_runtime.__toESM(require("@langchain/core/utils/async_caller"));
|
|
5
|
+
const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env"));
|
|
6
|
+
const __langchain_core_utils_chunk_array = require_rolldown_runtime.__toESM(require("@langchain/core/utils/chunk_array"));
|
|
7
|
+
const __langchain_core_language_models_llms = require_rolldown_runtime.__toESM(require("@langchain/core/language_models/llms"));
|
|
8
|
+
|
|
9
|
+
//#region src/llms.ts
|
|
10
|
+
/**
|
|
11
|
+
* MistralAI completions LLM.
|
|
12
|
+
*/
|
|
13
|
+
var MistralAI = class extends __langchain_core_language_models_llms.LLM {
|
|
14
|
+
static lc_name() {
|
|
15
|
+
return "MistralAI";
|
|
16
|
+
}
|
|
17
|
+
lc_namespace = [
|
|
18
|
+
"langchain",
|
|
19
|
+
"llms",
|
|
20
|
+
"mistralai"
|
|
21
|
+
];
|
|
22
|
+
lc_serializable = true;
|
|
23
|
+
model = "codestral-latest";
|
|
24
|
+
temperature = 0;
|
|
25
|
+
topP;
|
|
26
|
+
maxTokens;
|
|
27
|
+
randomSeed;
|
|
28
|
+
streaming = false;
|
|
29
|
+
batchSize = 20;
|
|
30
|
+
apiKey;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated use serverURL instead
|
|
33
|
+
*/
|
|
34
|
+
endpoint;
|
|
35
|
+
serverURL;
|
|
36
|
+
maxRetries;
|
|
37
|
+
maxConcurrency;
|
|
38
|
+
beforeRequestHooks;
|
|
39
|
+
requestErrorHooks;
|
|
40
|
+
responseHooks;
|
|
41
|
+
httpClient;
|
|
42
|
+
constructor(fields) {
|
|
43
|
+
super(fields ?? {});
|
|
44
|
+
this.model = fields?.model ?? this.model;
|
|
45
|
+
this.temperature = fields?.temperature ?? this.temperature;
|
|
46
|
+
this.topP = fields?.topP ?? this.topP;
|
|
47
|
+
this.maxTokens = fields?.maxTokens ?? this.maxTokens;
|
|
48
|
+
this.randomSeed = fields?.randomSeed ?? this.randomSeed;
|
|
49
|
+
this.batchSize = fields?.batchSize ?? this.batchSize;
|
|
50
|
+
this.streaming = fields?.streaming ?? this.streaming;
|
|
51
|
+
this.serverURL = fields?.serverURL ?? this.serverURL;
|
|
52
|
+
this.maxRetries = fields?.maxRetries;
|
|
53
|
+
this.maxConcurrency = fields?.maxConcurrency;
|
|
54
|
+
this.beforeRequestHooks = fields?.beforeRequestHooks ?? this.beforeRequestHooks;
|
|
55
|
+
this.requestErrorHooks = fields?.requestErrorHooks ?? this.requestErrorHooks;
|
|
56
|
+
this.responseHooks = fields?.responseHooks ?? this.responseHooks;
|
|
57
|
+
this.httpClient = fields?.httpClient ?? this.httpClient;
|
|
58
|
+
const apiKey = fields?.apiKey ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("MISTRAL_API_KEY");
|
|
59
|
+
if (!apiKey) throw new Error(`MistralAI requires an API key to be set.
|
|
60
|
+
Either provide one via the "apiKey" field in the constructor, or set the "MISTRAL_API_KEY" environment variable.`);
|
|
61
|
+
this.apiKey = apiKey;
|
|
62
|
+
this.addAllHooksToHttpClient();
|
|
63
|
+
}
|
|
64
|
+
get lc_secrets() {
|
|
65
|
+
return { apiKey: "MISTRAL_API_KEY" };
|
|
66
|
+
}
|
|
67
|
+
get lc_aliases() {
|
|
68
|
+
return { apiKey: "mistral_api_key" };
|
|
69
|
+
}
|
|
70
|
+
_llmType() {
|
|
71
|
+
return "mistralai";
|
|
72
|
+
}
|
|
73
|
+
invocationParams(options) {
|
|
74
|
+
return {
|
|
75
|
+
model: this.model,
|
|
76
|
+
suffix: options.suffix,
|
|
77
|
+
temperature: this.temperature,
|
|
78
|
+
maxTokens: this.maxTokens,
|
|
79
|
+
topP: this.topP,
|
|
80
|
+
randomSeed: this.randomSeed,
|
|
81
|
+
stop: options.stop
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* For some given input string and options, return a string output.
|
|
86
|
+
*
|
|
87
|
+
* Despite the fact that `invoke` is overridden below, we still need this
|
|
88
|
+
* in order to handle public APi calls to `generate()`.
|
|
89
|
+
*/
|
|
90
|
+
async _call(prompt, options) {
|
|
91
|
+
const params = {
|
|
92
|
+
...this.invocationParams(options),
|
|
93
|
+
prompt
|
|
94
|
+
};
|
|
95
|
+
const result = await this.completionWithRetry(params, options, false);
|
|
96
|
+
let content = result?.choices?.[0].message.content ?? "";
|
|
97
|
+
if (Array.isArray(content)) content = content[0].type === "text" ? content[0].text : "";
|
|
98
|
+
return content;
|
|
99
|
+
}
|
|
100
|
+
async _generate(prompts, options, runManager) {
|
|
101
|
+
const subPrompts = (0, __langchain_core_utils_chunk_array.chunkArray)(prompts, this.batchSize);
|
|
102
|
+
const choices = [];
|
|
103
|
+
const params = this.invocationParams(options);
|
|
104
|
+
for (let i = 0; i < subPrompts.length; i += 1) {
|
|
105
|
+
const data = await (async () => {
|
|
106
|
+
if (this.streaming) {
|
|
107
|
+
const responseData = [];
|
|
108
|
+
for (let x = 0; x < subPrompts[i].length; x += 1) {
|
|
109
|
+
const choices$1 = [];
|
|
110
|
+
let response;
|
|
111
|
+
const stream = await this.completionWithRetry({
|
|
112
|
+
...params,
|
|
113
|
+
prompt: subPrompts[i][x]
|
|
114
|
+
}, options, true);
|
|
115
|
+
for await (const { data: data$1 } of stream) {
|
|
116
|
+
if (!response) response = {
|
|
117
|
+
id: data$1.id,
|
|
118
|
+
object: "chat.completion",
|
|
119
|
+
created: data$1.created,
|
|
120
|
+
model: data$1.model
|
|
121
|
+
};
|
|
122
|
+
for (const part of data$1.choices) {
|
|
123
|
+
let content = part.delta.content ?? "";
|
|
124
|
+
if (Array.isArray(content)) {
|
|
125
|
+
let strContent = "";
|
|
126
|
+
for (const contentChunk of content) if (contentChunk.type === "text") strContent += contentChunk.text;
|
|
127
|
+
else if (contentChunk.type === "image_url") {
|
|
128
|
+
const imageURL = typeof contentChunk.imageUrl === "string" ? contentChunk.imageUrl : contentChunk.imageUrl.url;
|
|
129
|
+
strContent += imageURL;
|
|
130
|
+
}
|
|
131
|
+
content = strContent;
|
|
132
|
+
}
|
|
133
|
+
if (!choices$1[part.index]) choices$1[part.index] = {
|
|
134
|
+
index: part.index,
|
|
135
|
+
message: {
|
|
136
|
+
role: "assistant",
|
|
137
|
+
content,
|
|
138
|
+
toolCalls: null
|
|
139
|
+
},
|
|
140
|
+
finishReason: part.finishReason ?? "length"
|
|
141
|
+
};
|
|
142
|
+
else {
|
|
143
|
+
const choice = choices$1[part.index];
|
|
144
|
+
choice.message.content += content;
|
|
145
|
+
choice.finishReason = part.finishReason ?? "length";
|
|
146
|
+
}
|
|
147
|
+
runManager?.handleLLMNewToken(content, {
|
|
148
|
+
prompt: part.index,
|
|
149
|
+
completion: part.index
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (options.signal?.aborted) throw new Error("AbortError");
|
|
154
|
+
responseData.push({
|
|
155
|
+
...response,
|
|
156
|
+
choices: choices$1
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return responseData;
|
|
160
|
+
} else {
|
|
161
|
+
const responseData = [];
|
|
162
|
+
for (let x = 0; x < subPrompts[i].length; x += 1) {
|
|
163
|
+
const res = await this.completionWithRetry({
|
|
164
|
+
...params,
|
|
165
|
+
prompt: subPrompts[i][x]
|
|
166
|
+
}, options, false);
|
|
167
|
+
responseData.push(res);
|
|
168
|
+
}
|
|
169
|
+
return responseData;
|
|
170
|
+
}
|
|
171
|
+
})();
|
|
172
|
+
choices.push(...data.map((d) => d.choices ?? []));
|
|
173
|
+
}
|
|
174
|
+
const generations = choices.map((promptChoices) => promptChoices.map((choice) => {
|
|
175
|
+
let text = choice.message?.content ?? "";
|
|
176
|
+
if (Array.isArray(text)) text = text[0].type === "text" ? text[0].text : "";
|
|
177
|
+
return {
|
|
178
|
+
text,
|
|
179
|
+
generationInfo: { finishReason: choice.finishReason }
|
|
180
|
+
};
|
|
181
|
+
}));
|
|
182
|
+
return { generations };
|
|
183
|
+
}
|
|
184
|
+
async completionWithRetry(request, options, stream) {
|
|
185
|
+
const { Mistral } = await this.imports();
|
|
186
|
+
const caller = new __langchain_core_utils_async_caller.AsyncCaller({
|
|
187
|
+
maxConcurrency: options.maxConcurrency || this.maxConcurrency,
|
|
188
|
+
maxRetries: this.maxRetries
|
|
189
|
+
});
|
|
190
|
+
const client = new Mistral({
|
|
191
|
+
apiKey: this.apiKey,
|
|
192
|
+
serverURL: this.serverURL,
|
|
193
|
+
timeoutMs: options.timeout,
|
|
194
|
+
...this.httpClient ? { httpClient: this.httpClient } : {}
|
|
195
|
+
});
|
|
196
|
+
return caller.callWithOptions({ signal: options.signal }, async () => {
|
|
197
|
+
try {
|
|
198
|
+
let res;
|
|
199
|
+
if (stream) res = await client.fim.stream(request);
|
|
200
|
+
else res = await client.fim.complete(request);
|
|
201
|
+
return res;
|
|
202
|
+
} catch (e) {
|
|
203
|
+
if (e.message?.includes("status: 400") || e.message?.toLowerCase().includes("status 400") || e.message?.includes("validation failed")) e.status = 400;
|
|
204
|
+
throw e;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async *_streamResponseChunks(prompt, options, runManager) {
|
|
209
|
+
const params = {
|
|
210
|
+
...this.invocationParams(options),
|
|
211
|
+
prompt
|
|
212
|
+
};
|
|
213
|
+
const stream = await this.completionWithRetry(params, options, true);
|
|
214
|
+
for await (const message of stream) {
|
|
215
|
+
const { data } = message;
|
|
216
|
+
const choice = data?.choices[0];
|
|
217
|
+
if (!choice) continue;
|
|
218
|
+
let text = choice.delta.content ?? "";
|
|
219
|
+
if (Array.isArray(text)) text = text[0].type === "text" ? text[0].text : "";
|
|
220
|
+
const chunk = new __langchain_core_outputs.GenerationChunk({
|
|
221
|
+
text,
|
|
222
|
+
generationInfo: {
|
|
223
|
+
finishReason: choice.finishReason,
|
|
224
|
+
tokenUsage: data.usage
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
yield chunk;
|
|
228
|
+
runManager?.handleLLMNewToken(chunk.text ?? "");
|
|
229
|
+
}
|
|
230
|
+
if (options.signal?.aborted) throw new Error("AbortError");
|
|
231
|
+
}
|
|
232
|
+
addAllHooksToHttpClient() {
|
|
233
|
+
try {
|
|
234
|
+
this.removeAllHooksFromHttpClient();
|
|
235
|
+
const hasHooks = [
|
|
236
|
+
this.beforeRequestHooks,
|
|
237
|
+
this.requestErrorHooks,
|
|
238
|
+
this.responseHooks
|
|
239
|
+
].some((hook) => hook && hook.length > 0);
|
|
240
|
+
if (hasHooks && !this.httpClient) this.httpClient = new __mistralai_mistralai_lib_http_js.HTTPClient();
|
|
241
|
+
if (this.beforeRequestHooks) for (const hook of this.beforeRequestHooks) this.httpClient?.addHook("beforeRequest", hook);
|
|
242
|
+
if (this.requestErrorHooks) for (const hook of this.requestErrorHooks) this.httpClient?.addHook("requestError", hook);
|
|
243
|
+
if (this.responseHooks) for (const hook of this.responseHooks) this.httpClient?.addHook("response", hook);
|
|
244
|
+
} catch {
|
|
245
|
+
throw new Error("Error in adding all hooks");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
removeAllHooksFromHttpClient() {
|
|
249
|
+
try {
|
|
250
|
+
if (this.beforeRequestHooks) for (const hook of this.beforeRequestHooks) this.httpClient?.removeHook("beforeRequest", hook);
|
|
251
|
+
if (this.requestErrorHooks) for (const hook of this.requestErrorHooks) this.httpClient?.removeHook("requestError", hook);
|
|
252
|
+
if (this.responseHooks) for (const hook of this.responseHooks) this.httpClient?.removeHook("response", hook);
|
|
253
|
+
} catch {
|
|
254
|
+
throw new Error("Error in removing hooks");
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
removeHookFromHttpClient(hook) {
|
|
258
|
+
try {
|
|
259
|
+
this.httpClient?.removeHook("beforeRequest", hook);
|
|
260
|
+
this.httpClient?.removeHook("requestError", hook);
|
|
261
|
+
this.httpClient?.removeHook("response", hook);
|
|
262
|
+
} catch {
|
|
263
|
+
throw new Error("Error in removing hook");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/** @ignore */
|
|
267
|
+
async imports() {
|
|
268
|
+
const { Mistral } = await import("@mistralai/mistralai");
|
|
269
|
+
return { Mistral };
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
exports.MistralAI = MistralAI;
|
|
275
|
+
//# sourceMappingURL=llms.cjs.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { CompletionEvent } from "@mistralai/mistralai/models/components/completionevent.js";
|
|
2
|
+
import { BeforeRequestHook, HTTPClient, RequestErrorHook, ResponseHook } from "@mistralai/mistralai/lib/http.js";
|
|
3
|
+
import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
|
|
4
|
+
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
5
|
+
import { GenerationChunk, LLMResult } from "@langchain/core/outputs";
|
|
6
|
+
import { BaseLLMParams, LLM } from "@langchain/core/language_models/llms";
|
|
7
|
+
import { FIMCompletionRequest } from "@mistralai/mistralai/models/components/fimcompletionrequest.js";
|
|
8
|
+
import { FIMCompletionStreamRequest } from "@mistralai/mistralai/models/components/fimcompletionstreamrequest.js";
|
|
9
|
+
import { FIMCompletionResponse } from "@mistralai/mistralai/models/components/fimcompletionresponse.js";
|
|
10
|
+
|
|
11
|
+
//#region src/llms.d.ts
|
|
12
|
+
interface MistralAICallOptions extends BaseLanguageModelCallOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Optional text/code that adds more context for the model.
|
|
15
|
+
* When given a prompt and a suffix the model will fill what
|
|
16
|
+
* is between them. When suffix is not provided, the model
|
|
17
|
+
* will simply execute completion starting with prompt.
|
|
18
|
+
*/
|
|
19
|
+
suffix?: string;
|
|
20
|
+
}
|
|
21
|
+
interface MistralAIInput extends BaseLLMParams {
|
|
22
|
+
/**
|
|
23
|
+
* The name of the model to use.
|
|
24
|
+
* @default "codestral-latest"
|
|
25
|
+
*/
|
|
26
|
+
model?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The API key to use.
|
|
29
|
+
* @default {process.env.MISTRAL_API_KEY}
|
|
30
|
+
*/
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Override the default server URL used by the Mistral SDK.
|
|
34
|
+
* @deprecated use serverURL instead
|
|
35
|
+
*/
|
|
36
|
+
endpoint?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Override the default server URL used by the Mistral SDK.
|
|
39
|
+
*/
|
|
40
|
+
serverURL?: string;
|
|
41
|
+
/**
|
|
42
|
+
* What sampling temperature to use, between 0.0 and 2.0.
|
|
43
|
+
* Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
|
|
44
|
+
* @default {0.7}
|
|
45
|
+
*/
|
|
46
|
+
temperature?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Nucleus sampling, where the model considers the results of the tokens with `topP` probability mass.
|
|
49
|
+
* So 0.1 means only the tokens comprising the top 10% probability mass are considered.
|
|
50
|
+
* Should be between 0 and 1.
|
|
51
|
+
* @default {1}
|
|
52
|
+
*/
|
|
53
|
+
topP?: number;
|
|
54
|
+
/**
|
|
55
|
+
* The maximum number of tokens to generate in the completion.
|
|
56
|
+
* The token count of your prompt plus maxTokens cannot exceed the model's context length.
|
|
57
|
+
*/
|
|
58
|
+
maxTokens?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Whether or not to stream the response.
|
|
61
|
+
* @default {false}
|
|
62
|
+
*/
|
|
63
|
+
streaming?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The seed to use for random sampling. If set, different calls will generate deterministic results.
|
|
66
|
+
* Alias for `seed`
|
|
67
|
+
*/
|
|
68
|
+
randomSeed?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Batch size to use when passing multiple documents to generate
|
|
71
|
+
*/
|
|
72
|
+
batchSize?: number;
|
|
73
|
+
/**
|
|
74
|
+
* A list of custom hooks that must follow (req: Request) => Awaitable<Request | void>
|
|
75
|
+
* They are automatically added when a ChatMistralAI instance is created
|
|
76
|
+
*/
|
|
77
|
+
beforeRequestHooks?: BeforeRequestHook[];
|
|
78
|
+
/**
|
|
79
|
+
* A list of custom hooks that must follow (err: unknown, req: Request) => Awaitable<void>
|
|
80
|
+
* They are automatically added when a ChatMistralAI instance is created
|
|
81
|
+
*/
|
|
82
|
+
requestErrorHooks?: RequestErrorHook[];
|
|
83
|
+
/**
|
|
84
|
+
* A list of custom hooks that must follow (res: Response, req: Request) => Awaitable<void>
|
|
85
|
+
* They are automatically added when a ChatMistralAI instance is created
|
|
86
|
+
*/
|
|
87
|
+
responseHooks?: ResponseHook[];
|
|
88
|
+
/**
|
|
89
|
+
* Optional custom HTTP client to manage API requests
|
|
90
|
+
* Allows users to add custom fetch implementations, hooks, as well as error and response processing.
|
|
91
|
+
*/
|
|
92
|
+
httpClient?: HTTPClient;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* MistralAI completions LLM.
|
|
96
|
+
*/
|
|
97
|
+
declare class MistralAI extends LLM<MistralAICallOptions> implements MistralAIInput {
|
|
98
|
+
static lc_name(): string;
|
|
99
|
+
lc_namespace: string[];
|
|
100
|
+
lc_serializable: boolean;
|
|
101
|
+
model: string;
|
|
102
|
+
temperature: number;
|
|
103
|
+
topP?: number;
|
|
104
|
+
maxTokens?: number | undefined;
|
|
105
|
+
randomSeed?: number | undefined;
|
|
106
|
+
streaming: boolean;
|
|
107
|
+
batchSize: number;
|
|
108
|
+
apiKey: string;
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated use serverURL instead
|
|
111
|
+
*/
|
|
112
|
+
endpoint: string;
|
|
113
|
+
serverURL?: string;
|
|
114
|
+
maxRetries?: number;
|
|
115
|
+
maxConcurrency?: number;
|
|
116
|
+
beforeRequestHooks?: Array<BeforeRequestHook>;
|
|
117
|
+
requestErrorHooks?: Array<RequestErrorHook>;
|
|
118
|
+
responseHooks?: Array<ResponseHook>;
|
|
119
|
+
httpClient?: HTTPClient;
|
|
120
|
+
constructor(fields?: MistralAIInput);
|
|
121
|
+
get lc_secrets(): {
|
|
122
|
+
[key: string]: string;
|
|
123
|
+
} | undefined;
|
|
124
|
+
get lc_aliases(): {
|
|
125
|
+
[key: string]: string;
|
|
126
|
+
} | undefined;
|
|
127
|
+
_llmType(): string;
|
|
128
|
+
invocationParams(options: this["ParsedCallOptions"]): Omit<FIMCompletionRequest | FIMCompletionStreamRequest, "prompt">;
|
|
129
|
+
/**
|
|
130
|
+
* For some given input string and options, return a string output.
|
|
131
|
+
*
|
|
132
|
+
* Despite the fact that `invoke` is overridden below, we still need this
|
|
133
|
+
* in order to handle public APi calls to `generate()`.
|
|
134
|
+
*/
|
|
135
|
+
_call(prompt: string, options: this["ParsedCallOptions"]): Promise<string>;
|
|
136
|
+
_generate(prompts: string[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<LLMResult>;
|
|
137
|
+
completionWithRetry(request: FIMCompletionRequest, options: this["ParsedCallOptions"], stream: false): Promise<FIMCompletionResponse>;
|
|
138
|
+
completionWithRetry(request: FIMCompletionStreamRequest, options: this["ParsedCallOptions"], stream: true): Promise<AsyncIterable<CompletionEvent>>;
|
|
139
|
+
_streamResponseChunks(prompt: string, options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<GenerationChunk>;
|
|
140
|
+
addAllHooksToHttpClient(): void;
|
|
141
|
+
removeAllHooksFromHttpClient(): void;
|
|
142
|
+
removeHookFromHttpClient(hook: BeforeRequestHook | RequestErrorHook | ResponseHook): void;
|
|
143
|
+
private imports;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { MistralAI, MistralAICallOptions, MistralAIInput };
|
|
147
|
+
//# sourceMappingURL=llms.d.cts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { BeforeRequestHook, HTTPClient, RequestErrorHook, ResponseHook } from "@mistralai/mistralai/lib/http.js";
|
|
2
|
+
import { GenerationChunk, LLMResult } from "@langchain/core/outputs";
|
|
3
|
+
import { BaseLLMParams, LLM } from "@langchain/core/language_models/llms";
|
|
4
|
+
import { CompletionEvent } from "@mistralai/mistralai/models/components/completionevent.js";
|
|
5
|
+
import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
|
|
6
|
+
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
7
|
+
import { FIMCompletionRequest } from "@mistralai/mistralai/models/components/fimcompletionrequest.js";
|
|
8
|
+
import { FIMCompletionStreamRequest } from "@mistralai/mistralai/models/components/fimcompletionstreamrequest.js";
|
|
9
|
+
import { FIMCompletionResponse } from "@mistralai/mistralai/models/components/fimcompletionresponse.js";
|
|
10
|
+
|
|
11
|
+
//#region src/llms.d.ts
|
|
12
|
+
interface MistralAICallOptions extends BaseLanguageModelCallOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Optional text/code that adds more context for the model.
|
|
15
|
+
* When given a prompt and a suffix the model will fill what
|
|
16
|
+
* is between them. When suffix is not provided, the model
|
|
17
|
+
* will simply execute completion starting with prompt.
|
|
18
|
+
*/
|
|
19
|
+
suffix?: string;
|
|
20
|
+
}
|
|
21
|
+
interface MistralAIInput extends BaseLLMParams {
|
|
22
|
+
/**
|
|
23
|
+
* The name of the model to use.
|
|
24
|
+
* @default "codestral-latest"
|
|
25
|
+
*/
|
|
26
|
+
model?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The API key to use.
|
|
29
|
+
* @default {process.env.MISTRAL_API_KEY}
|
|
30
|
+
*/
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Override the default server URL used by the Mistral SDK.
|
|
34
|
+
* @deprecated use serverURL instead
|
|
35
|
+
*/
|
|
36
|
+
endpoint?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Override the default server URL used by the Mistral SDK.
|
|
39
|
+
*/
|
|
40
|
+
serverURL?: string;
|
|
41
|
+
/**
|
|
42
|
+
* What sampling temperature to use, between 0.0 and 2.0.
|
|
43
|
+
* Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
|
|
44
|
+
* @default {0.7}
|
|
45
|
+
*/
|
|
46
|
+
temperature?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Nucleus sampling, where the model considers the results of the tokens with `topP` probability mass.
|
|
49
|
+
* So 0.1 means only the tokens comprising the top 10% probability mass are considered.
|
|
50
|
+
* Should be between 0 and 1.
|
|
51
|
+
* @default {1}
|
|
52
|
+
*/
|
|
53
|
+
topP?: number;
|
|
54
|
+
/**
|
|
55
|
+
* The maximum number of tokens to generate in the completion.
|
|
56
|
+
* The token count of your prompt plus maxTokens cannot exceed the model's context length.
|
|
57
|
+
*/
|
|
58
|
+
maxTokens?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Whether or not to stream the response.
|
|
61
|
+
* @default {false}
|
|
62
|
+
*/
|
|
63
|
+
streaming?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The seed to use for random sampling. If set, different calls will generate deterministic results.
|
|
66
|
+
* Alias for `seed`
|
|
67
|
+
*/
|
|
68
|
+
randomSeed?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Batch size to use when passing multiple documents to generate
|
|
71
|
+
*/
|
|
72
|
+
batchSize?: number;
|
|
73
|
+
/**
|
|
74
|
+
* A list of custom hooks that must follow (req: Request) => Awaitable<Request | void>
|
|
75
|
+
* They are automatically added when a ChatMistralAI instance is created
|
|
76
|
+
*/
|
|
77
|
+
beforeRequestHooks?: BeforeRequestHook[];
|
|
78
|
+
/**
|
|
79
|
+
* A list of custom hooks that must follow (err: unknown, req: Request) => Awaitable<void>
|
|
80
|
+
* They are automatically added when a ChatMistralAI instance is created
|
|
81
|
+
*/
|
|
82
|
+
requestErrorHooks?: RequestErrorHook[];
|
|
83
|
+
/**
|
|
84
|
+
* A list of custom hooks that must follow (res: Response, req: Request) => Awaitable<void>
|
|
85
|
+
* They are automatically added when a ChatMistralAI instance is created
|
|
86
|
+
*/
|
|
87
|
+
responseHooks?: ResponseHook[];
|
|
88
|
+
/**
|
|
89
|
+
* Optional custom HTTP client to manage API requests
|
|
90
|
+
* Allows users to add custom fetch implementations, hooks, as well as error and response processing.
|
|
91
|
+
*/
|
|
92
|
+
httpClient?: HTTPClient;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* MistralAI completions LLM.
|
|
96
|
+
*/
|
|
97
|
+
declare class MistralAI extends LLM<MistralAICallOptions> implements MistralAIInput {
|
|
98
|
+
static lc_name(): string;
|
|
99
|
+
lc_namespace: string[];
|
|
100
|
+
lc_serializable: boolean;
|
|
101
|
+
model: string;
|
|
102
|
+
temperature: number;
|
|
103
|
+
topP?: number;
|
|
104
|
+
maxTokens?: number | undefined;
|
|
105
|
+
randomSeed?: number | undefined;
|
|
106
|
+
streaming: boolean;
|
|
107
|
+
batchSize: number;
|
|
108
|
+
apiKey: string;
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated use serverURL instead
|
|
111
|
+
*/
|
|
112
|
+
endpoint: string;
|
|
113
|
+
serverURL?: string;
|
|
114
|
+
maxRetries?: number;
|
|
115
|
+
maxConcurrency?: number;
|
|
116
|
+
beforeRequestHooks?: Array<BeforeRequestHook>;
|
|
117
|
+
requestErrorHooks?: Array<RequestErrorHook>;
|
|
118
|
+
responseHooks?: Array<ResponseHook>;
|
|
119
|
+
httpClient?: HTTPClient;
|
|
120
|
+
constructor(fields?: MistralAIInput);
|
|
121
|
+
get lc_secrets(): {
|
|
122
|
+
[key: string]: string;
|
|
123
|
+
} | undefined;
|
|
124
|
+
get lc_aliases(): {
|
|
125
|
+
[key: string]: string;
|
|
126
|
+
} | undefined;
|
|
127
|
+
_llmType(): string;
|
|
128
|
+
invocationParams(options: this["ParsedCallOptions"]): Omit<FIMCompletionRequest | FIMCompletionStreamRequest, "prompt">;
|
|
129
|
+
/**
|
|
130
|
+
* For some given input string and options, return a string output.
|
|
131
|
+
*
|
|
132
|
+
* Despite the fact that `invoke` is overridden below, we still need this
|
|
133
|
+
* in order to handle public APi calls to `generate()`.
|
|
134
|
+
*/
|
|
135
|
+
_call(prompt: string, options: this["ParsedCallOptions"]): Promise<string>;
|
|
136
|
+
_generate(prompts: string[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<LLMResult>;
|
|
137
|
+
completionWithRetry(request: FIMCompletionRequest, options: this["ParsedCallOptions"], stream: false): Promise<FIMCompletionResponse>;
|
|
138
|
+
completionWithRetry(request: FIMCompletionStreamRequest, options: this["ParsedCallOptions"], stream: true): Promise<AsyncIterable<CompletionEvent>>;
|
|
139
|
+
_streamResponseChunks(prompt: string, options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<GenerationChunk>;
|
|
140
|
+
addAllHooksToHttpClient(): void;
|
|
141
|
+
removeAllHooksFromHttpClient(): void;
|
|
142
|
+
removeHookFromHttpClient(hook: BeforeRequestHook | RequestErrorHook | ResponseHook): void;
|
|
143
|
+
private imports;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { MistralAI, MistralAICallOptions, MistralAIInput };
|
|
147
|
+
//# sourceMappingURL=llms.d.ts.map
|