@core-ai/mistral 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +21 -24
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -144,11 +144,7 @@ function convertToolChoice(choice) {
144
144
  };
145
145
  }
146
146
  function getStructuredOutputToolName(options) {
147
- const trimmedName = options.schemaName?.trim();
148
- if (trimmedName && trimmedName.length > 0) {
149
- return trimmedName;
150
- }
151
- return DEFAULT_STRUCTURED_OUTPUT_TOOL_NAME;
147
+ return options.schemaName?.trim() || DEFAULT_STRUCTURED_OUTPUT_TOOL_NAME;
152
148
  }
153
149
  function createStructuredOutputOptions(options) {
154
150
  const toolName = getStructuredOutputToolName(options);
@@ -212,7 +208,7 @@ function mapMistralProviderOptionsToRequest(baseRequest, providerOptions) {
212
208
  if (!providerOptions) {
213
209
  return baseRequest;
214
210
  }
215
- const mergedRequest = {
211
+ return {
216
212
  ...baseRequest,
217
213
  ...providerOptions.stopSequences ? { stop: providerOptions.stopSequences } : {},
218
214
  ...providerOptions.frequencyPenalty !== void 0 ? { frequencyPenalty: providerOptions.frequencyPenalty } : {},
@@ -222,7 +218,6 @@ function mapMistralProviderOptionsToRequest(baseRequest, providerOptions) {
222
218
  ...providerOptions.promptMode !== void 0 ? { promptMode: providerOptions.promptMode } : {},
223
219
  ...providerOptions.safePrompt !== void 0 ? { safePrompt: providerOptions.safePrompt } : {}
224
220
  };
225
- return mergedRequest;
226
221
  }
227
222
  function mapGenerateResponse(response) {
228
223
  const firstChoice = response.choices[0];
@@ -266,6 +261,16 @@ async function* transformStream(stream) {
266
261
  },
267
262
  outputTokenDetails: {}
268
263
  };
264
+ const closeReasoning = () => {
265
+ if (!reasoningOpen) {
266
+ return null;
267
+ }
268
+ reasoningOpen = false;
269
+ return {
270
+ type: "reasoning-end",
271
+ providerMetadata: { mistral: {} }
272
+ };
273
+ };
269
274
  for await (const event of stream) {
270
275
  const chunk = event.data;
271
276
  if (chunk.usage) {
@@ -291,12 +296,9 @@ async function* transformStream(stream) {
291
296
  }
292
297
  }
293
298
  for (const textDelta of extractTextDeltas(choice.delta.content)) {
294
- if (reasoningOpen) {
295
- reasoningOpen = false;
296
- yield {
297
- type: "reasoning-end",
298
- providerMetadata: { mistral: {} }
299
- };
299
+ const reasoningEnd2 = closeReasoning();
300
+ if (reasoningEnd2) {
301
+ yield reasoningEnd2;
300
302
  }
301
303
  yield {
302
304
  type: "text-delta",
@@ -304,12 +306,9 @@ async function* transformStream(stream) {
304
306
  };
305
307
  }
306
308
  if (choice.delta.toolCalls) {
307
- if (reasoningOpen) {
308
- reasoningOpen = false;
309
- yield {
310
- type: "reasoning-end",
311
- providerMetadata: { mistral: {} }
312
- };
309
+ const reasoningEnd2 = closeReasoning();
310
+ if (reasoningEnd2) {
311
+ yield reasoningEnd2;
313
312
  }
314
313
  for (const [
315
314
  position,
@@ -364,11 +363,9 @@ async function* transformStream(stream) {
364
363
  yield* emitBufferedToolCalls(bufferedToolCalls, emittedToolCalls);
365
364
  }
366
365
  }
367
- if (reasoningOpen) {
368
- yield {
369
- type: "reasoning-end",
370
- providerMetadata: { mistral: {} }
371
- };
366
+ const reasoningEnd = closeReasoning();
367
+ if (reasoningEnd) {
368
+ yield reasoningEnd;
372
369
  }
373
370
  yield* emitBufferedToolCalls(bufferedToolCalls, emittedToolCalls);
374
371
  yield {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@core-ai/mistral",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Mistral provider package for @core-ai/core-ai",
5
5
  "license": "MIT",
6
6
  "author": "Omnifact (https://omnifact.ai)",
@@ -41,7 +41,7 @@
41
41
  "test:watch": "vitest"
42
42
  },
43
43
  "dependencies": {
44
- "@core-ai/core-ai": "^0.6.0",
44
+ "@core-ai/core-ai": "^0.6.1",
45
45
  "@mistralai/mistralai": "^1.14.0",
46
46
  "zod-to-json-schema": "^3.25.1"
47
47
  },