Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/openai-compatible

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/openai-compatible - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

6

CHANGELOG.md
# @ai-sdk/openai-compatible
## 0.0.12
### Patch Changes
- 70003b8: feat (provider/openai-compatible): Allow extending messages via metadata.
## 0.0.11

@@ -4,0 +10,0 @@

8

dist/index.d.ts

@@ -106,9 +106,9 @@ import { ProviderV1, LanguageModelV1, EmbeddingModelV1, LanguageModelV1ObjectGenerationMode } from '@ai-sdk/provider';

message: string;
type?: string | null | undefined;
code?: string | number | null | undefined;
type?: string | null | undefined;
param?: any;
}, {
message: string;
type?: string | null | undefined;
code?: string | number | null | undefined;
type?: string | null | undefined;
param?: any;

@@ -119,4 +119,4 @@ }>;

message: string;
type?: string | null | undefined;
code?: string | number | null | undefined;
type?: string | null | undefined;
param?: any;

@@ -127,4 +127,4 @@ };

message: string;
type?: string | null | undefined;
code?: string | number | null | undefined;
type?: string | null | undefined;
param?: any;

@@ -131,0 +131,0 @@ };

@@ -41,8 +41,13 @@ "use strict";

var import_provider_utils = require("@ai-sdk/provider-utils");
function getOpenAIMetadata(message) {
var _a, _b;
return (_b = (_a = message == null ? void 0 : message.providerMetadata) == null ? void 0 : _a.openaiCompatible) != null ? _b : {};
}
function convertToOpenAICompatibleChatMessages(prompt) {
const messages = [];
for (const { role, content } of prompt) {
for (const { role, content, ...message } of prompt) {
const metadata = getOpenAIMetadata({ ...message });
switch (role) {
case "system": {
messages.push({ role: "system", content });
messages.push({ role: "system", content, ...metadata });
break;

@@ -52,3 +57,7 @@ }

if (content.length === 1 && content[0].type === "text") {
messages.push({ role: "user", content: content[0].text });
messages.push({
role: "user",
content: content[0].text,
...getOpenAIMetadata(content[0])
});
break;

@@ -60,5 +69,6 @@ }

var _a;
const partMetadata = getOpenAIMetadata(part);
switch (part.type) {
case "text": {
return { type: "text", text: part.text };
return { type: "text", text: part.text, ...partMetadata };
}

@@ -70,3 +80,4 @@ case "image": {

url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${(0, import_provider_utils.convertUint8ArrayToBase64)(part.image)}`
}
},
...partMetadata
};

@@ -80,3 +91,4 @@ }

}
})
}),
...metadata
});

@@ -89,2 +101,3 @@ break;

for (const part of content) {
const partMetadata = getOpenAIMetadata(part);
switch (part.type) {

@@ -102,3 +115,4 @@ case "text": {

arguments: JSON.stringify(part.args)
}
},
...partMetadata
});

@@ -116,3 +130,4 @@ break;

content: text,
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
...metadata
});

@@ -123,6 +138,8 @@ break;

for (const toolResponse of content) {
const toolResponseMetadata = getOpenAIMetadata(toolResponse);
messages.push({
role: "tool",
tool_call_id: toolResponse.toolCallId,
content: JSON.stringify(toolResponse.result)
content: JSON.stringify(toolResponse.result),
...toolResponseMetadata
});

@@ -129,0 +146,0 @@ }

{
"name": "@ai-sdk/openai-compatible",
"version": "0.0.11",
"version": "0.0.12",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "sideEffects": false,

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

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