New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/mistral

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/mistral - npm Package Compare versions

Comparing version 0.0.44 to 0.0.46

97

./dist/index.js

@@ -171,2 +171,51 @@ "use strict";

// src/mistral-prepare-tools.ts
function prepareTools(mode) {
var _a;
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
const toolWarnings = [];
if (tools == null) {
return { tools: void 0, tool_choice: void 0, toolWarnings };
}
const mistralTools = [];
for (const tool of tools) {
if (tool.type === "provider-defined") {
toolWarnings.push({ type: "unsupported-tool", tool });
} else {
mistralTools.push({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
});
}
}
const toolChoice = mode.toolChoice;
if (toolChoice == null) {
return { tools: mistralTools, tool_choice: void 0, toolWarnings };
}
const type = toolChoice.type;
switch (type) {
case "auto":
case "none":
return { tools: mistralTools, tool_choice: type, toolWarnings };
case "required":
return { tools: mistralTools, tool_choice: "any", toolWarnings };
case "tool":
return {
tools: mistralTools.filter(
(tool) => tool.function.name === toolChoice.toolName
),
tool_choice: "any",
toolWarnings
};
default: {
const _exhaustiveCheck = type;
throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`);
}
}
}
// src/mistral-chat-language-model.ts

@@ -248,5 +297,6 @@ var MistralChatLanguageModel = class {

case "regular": {
const { tools, tool_choice, toolWarnings } = prepareTools(mode);
return {
args: { ...baseArgs, ...prepareToolsAndToolChoice(mode) },
warnings
args: { ...baseArgs, tools, tool_choice },
warnings: [...warnings, ...toolWarnings]
};

@@ -315,2 +365,3 @@ }

rawResponse: { headers: responseHeaders },
request: { body: JSON.stringify(args) },
response: getResponseMetadata(response),

@@ -322,6 +373,7 @@ warnings

const { args, warnings } = this.getArgs(options);
const body = { ...args, stream: true };
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
url: `${this.config.baseURL}/chat/completions`,
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
body: { ...args, stream: true },
body,
failedResponseHandler: mistralFailedResponseHandler,

@@ -414,2 +466,3 @@ successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(

rawResponse: { headers: responseHeaders },
request: { body: JSON.stringify(body) },
warnings

@@ -470,40 +523,2 @@ };

});
function prepareToolsAndToolChoice(mode) {
var _a;
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
if (tools == null) {
return { tools: void 0, tool_choice: void 0 };
}
const mappedTools = tools.map((tool) => ({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
}));
const toolChoice = mode.toolChoice;
if (toolChoice == null) {
return { tools: mappedTools, tool_choice: void 0 };
}
const type = toolChoice.type;
switch (type) {
case "auto":
case "none":
return { tools: mappedTools, tool_choice: type };
case "required":
return { tools: mappedTools, tool_choice: "any" };
case "tool":
return {
tools: mappedTools.filter(
(tool) => tool.function.name === toolChoice.toolName
),
tool_choice: "any"
};
default: {
const _exhaustiveCheck = type;
throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`);
}
}
}

@@ -510,0 +525,0 @@ // src/mistral-facade.ts

# @ai-sdk/mistral
## 0.0.46
### Patch Changes
- 3b1b69a: feat: provider-defined tools
- Updated dependencies [aa98cdb]
- Updated dependencies [1486128]
- Updated dependencies [7b937c5]
- Updated dependencies [3b1b69a]
- Updated dependencies [811a317]
- @ai-sdk/provider-utils@1.0.22
- @ai-sdk/provider@0.0.26
## 0.0.45
### Patch Changes
- b9b0d7b: feat (ai): access raw request body
- Updated dependencies [b9b0d7b]
- @ai-sdk/provider@0.0.25
- @ai-sdk/provider-utils@1.0.21
## 0.0.44

@@ -4,0 +26,0 @@

@@ -171,2 +171,51 @@ "use strict";

// src/mistral-prepare-tools.ts
function prepareTools(mode) {
var _a;
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
const toolWarnings = [];
if (tools == null) {
return { tools: void 0, tool_choice: void 0, toolWarnings };
}
const mistralTools = [];
for (const tool of tools) {
if (tool.type === "provider-defined") {
toolWarnings.push({ type: "unsupported-tool", tool });
} else {
mistralTools.push({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
});
}
}
const toolChoice = mode.toolChoice;
if (toolChoice == null) {
return { tools: mistralTools, tool_choice: void 0, toolWarnings };
}
const type = toolChoice.type;
switch (type) {
case "auto":
case "none":
return { tools: mistralTools, tool_choice: type, toolWarnings };
case "required":
return { tools: mistralTools, tool_choice: "any", toolWarnings };
case "tool":
return {
tools: mistralTools.filter(
(tool) => tool.function.name === toolChoice.toolName
),
tool_choice: "any",
toolWarnings
};
default: {
const _exhaustiveCheck = type;
throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`);
}
}
}
// src/mistral-chat-language-model.ts

@@ -248,5 +297,6 @@ var MistralChatLanguageModel = class {

case "regular": {
const { tools, tool_choice, toolWarnings } = prepareTools(mode);
return {
args: { ...baseArgs, ...prepareToolsAndToolChoice(mode) },
warnings
args: { ...baseArgs, tools, tool_choice },
warnings: [...warnings, ...toolWarnings]
};

@@ -315,2 +365,3 @@ }

rawResponse: { headers: responseHeaders },
request: { body: JSON.stringify(args) },
response: getResponseMetadata(response),

@@ -322,6 +373,7 @@ warnings

const { args, warnings } = this.getArgs(options);
const body = { ...args, stream: true };
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
url: `${this.config.baseURL}/chat/completions`,
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
body: { ...args, stream: true },
body,
failedResponseHandler: mistralFailedResponseHandler,

@@ -414,2 +466,3 @@ successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(

rawResponse: { headers: responseHeaders },
request: { body: JSON.stringify(body) },
warnings

@@ -470,40 +523,2 @@ };

});
function prepareToolsAndToolChoice(mode) {
var _a;
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
if (tools == null) {
return { tools: void 0, tool_choice: void 0 };
}
const mappedTools = tools.map((tool) => ({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
}));
const toolChoice = mode.toolChoice;
if (toolChoice == null) {
return { tools: mappedTools, tool_choice: void 0 };
}
const type = toolChoice.type;
switch (type) {
case "auto":
case "none":
return { tools: mappedTools, tool_choice: type };
case "required":
return { tools: mappedTools, tool_choice: "any" };
case "tool":
return {
tools: mappedTools.filter(
(tool) => tool.function.name === toolChoice.toolName
),
tool_choice: "any"
};
default: {
const _exhaustiveCheck = type;
throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`);
}
}
}

@@ -510,0 +525,0 @@ // src/mistral-facade.ts

{
"name": "@ai-sdk/mistral",
"version": "0.0.44",
"version": "0.0.46",
"license": "Apache-2.0",

@@ -22,4 +22,4 @@ "sideEffects": false,

"dependencies": {
"@ai-sdk/provider": "0.0.24",
"@ai-sdk/provider-utils": "1.0.20"
"@ai-sdk/provider": "0.0.26",
"@ai-sdk/provider-utils": "1.0.22"
},

@@ -26,0 +26,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc