@core-ai/mistral 0.13.1 → 0.14.0
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/index.js +19 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -255,6 +255,7 @@ async function* transformStream(stream) {
|
|
|
255
255
|
const bufferedToolCalls = /* @__PURE__ */ new Map();
|
|
256
256
|
const emittedToolCalls = /* @__PURE__ */ new Set();
|
|
257
257
|
let finishReason = "unknown";
|
|
258
|
+
let textOpen = false;
|
|
258
259
|
let reasoningOpen = false;
|
|
259
260
|
let usage = {
|
|
260
261
|
inputTokens: 0,
|
|
@@ -275,6 +276,20 @@ async function* transformStream(stream) {
|
|
|
275
276
|
providerMetadata: { mistral: {} }
|
|
276
277
|
};
|
|
277
278
|
};
|
|
279
|
+
const startText = function* () {
|
|
280
|
+
if (textOpen) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
textOpen = true;
|
|
284
|
+
yield { type: "text-start" };
|
|
285
|
+
};
|
|
286
|
+
const closeText = function* () {
|
|
287
|
+
if (!textOpen) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
textOpen = false;
|
|
291
|
+
yield { type: "text-end" };
|
|
292
|
+
};
|
|
278
293
|
for await (const event of stream) {
|
|
279
294
|
const chunk = event.data;
|
|
280
295
|
if (chunk.usage) {
|
|
@@ -286,6 +301,7 @@ async function* transformStream(stream) {
|
|
|
286
301
|
}
|
|
287
302
|
const thinkingDeltas = extractThinkingDeltas(choice.delta.content);
|
|
288
303
|
if (thinkingDeltas.length > 0) {
|
|
304
|
+
yield* closeText();
|
|
289
305
|
if (!reasoningOpen) {
|
|
290
306
|
reasoningOpen = true;
|
|
291
307
|
yield {
|
|
@@ -304,12 +320,14 @@ async function* transformStream(stream) {
|
|
|
304
320
|
if (reasoningEnd2) {
|
|
305
321
|
yield reasoningEnd2;
|
|
306
322
|
}
|
|
323
|
+
yield* startText();
|
|
307
324
|
yield {
|
|
308
325
|
type: "text-delta",
|
|
309
326
|
text: textDelta
|
|
310
327
|
};
|
|
311
328
|
}
|
|
312
329
|
if (choice.delta.toolCalls) {
|
|
330
|
+
yield* closeText();
|
|
313
331
|
const reasoningEnd2 = closeReasoning();
|
|
314
332
|
if (reasoningEnd2) {
|
|
315
333
|
yield reasoningEnd2;
|
|
@@ -371,6 +389,7 @@ async function* transformStream(stream) {
|
|
|
371
389
|
if (reasoningEnd) {
|
|
372
390
|
yield reasoningEnd;
|
|
373
391
|
}
|
|
392
|
+
yield* closeText();
|
|
374
393
|
yield* emitBufferedToolCalls(bufferedToolCalls, emittedToolCalls);
|
|
375
394
|
yield {
|
|
376
395
|
type: "finish",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/mistral",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Mistral provider package for @core-ai/core-ai",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Omnifact (https://omnifact.ai)",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test:watch": "vitest"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@core-ai/core-ai": "^0.
|
|
46
|
+
"@core-ai/core-ai": "^0.14.0",
|
|
47
47
|
"@mistralai/mistralai": "^1.14.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|