@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,541 @@
|
|
|
1
|
+
import { BeforeRequestHook, HTTPClient, RequestErrorHook, ResponseHook } from "@mistralai/mistralai/lib/http.js";
|
|
2
|
+
import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
|
|
3
|
+
import { BaseChatModel, BaseChatModelParams, BindToolsInput, LangSmithParams } from "@langchain/core/language_models/chat_models";
|
|
4
|
+
import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
|
|
5
|
+
import { Runnable } from "@langchain/core/runnables";
|
|
6
|
+
import { InteropZodType } from "@langchain/core/utils/types";
|
|
7
|
+
import { ChatCompletionRequest, ChatCompletionRequestToolChoice, Messages } from "@mistralai/mistralai/models/components/chatcompletionrequest.js";
|
|
8
|
+
import { Tool } from "@mistralai/mistralai/models/components/tool.js";
|
|
9
|
+
import { ToolCall } from "@mistralai/mistralai/models/components/toolcall.js";
|
|
10
|
+
import { ChatCompletionStreamRequest } from "@mistralai/mistralai/models/components/chatcompletionstreamrequest.js";
|
|
11
|
+
import { CompletionEvent } from "@mistralai/mistralai/models/components/completionevent.js";
|
|
12
|
+
import { ChatCompletionResponse } from "@mistralai/mistralai/models/components/chatcompletionresponse.js";
|
|
13
|
+
import { BaseLanguageModelCallOptions, BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
|
|
14
|
+
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
15
|
+
|
|
16
|
+
//#region src/chat_models.d.ts
|
|
17
|
+
type ChatMistralAIToolType = ToolCall | Tool | BindToolsInput;
|
|
18
|
+
interface ChatMistralAICallOptions extends Omit<BaseLanguageModelCallOptions, "stop"> {
|
|
19
|
+
response_format?: {
|
|
20
|
+
type: "text" | "json_object";
|
|
21
|
+
};
|
|
22
|
+
tools?: ChatMistralAIToolType[];
|
|
23
|
+
tool_choice?: ChatCompletionRequestToolChoice;
|
|
24
|
+
/**
|
|
25
|
+
* Whether or not to include token usage in the stream.
|
|
26
|
+
* @default {true}
|
|
27
|
+
*/
|
|
28
|
+
streamUsage?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Input to chat model class.
|
|
32
|
+
*/
|
|
33
|
+
interface ChatMistralAIInput extends BaseChatModelParams, Pick<ChatMistralAICallOptions, "streamUsage"> {
|
|
34
|
+
/**
|
|
35
|
+
* The API key to use.
|
|
36
|
+
* @default {process.env.MISTRAL_API_KEY}
|
|
37
|
+
*/
|
|
38
|
+
apiKey?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The name of the model to use.
|
|
41
|
+
* Alias for `model`
|
|
42
|
+
* @deprecated Use `model` instead.
|
|
43
|
+
* @default {"mistral-small-latest"}
|
|
44
|
+
*/
|
|
45
|
+
modelName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The name of the model to use.
|
|
48
|
+
* @default {"mistral-small-latest"}
|
|
49
|
+
*/
|
|
50
|
+
model?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Override the default server URL used by the Mistral SDK.
|
|
53
|
+
* @deprecated use serverURL instead
|
|
54
|
+
*/
|
|
55
|
+
endpoint?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Override the default server URL used by the Mistral SDK.
|
|
58
|
+
*/
|
|
59
|
+
serverURL?: string;
|
|
60
|
+
/**
|
|
61
|
+
* What sampling temperature to use, between 0.0 and 2.0.
|
|
62
|
+
* Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
|
|
63
|
+
* @default {0.7}
|
|
64
|
+
*/
|
|
65
|
+
temperature?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass.
|
|
68
|
+
* So 0.1 means only the tokens comprising the top 10% probability mass are considered.
|
|
69
|
+
* Should be between 0 and 1.
|
|
70
|
+
* @default {1}
|
|
71
|
+
*/
|
|
72
|
+
topP?: number;
|
|
73
|
+
/**
|
|
74
|
+
* The maximum number of tokens to generate in the completion.
|
|
75
|
+
* The token count of your prompt plus max_tokens cannot exceed the model's context length.
|
|
76
|
+
*/
|
|
77
|
+
maxTokens?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Whether or not to stream the response.
|
|
80
|
+
* @default {false}
|
|
81
|
+
*/
|
|
82
|
+
streaming?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Whether to inject a safety prompt before all conversations.
|
|
85
|
+
* @default {false}
|
|
86
|
+
* @deprecated use safePrompt instead
|
|
87
|
+
*/
|
|
88
|
+
safeMode?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Whether to inject a safety prompt before all conversations.
|
|
91
|
+
* @default {false}
|
|
92
|
+
*/
|
|
93
|
+
safePrompt?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* The seed to use for random sampling. If set, different calls will generate deterministic results.
|
|
96
|
+
* Alias for `seed`
|
|
97
|
+
*/
|
|
98
|
+
randomSeed?: number;
|
|
99
|
+
/**
|
|
100
|
+
* The seed to use for random sampling. If set, different calls will generate deterministic results.
|
|
101
|
+
*/
|
|
102
|
+
seed?: number;
|
|
103
|
+
/**
|
|
104
|
+
* A list of custom hooks that must follow (req: Request) => Awaitable<Request | void>
|
|
105
|
+
* They are automatically added when a ChatMistralAI instance is created.
|
|
106
|
+
*/
|
|
107
|
+
beforeRequestHooks?: BeforeRequestHook[];
|
|
108
|
+
/**
|
|
109
|
+
* A list of custom hooks that must follow (err: unknown, req: Request) => Awaitable<void>.
|
|
110
|
+
* They are automatically added when a ChatMistralAI instance is created.
|
|
111
|
+
*/
|
|
112
|
+
requestErrorHooks?: RequestErrorHook[];
|
|
113
|
+
/**
|
|
114
|
+
* A list of custom hooks that must follow (res: Response, req: Request) => Awaitable<void>.
|
|
115
|
+
* They are automatically added when a ChatMistralAI instance is created.
|
|
116
|
+
*/
|
|
117
|
+
responseHooks?: ResponseHook[];
|
|
118
|
+
/**
|
|
119
|
+
* Custom HTTP client to manage API requests.
|
|
120
|
+
* Allows users to add custom fetch implementations, hooks, as well as error and response processing.
|
|
121
|
+
*/
|
|
122
|
+
httpClient?: HTTPClient;
|
|
123
|
+
/**
|
|
124
|
+
* Determines how much the model penalizes the repetition of words or phrases. A higher presence
|
|
125
|
+
* penalty encourages the model to use a wider variety of words and phrases, making the output
|
|
126
|
+
* more diverse and creative.
|
|
127
|
+
*/
|
|
128
|
+
presencePenalty?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Penalizes the repetition of words based on their frequency in the generated text. A higher
|
|
131
|
+
* frequency penalty discourages the model from repeating words that have already appeared frequently
|
|
132
|
+
* in the output, promoting diversity and reducing repetition.
|
|
133
|
+
*/
|
|
134
|
+
frequencyPenalty?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Number of completions to return for each request, input tokens are only billed once.
|
|
137
|
+
*/
|
|
138
|
+
numCompletions?: number;
|
|
139
|
+
}
|
|
140
|
+
declare function convertMessagesToMistralMessages(messages: Array<BaseMessage>): Array<Messages>;
|
|
141
|
+
/**
|
|
142
|
+
* Mistral AI chat model integration.
|
|
143
|
+
*
|
|
144
|
+
* Setup:
|
|
145
|
+
* Install `@langchain/mistralai` and set an environment variable named `MISTRAL_API_KEY`.
|
|
146
|
+
*
|
|
147
|
+
* ```bash
|
|
148
|
+
* npm install @langchain/mistralai
|
|
149
|
+
* export MISTRAL_API_KEY="your-api-key"
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* ## [Constructor args](https://api.js.langchain.com/classes/_langchain_mistralai.ChatMistralAI.html#constructor)
|
|
153
|
+
*
|
|
154
|
+
* ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_mistralai.ChatMistralAICallOptions.html)
|
|
155
|
+
*
|
|
156
|
+
* Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
|
|
157
|
+
* They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:
|
|
158
|
+
*
|
|
159
|
+
* ```typescript
|
|
160
|
+
* // When calling `.withConfig`, call options should be passed via the first argument
|
|
161
|
+
* const llmWithArgsBound = llm.bindTools([...]) // tools array
|
|
162
|
+
* .withConfig({
|
|
163
|
+
* stop: ["\n"], // other call options
|
|
164
|
+
* });
|
|
165
|
+
*
|
|
166
|
+
* // You can also bind tools and call options like this
|
|
167
|
+
* const llmWithTools = llm.bindTools([...], {
|
|
168
|
+
* tool_choice: "auto",
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* ## Examples
|
|
173
|
+
*
|
|
174
|
+
* <details open>
|
|
175
|
+
* <summary><strong>Instantiate</strong></summary>
|
|
176
|
+
*
|
|
177
|
+
* ```typescript
|
|
178
|
+
* import { ChatMistralAI } from '@langchain/mistralai';
|
|
179
|
+
*
|
|
180
|
+
* const llm = new ChatMistralAI({
|
|
181
|
+
* model: "mistral-large-2402",
|
|
182
|
+
* temperature: 0,
|
|
183
|
+
* // other params...
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
* </details>
|
|
187
|
+
*
|
|
188
|
+
* <br />
|
|
189
|
+
*
|
|
190
|
+
* <details>
|
|
191
|
+
* <summary><strong>Invoking</strong></summary>
|
|
192
|
+
*
|
|
193
|
+
* ```typescript
|
|
194
|
+
* const input = `Translate "I love programming" into French.`;
|
|
195
|
+
*
|
|
196
|
+
* // Models also accept a list of chat messages or a formatted prompt
|
|
197
|
+
* const result = await llm.invoke(input);
|
|
198
|
+
* console.log(result);
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* ```txt
|
|
202
|
+
* AIMessage {
|
|
203
|
+
* "content": "The translation of \"I love programming\" into French is \"J'aime la programmation\". Here's the breakdown:\n\n- \"I\" translates to \"Je\"\n- \"love\" translates to \"aime\"\n- \"programming\" translates to \"la programmation\"\n\nSo, \"J'aime la programmation\" means \"I love programming\" in French.",
|
|
204
|
+
* "additional_kwargs": {},
|
|
205
|
+
* "response_metadata": {
|
|
206
|
+
* "tokenUsage": {
|
|
207
|
+
* "completionTokens": 89,
|
|
208
|
+
* "promptTokens": 13,
|
|
209
|
+
* "totalTokens": 102
|
|
210
|
+
* },
|
|
211
|
+
* "finish_reason": "stop"
|
|
212
|
+
* },
|
|
213
|
+
* "tool_calls": [],
|
|
214
|
+
* "invalid_tool_calls": [],
|
|
215
|
+
* "usage_metadata": {
|
|
216
|
+
* "input_tokens": 13,
|
|
217
|
+
* "output_tokens": 89,
|
|
218
|
+
* "total_tokens": 102
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
222
|
+
* </details>
|
|
223
|
+
*
|
|
224
|
+
* <br />
|
|
225
|
+
*
|
|
226
|
+
* <details>
|
|
227
|
+
* <summary><strong>Streaming Chunks</strong></summary>
|
|
228
|
+
*
|
|
229
|
+
* ```typescript
|
|
230
|
+
* for await (const chunk of await llm.stream(input)) {
|
|
231
|
+
* console.log(chunk);
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* ```txt
|
|
236
|
+
* AIMessageChunk {
|
|
237
|
+
* "content": "The",
|
|
238
|
+
* "additional_kwargs": {},
|
|
239
|
+
* "response_metadata": {
|
|
240
|
+
* "prompt": 0,
|
|
241
|
+
* "completion": 0
|
|
242
|
+
* },
|
|
243
|
+
* "tool_calls": [],
|
|
244
|
+
* "tool_call_chunks": [],
|
|
245
|
+
* "invalid_tool_calls": []
|
|
246
|
+
* }
|
|
247
|
+
* AIMessageChunk {
|
|
248
|
+
* "content": " translation",
|
|
249
|
+
* "additional_kwargs": {},
|
|
250
|
+
* "response_metadata": {
|
|
251
|
+
* "prompt": 0,
|
|
252
|
+
* "completion": 0
|
|
253
|
+
* },
|
|
254
|
+
* "tool_calls": [],
|
|
255
|
+
* "tool_call_chunks": [],
|
|
256
|
+
* "invalid_tool_calls": []
|
|
257
|
+
* }
|
|
258
|
+
* AIMessageChunk {
|
|
259
|
+
* "content": " of",
|
|
260
|
+
* "additional_kwargs": {},
|
|
261
|
+
* "response_metadata": {
|
|
262
|
+
* "prompt": 0,
|
|
263
|
+
* "completion": 0
|
|
264
|
+
* },
|
|
265
|
+
* "tool_calls": [],
|
|
266
|
+
* "tool_call_chunks": [],
|
|
267
|
+
* "invalid_tool_calls": []
|
|
268
|
+
* }
|
|
269
|
+
* AIMessageChunk {
|
|
270
|
+
* "content": " \"",
|
|
271
|
+
* "additional_kwargs": {},
|
|
272
|
+
* "response_metadata": {
|
|
273
|
+
* "prompt": 0,
|
|
274
|
+
* "completion": 0
|
|
275
|
+
* },
|
|
276
|
+
* "tool_calls": [],
|
|
277
|
+
* "tool_call_chunks": [],
|
|
278
|
+
* "invalid_tool_calls": []
|
|
279
|
+
* }
|
|
280
|
+
* AIMessageChunk {
|
|
281
|
+
* "content": "I",
|
|
282
|
+
* "additional_kwargs": {},
|
|
283
|
+
* "response_metadata": {
|
|
284
|
+
* "prompt": 0,
|
|
285
|
+
* "completion": 0
|
|
286
|
+
* },
|
|
287
|
+
* "tool_calls": [],
|
|
288
|
+
* "tool_call_chunks": [],
|
|
289
|
+
* "invalid_tool_calls": []
|
|
290
|
+
* }
|
|
291
|
+
* AIMessageChunk {
|
|
292
|
+
* "content": ".",
|
|
293
|
+
* "additional_kwargs": {},
|
|
294
|
+
* "response_metadata": {
|
|
295
|
+
* "prompt": 0,
|
|
296
|
+
* "completion": 0
|
|
297
|
+
* },
|
|
298
|
+
* "tool_calls": [],
|
|
299
|
+
* "tool_call_chunks": [],
|
|
300
|
+
* "invalid_tool_calls": []
|
|
301
|
+
*}
|
|
302
|
+
*AIMessageChunk {
|
|
303
|
+
* "content": "",
|
|
304
|
+
* "additional_kwargs": {},
|
|
305
|
+
* "response_metadata": {
|
|
306
|
+
* "prompt": 0,
|
|
307
|
+
* "completion": 0
|
|
308
|
+
* },
|
|
309
|
+
* "tool_calls": [],
|
|
310
|
+
* "tool_call_chunks": [],
|
|
311
|
+
* "invalid_tool_calls": [],
|
|
312
|
+
* "usage_metadata": {
|
|
313
|
+
* "input_tokens": 13,
|
|
314
|
+
* "output_tokens": 89,
|
|
315
|
+
* "total_tokens": 102
|
|
316
|
+
* }
|
|
317
|
+
*}
|
|
318
|
+
* ```
|
|
319
|
+
* </details>
|
|
320
|
+
*
|
|
321
|
+
* <br />
|
|
322
|
+
*
|
|
323
|
+
* <details>
|
|
324
|
+
* <summary><strong>Aggregate Streamed Chunks</strong></summary>
|
|
325
|
+
*
|
|
326
|
+
* ```typescript
|
|
327
|
+
* import { AIMessageChunk } from '@langchain/core/messages';
|
|
328
|
+
* import { concat } from '@langchain/core/utils/stream';
|
|
329
|
+
*
|
|
330
|
+
* const stream = await llm.stream(input);
|
|
331
|
+
* let full: AIMessageChunk | undefined;
|
|
332
|
+
* for await (const chunk of stream) {
|
|
333
|
+
* full = !full ? chunk : concat(full, chunk);
|
|
334
|
+
* }
|
|
335
|
+
* console.log(full);
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* ```txt
|
|
339
|
+
* AIMessageChunk {
|
|
340
|
+
* "content": "The translation of \"I love programming\" into French is \"J'aime la programmation\". Here's the breakdown:\n\n- \"I\" translates to \"Je\"\n- \"love\" translates to \"aime\"\n- \"programming\" translates to \"la programmation\"\n\nSo, \"J'aime la programmation\" means \"I love programming\" in French.",
|
|
341
|
+
* "additional_kwargs": {},
|
|
342
|
+
* "response_metadata": {
|
|
343
|
+
* "prompt": 0,
|
|
344
|
+
* "completion": 0
|
|
345
|
+
* },
|
|
346
|
+
* "tool_calls": [],
|
|
347
|
+
* "tool_call_chunks": [],
|
|
348
|
+
* "invalid_tool_calls": [],
|
|
349
|
+
* "usage_metadata": {
|
|
350
|
+
* "input_tokens": 13,
|
|
351
|
+
* "output_tokens": 89,
|
|
352
|
+
* "total_tokens": 102
|
|
353
|
+
* }
|
|
354
|
+
* }
|
|
355
|
+
* ```
|
|
356
|
+
* </details>
|
|
357
|
+
*
|
|
358
|
+
* <br />
|
|
359
|
+
*
|
|
360
|
+
* <details>
|
|
361
|
+
* <summary><strong>Bind tools</strong></summary>
|
|
362
|
+
*
|
|
363
|
+
* ```typescript
|
|
364
|
+
* import { z } from 'zod';
|
|
365
|
+
*
|
|
366
|
+
* const GetWeather = {
|
|
367
|
+
* name: "GetWeather",
|
|
368
|
+
* description: "Get the current weather in a given location",
|
|
369
|
+
* schema: z.object({
|
|
370
|
+
* location: z.string().describe("The city and state, e.g. San Francisco, CA")
|
|
371
|
+
* }),
|
|
372
|
+
* }
|
|
373
|
+
*
|
|
374
|
+
* const GetPopulation = {
|
|
375
|
+
* name: "GetPopulation",
|
|
376
|
+
* description: "Get the current population in a given location",
|
|
377
|
+
* schema: z.object({
|
|
378
|
+
* location: z.string().describe("The city and state, e.g. San Francisco, CA")
|
|
379
|
+
* }),
|
|
380
|
+
* }
|
|
381
|
+
*
|
|
382
|
+
* const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);
|
|
383
|
+
* const aiMsg = await llmWithTools.invoke(
|
|
384
|
+
* "Which city is hotter today and which is bigger: LA or NY?"
|
|
385
|
+
* );
|
|
386
|
+
* console.log(aiMsg.tool_calls);
|
|
387
|
+
* ```
|
|
388
|
+
*
|
|
389
|
+
* ```txt
|
|
390
|
+
* [
|
|
391
|
+
* {
|
|
392
|
+
* name: 'GetWeather',
|
|
393
|
+
* args: { location: 'Los Angeles, CA' },
|
|
394
|
+
* type: 'tool_call',
|
|
395
|
+
* id: '47i216yko'
|
|
396
|
+
* },
|
|
397
|
+
* {
|
|
398
|
+
* name: 'GetWeather',
|
|
399
|
+
* args: { location: 'New York, NY' },
|
|
400
|
+
* type: 'tool_call',
|
|
401
|
+
* id: 'nb3v8Fpcn'
|
|
402
|
+
* },
|
|
403
|
+
* {
|
|
404
|
+
* name: 'GetPopulation',
|
|
405
|
+
* args: { location: 'Los Angeles, CA' },
|
|
406
|
+
* type: 'tool_call',
|
|
407
|
+
* id: 'EedWzByIB'
|
|
408
|
+
* },
|
|
409
|
+
* {
|
|
410
|
+
* name: 'GetPopulation',
|
|
411
|
+
* args: { location: 'New York, NY' },
|
|
412
|
+
* type: 'tool_call',
|
|
413
|
+
* id: 'jLdLia7zC'
|
|
414
|
+
* }
|
|
415
|
+
* ]
|
|
416
|
+
* ```
|
|
417
|
+
* </details>
|
|
418
|
+
*
|
|
419
|
+
* <br />
|
|
420
|
+
*
|
|
421
|
+
* <details>
|
|
422
|
+
* <summary><strong>Structured Output</strong></summary>
|
|
423
|
+
*
|
|
424
|
+
* ```typescript
|
|
425
|
+
* import { z } from 'zod';
|
|
426
|
+
*
|
|
427
|
+
* const Joke = z.object({
|
|
428
|
+
* setup: z.string().describe("The setup of the joke"),
|
|
429
|
+
* punchline: z.string().describe("The punchline to the joke"),
|
|
430
|
+
* rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
|
|
431
|
+
* }).describe('Joke to tell user.');
|
|
432
|
+
*
|
|
433
|
+
* const structuredLlm = llm.withStructuredOutput(Joke, { name: "Joke" });
|
|
434
|
+
* const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
|
|
435
|
+
* console.log(jokeResult);
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* ```txt
|
|
439
|
+
* {
|
|
440
|
+
* setup: "Why don't cats play poker in the jungle?",
|
|
441
|
+
* punchline: 'Too many cheetahs!',
|
|
442
|
+
* rating: 7
|
|
443
|
+
* }
|
|
444
|
+
* ```
|
|
445
|
+
* </details>
|
|
446
|
+
*
|
|
447
|
+
* <br />
|
|
448
|
+
*
|
|
449
|
+
* <details>
|
|
450
|
+
* <summary><strong>Usage Metadata</strong></summary>
|
|
451
|
+
*
|
|
452
|
+
* ```typescript
|
|
453
|
+
* const aiMsgForMetadata = await llm.invoke(input);
|
|
454
|
+
* console.log(aiMsgForMetadata.usage_metadata);
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* ```txt
|
|
458
|
+
* { input_tokens: 13, output_tokens: 89, total_tokens: 102 }
|
|
459
|
+
* ```
|
|
460
|
+
* </details>
|
|
461
|
+
*
|
|
462
|
+
* <br />
|
|
463
|
+
*/
|
|
464
|
+
declare class ChatMistralAI<CallOptions extends ChatMistralAICallOptions = ChatMistralAICallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements ChatMistralAIInput {
|
|
465
|
+
// Used for tracing, replace with the same name as your class
|
|
466
|
+
static lc_name(): string;
|
|
467
|
+
lc_namespace: string[];
|
|
468
|
+
model: string;
|
|
469
|
+
apiKey: string;
|
|
470
|
+
/**
|
|
471
|
+
* @deprecated use serverURL instead
|
|
472
|
+
*/
|
|
473
|
+
endpoint: string;
|
|
474
|
+
serverURL?: string;
|
|
475
|
+
temperature: number;
|
|
476
|
+
streaming: boolean;
|
|
477
|
+
topP: number;
|
|
478
|
+
maxTokens: number;
|
|
479
|
+
/**
|
|
480
|
+
* @deprecated use safePrompt instead
|
|
481
|
+
*/
|
|
482
|
+
safeMode: boolean;
|
|
483
|
+
safePrompt: boolean;
|
|
484
|
+
randomSeed?: number;
|
|
485
|
+
seed?: number;
|
|
486
|
+
maxRetries?: number;
|
|
487
|
+
lc_serializable: boolean;
|
|
488
|
+
streamUsage: boolean;
|
|
489
|
+
beforeRequestHooks?: Array<BeforeRequestHook>;
|
|
490
|
+
requestErrorHooks?: Array<RequestErrorHook>;
|
|
491
|
+
responseHooks?: Array<ResponseHook>;
|
|
492
|
+
httpClient?: HTTPClient;
|
|
493
|
+
presencePenalty?: number;
|
|
494
|
+
frequencyPenalty?: number;
|
|
495
|
+
numCompletions?: number;
|
|
496
|
+
constructor(fields?: ChatMistralAIInput);
|
|
497
|
+
get lc_secrets(): {
|
|
498
|
+
[key: string]: string;
|
|
499
|
+
} | undefined;
|
|
500
|
+
get lc_aliases(): {
|
|
501
|
+
[key: string]: string;
|
|
502
|
+
} | undefined;
|
|
503
|
+
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
504
|
+
_llmType(): string;
|
|
505
|
+
/**
|
|
506
|
+
* Get the parameters used to invoke the model
|
|
507
|
+
*/
|
|
508
|
+
invocationParams(options?: this["ParsedCallOptions"]): Omit<ChatCompletionRequest | ChatCompletionStreamRequest, "messages">;
|
|
509
|
+
bindTools(tools: ChatMistralAIToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;
|
|
510
|
+
/**
|
|
511
|
+
* Calls the MistralAI API with retry logic in case of failures.
|
|
512
|
+
* @param {ChatRequest} input The input to send to the MistralAI API.
|
|
513
|
+
* @returns {Promise<MistralAIChatCompletionResult | AsyncIterable<MistralAIChatCompletionEvent>>} The response from the MistralAI API.
|
|
514
|
+
*/
|
|
515
|
+
completionWithRetry(input: ChatCompletionStreamRequest, streaming: true): Promise<AsyncIterable<CompletionEvent>>;
|
|
516
|
+
completionWithRetry(input: ChatCompletionRequest, streaming: false): Promise<ChatCompletionResponse>;
|
|
517
|
+
/** @ignore */
|
|
518
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
519
|
+
_streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
520
|
+
addAllHooksToHttpClient(): void;
|
|
521
|
+
removeAllHooksFromHttpClient(): void;
|
|
522
|
+
removeHookFromHttpClient(hook: BeforeRequestHook | RequestErrorHook | ResponseHook): void;
|
|
523
|
+
/** @ignore */
|
|
524
|
+
_combineLLMOutput(): never[];
|
|
525
|
+
withStructuredOutput<
|
|
526
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
527
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
528
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
529
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
530
|
+
withStructuredOutput<
|
|
531
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
532
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
533
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
534
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
535
|
+
raw: BaseMessage;
|
|
536
|
+
parsed: RunOutput;
|
|
537
|
+
}>;
|
|
538
|
+
}
|
|
539
|
+
//#endregion
|
|
540
|
+
export { ChatMistralAI, ChatMistralAICallOptions, ChatMistralAIInput, convertMessagesToMistralMessages };
|
|
541
|
+
//# sourceMappingURL=chat_models.d.ts.map
|