@ai-sdk/mistral
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -147,2 +147,15 @@ "use strict"; | ||
// src/get-response-metadata.ts | ||
function getResponseMetadata({ | ||
id, | ||
model, | ||
created | ||
}) { | ||
return { | ||
id: id != null ? id : void 0, | ||
modelId: model != null ? model : void 0, | ||
timestamp: created != null ? new Date(created * 1e3) : void 0 | ||
}; | ||
} | ||
// src/mistral-chat-language-model.ts | ||
@@ -284,2 +297,3 @@ var MistralChatLanguageModel = class { | ||
rawResponse: { headers: responseHeaders }, | ||
response: getResponseMetadata(response), | ||
warnings | ||
@@ -293,6 +307,3 @@ }; | ||
headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers), | ||
body: { | ||
...args, | ||
stream: true | ||
}, | ||
body: { ...args, stream: true }, | ||
failedResponseHandler: mistralFailedResponseHandler, | ||
@@ -311,2 +322,3 @@ successfulResponseHandler: (0, import_provider_utils2.createEventSourceResponseHandler)( | ||
}; | ||
let isFirstChunk = true; | ||
return { | ||
@@ -321,2 +333,9 @@ stream: response.pipeThrough( | ||
const value = chunk.value; | ||
if (isFirstChunk) { | ||
isFirstChunk = false; | ||
controller.enqueue({ | ||
type: "response-metadata", | ||
...getResponseMetadata(value) | ||
}); | ||
} | ||
if (value.usage != null) { | ||
@@ -373,2 +392,5 @@ usage = { | ||
var mistralChatResponseSchema = import_zod2.z.object({ | ||
id: import_zod2.z.string().nullish(), | ||
created: import_zod2.z.number().nullish(), | ||
model: import_zod2.z.string().nullish(), | ||
choices: import_zod2.z.array( | ||
@@ -397,3 +419,5 @@ import_zod2.z.object({ | ||
var mistralChatChunkSchema = import_zod2.z.object({ | ||
object: import_zod2.z.literal("chat.completion.chunk"), | ||
id: import_zod2.z.string().nullish(), | ||
created: import_zod2.z.number().nullish(), | ||
model: import_zod2.z.string().nullish(), | ||
choices: import_zod2.z.array( | ||
@@ -400,0 +424,0 @@ import_zod2.z.object({ |
@@ -147,2 +147,15 @@ "use strict"; | ||
// src/get-response-metadata.ts | ||
function getResponseMetadata({ | ||
id, | ||
model, | ||
created | ||
}) { | ||
return { | ||
id: id != null ? id : void 0, | ||
modelId: model != null ? model : void 0, | ||
timestamp: created != null ? new Date(created * 1e3) : void 0 | ||
}; | ||
} | ||
// src/mistral-chat-language-model.ts | ||
@@ -284,2 +297,3 @@ var MistralChatLanguageModel = class { | ||
rawResponse: { headers: responseHeaders }, | ||
response: getResponseMetadata(response), | ||
warnings | ||
@@ -293,6 +307,3 @@ }; | ||
headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers), | ||
body: { | ||
...args, | ||
stream: true | ||
}, | ||
body: { ...args, stream: true }, | ||
failedResponseHandler: mistralFailedResponseHandler, | ||
@@ -311,2 +322,3 @@ successfulResponseHandler: (0, import_provider_utils2.createEventSourceResponseHandler)( | ||
}; | ||
let isFirstChunk = true; | ||
return { | ||
@@ -321,2 +333,9 @@ stream: response.pipeThrough( | ||
const value = chunk.value; | ||
if (isFirstChunk) { | ||
isFirstChunk = false; | ||
controller.enqueue({ | ||
type: "response-metadata", | ||
...getResponseMetadata(value) | ||
}); | ||
} | ||
if (value.usage != null) { | ||
@@ -373,2 +392,5 @@ usage = { | ||
var mistralChatResponseSchema = import_zod2.z.object({ | ||
id: import_zod2.z.string().nullish(), | ||
created: import_zod2.z.number().nullish(), | ||
model: import_zod2.z.string().nullish(), | ||
choices: import_zod2.z.array( | ||
@@ -397,3 +419,5 @@ import_zod2.z.object({ | ||
var mistralChatChunkSchema = import_zod2.z.object({ | ||
object: import_zod2.z.literal("chat.completion.chunk"), | ||
id: import_zod2.z.string().nullish(), | ||
created: import_zod2.z.number().nullish(), | ||
model: import_zod2.z.string().nullish(), | ||
choices: import_zod2.z.array( | ||
@@ -400,0 +424,0 @@ import_zod2.z.object({ |
{ | ||
"name": "@ai-sdk/mistral", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"license": "Apache-2.0", | ||
@@ -10,3 +10,4 @@ "sideEffects": false, | ||
"files": [ | ||
"dist/**/*" | ||
"dist/**/*", | ||
"CHANGELOG.md" | ||
], | ||
@@ -22,4 +23,4 @@ "exports": { | ||
"dependencies": { | ||
"@ai-sdk/provider": "0.0.22", | ||
"@ai-sdk/provider-utils": "1.0.17" | ||
"@ai-sdk/provider": "0.0.23", | ||
"@ai-sdk/provider-utils": "1.0.18" | ||
}, | ||
@@ -26,0 +27,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
146843
11
1917
+ Added@ai-sdk/provider@0.0.23(transitive)
+ Added@ai-sdk/provider-utils@1.0.18(transitive)
- Removed@ai-sdk/provider@0.0.22(transitive)
- Removed@ai-sdk/provider-utils@1.0.17(transitive)
Updated@ai-sdk/provider@0.0.23