@ai-sdk/openai-compatible 1.0.9 → 1.0.10

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // src/openai-compatible-chat-language-model.ts
1
+ // src/chat/openai-compatible-chat-language-model.ts
2
2
  import {
3
3
  InvalidResponseDataError
4
4
  } from "@ai-sdk/provider";
@@ -14,7 +14,7 @@ import {
14
14
  } from "@ai-sdk/provider-utils";
15
15
  import { z as z3 } from "zod/v4";
16
16
 
17
- // src/convert-to-openai-compatible-chat-messages.ts
17
+ // src/chat/convert-to-openai-compatible-chat-messages.ts
18
18
  import {
19
19
  UnsupportedFunctionalityError
20
20
  } from "@ai-sdk/provider";
@@ -137,7 +137,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
137
137
  return messages;
138
138
  }
139
139
 
140
- // src/get-response-metadata.ts
140
+ // src/chat/get-response-metadata.ts
141
141
  function getResponseMetadata({
142
142
  id,
143
143
  model,
@@ -150,7 +150,7 @@ function getResponseMetadata({
150
150
  };
151
151
  }
152
152
 
153
- // src/map-openai-compatible-finish-reason.ts
153
+ // src/chat/map-openai-compatible-finish-reason.ts
154
154
  function mapOpenAICompatibleFinishReason(finishReason) {
155
155
  switch (finishReason) {
156
156
  case "stop":
@@ -167,7 +167,7 @@ function mapOpenAICompatibleFinishReason(finishReason) {
167
167
  }
168
168
  }
169
169
 
170
- // src/openai-compatible-chat-options.ts
170
+ // src/chat/openai-compatible-chat-options.ts
171
171
  import { z } from "zod/v4";
172
172
  var openaiCompatibleProviderOptions = z.object({
173
173
  /**
@@ -199,7 +199,7 @@ var defaultOpenAICompatibleErrorStructure = {
199
199
  errorToMessage: (data) => data.error.message
200
200
  };
201
201
 
202
- // src/openai-compatible-prepare-tools.ts
202
+ // src/chat/openai-compatible-prepare-tools.ts
203
203
  import {
204
204
  UnsupportedFunctionalityError as UnsupportedFunctionalityError2
205
205
  } from "@ai-sdk/provider";
@@ -254,7 +254,7 @@ function prepareTools({
254
254
  }
255
255
  }
256
256
 
257
- // src/openai-compatible-chat-language-model.ts
257
+ // src/chat/openai-compatible-chat-language-model.ts
258
258
  var OpenAICompatibleChatLanguageModel = class {
259
259
  // type inferred via constructor
260
260
  constructor(modelId, config) {
@@ -778,7 +778,7 @@ var createOpenAICompatibleChatChunkSchema = (errorSchema) => z3.union([
778
778
  errorSchema
779
779
  ]);
780
780
 
781
- // src/openai-compatible-completion-language-model.ts
781
+ // src/completion/openai-compatible-completion-language-model.ts
782
782
  import {
783
783
  combineHeaders as combineHeaders2,
784
784
  createEventSourceResponseHandler as createEventSourceResponseHandler2,
@@ -789,7 +789,7 @@ import {
789
789
  } from "@ai-sdk/provider-utils";
790
790
  import { z as z5 } from "zod/v4";
791
791
 
792
- // src/convert-to-openai-compatible-completion-prompt.ts
792
+ // src/completion/convert-to-openai-compatible-completion-prompt.ts
793
793
  import {
794
794
  InvalidPromptError,
795
795
  UnsupportedFunctionalityError as UnsupportedFunctionalityError3
@@ -867,7 +867,37 @@ ${user}:`]
867
867
  };
868
868
  }
869
869
 
870
- // src/openai-compatible-completion-options.ts
870
+ // src/completion/get-response-metadata.ts
871
+ function getResponseMetadata2({
872
+ id,
873
+ model,
874
+ created
875
+ }) {
876
+ return {
877
+ id: id != null ? id : void 0,
878
+ modelId: model != null ? model : void 0,
879
+ timestamp: created != null ? new Date(created * 1e3) : void 0
880
+ };
881
+ }
882
+
883
+ // src/completion/map-openai-compatible-finish-reason.ts
884
+ function mapOpenAICompatibleFinishReason2(finishReason) {
885
+ switch (finishReason) {
886
+ case "stop":
887
+ return "stop";
888
+ case "length":
889
+ return "length";
890
+ case "content_filter":
891
+ return "content-filter";
892
+ case "function_call":
893
+ case "tool_calls":
894
+ return "tool-calls";
895
+ default:
896
+ return "unknown";
897
+ }
898
+ }
899
+
900
+ // src/completion/openai-compatible-completion-options.ts
871
901
  import { z as z4 } from "zod/v4";
872
902
  var openaiCompatibleCompletionProviderOptions = z4.object({
873
903
  /**
@@ -892,7 +922,7 @@ var openaiCompatibleCompletionProviderOptions = z4.object({
892
922
  user: z4.string().optional()
893
923
  });
894
924
 
895
- // src/openai-compatible-completion-language-model.ts
925
+ // src/completion/openai-compatible-completion-language-model.ts
896
926
  var OpenAICompatibleCompletionLanguageModel = class {
897
927
  // type inferred via constructor
898
928
  constructor(modelId, config) {
@@ -1014,10 +1044,10 @@ var OpenAICompatibleCompletionLanguageModel = class {
1014
1044
  outputTokens: (_d = (_c = response.usage) == null ? void 0 : _c.completion_tokens) != null ? _d : void 0,
1015
1045
  totalTokens: (_f = (_e = response.usage) == null ? void 0 : _e.total_tokens) != null ? _f : void 0
1016
1046
  },
1017
- finishReason: mapOpenAICompatibleFinishReason(choice.finish_reason),
1047
+ finishReason: mapOpenAICompatibleFinishReason2(choice.finish_reason),
1018
1048
  request: { body: args },
1019
1049
  response: {
1020
- ...getResponseMetadata(response),
1050
+ ...getResponseMetadata2(response),
1021
1051
  headers: responseHeaders,
1022
1052
  body: rawResponse
1023
1053
  },
@@ -1079,7 +1109,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
1079
1109
  isFirstChunk = false;
1080
1110
  controller.enqueue({
1081
1111
  type: "response-metadata",
1082
- ...getResponseMetadata(value)
1112
+ ...getResponseMetadata2(value)
1083
1113
  });
1084
1114
  controller.enqueue({
1085
1115
  type: "text-start",
@@ -1093,7 +1123,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
1093
1123
  }
1094
1124
  const choice = value.choices[0];
1095
1125
  if ((choice == null ? void 0 : choice.finish_reason) != null) {
1096
- finishReason = mapOpenAICompatibleFinishReason(
1126
+ finishReason = mapOpenAICompatibleFinishReason2(
1097
1127
  choice.finish_reason
1098
1128
  );
1099
1129
  }
@@ -1156,7 +1186,7 @@ var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => z5.union([
1156
1186
  errorSchema
1157
1187
  ]);
1158
1188
 
1159
- // src/openai-compatible-embedding-model.ts
1189
+ // src/embedding/openai-compatible-embedding-model.ts
1160
1190
  import {
1161
1191
  TooManyEmbeddingValuesForCallError
1162
1192
  } from "@ai-sdk/provider";
@@ -1169,7 +1199,7 @@ import {
1169
1199
  } from "@ai-sdk/provider-utils";
1170
1200
  import { z as z7 } from "zod/v4";
1171
1201
 
1172
- // src/openai-compatible-embedding-options.ts
1202
+ // src/embedding/openai-compatible-embedding-options.ts
1173
1203
  import { z as z6 } from "zod/v4";
1174
1204
  var openaiCompatibleEmbeddingProviderOptions = z6.object({
1175
1205
  /**
@@ -1184,7 +1214,7 @@ var openaiCompatibleEmbeddingProviderOptions = z6.object({
1184
1214
  user: z6.string().optional()
1185
1215
  });
1186
1216
 
1187
- // src/openai-compatible-embedding-model.ts
1217
+ // src/embedding/openai-compatible-embedding-model.ts
1188
1218
  var OpenAICompatibleEmbeddingModel = class {
1189
1219
  constructor(modelId, config) {
1190
1220
  this.specificationVersion = "v2";
@@ -1272,7 +1302,7 @@ var openaiTextEmbeddingResponseSchema = z7.object({
1272
1302
  providerMetadata: z7.record(z7.string(), z7.record(z7.string(), z7.any())).optional()
1273
1303
  });
1274
1304
 
1275
- // src/openai-compatible-image-model.ts
1305
+ // src/image/openai-compatible-image-model.ts
1276
1306
  import {
1277
1307
  combineHeaders as combineHeaders4,
1278
1308
  createJsonErrorResponseHandler as createJsonErrorResponseHandler4,