@ai-sdk/openai-compatible 2.0.7 → 2.0.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai-compatible
2
2
 
3
+ ## 2.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - bc02a3c: feat(groq,compat): add strictJsonSchema for providers
8
+
9
+ ## 2.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 78fcb18: fix(compat,groq): send reasoning-end before text-start in streaming
14
+
3
15
  ## 2.0.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -22,6 +22,7 @@ declare const openaiCompatibleProviderOptions: z.ZodObject<{
22
22
  user: z.ZodOptional<z.ZodString>;
23
23
  reasoningEffort: z.ZodOptional<z.ZodString>;
24
24
  textVerbosity: z.ZodOptional<z.ZodString>;
25
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
25
26
  }, z.core.$strip>;
26
27
  type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
27
28
 
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ declare const openaiCompatibleProviderOptions: z.ZodObject<{
22
22
  user: z.ZodOptional<z.ZodString>;
23
23
  reasoningEffort: z.ZodOptional<z.ZodString>;
24
24
  textVerbosity: z.ZodOptional<z.ZodString>;
25
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
25
26
  }, z.core.$strip>;
26
27
  type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
27
28
 
package/dist/index.js CHANGED
@@ -273,7 +273,15 @@ var openaiCompatibleProviderOptions = import_v42.z.object({
273
273
  /**
274
274
  * Controls the verbosity of the generated text. Defaults to `medium`.
275
275
  */
276
- textVerbosity: import_v42.z.string().optional()
276
+ textVerbosity: import_v42.z.string().optional(),
277
+ /**
278
+ * Whether to use strict JSON schema validation.
279
+ * When true, the model uses constrained decoding to guarantee schema compliance.
280
+ * Only used when the provider supports structured outputs and a schema is provided.
281
+ *
282
+ * @default true
283
+ */
284
+ strictJsonSchema: import_v42.z.boolean().optional()
277
285
  });
278
286
 
279
287
  // src/chat/openai-compatible-prepare-tools.ts
@@ -373,7 +381,7 @@ var OpenAICompatibleChatLanguageModel = class {
373
381
  toolChoice,
374
382
  tools
375
383
  }) {
376
- var _a, _b, _c, _d;
384
+ var _a, _b, _c, _d, _e;
377
385
  const warnings = [];
378
386
  const compatibleOptions = Object.assign(
379
387
  (_a = await (0, import_provider_utils2.parseProviderOptions)({
@@ -387,6 +395,7 @@ var OpenAICompatibleChatLanguageModel = class {
387
395
  schema: openaiCompatibleProviderOptions
388
396
  })) != null ? _b : {}
389
397
  );
398
+ const strictJsonSchema = (_c = compatibleOptions == null ? void 0 : compatibleOptions.strictJsonSchema) != null ? _c : true;
390
399
  if (topK != null) {
391
400
  warnings.push({ type: "unsupported", feature: "topK" });
392
401
  }
@@ -421,7 +430,8 @@ var OpenAICompatibleChatLanguageModel = class {
421
430
  type: "json_schema",
422
431
  json_schema: {
423
432
  schema: responseFormat.schema,
424
- name: (_c = responseFormat.name) != null ? _c : "response",
433
+ strict: strictJsonSchema,
434
+ name: (_d = responseFormat.name) != null ? _d : "response",
425
435
  description: responseFormat.description
426
436
  }
427
437
  } : { type: "json_object" } : void 0,
@@ -429,7 +439,7 @@ var OpenAICompatibleChatLanguageModel = class {
429
439
  seed,
430
440
  ...Object.fromEntries(
431
441
  Object.entries(
432
- (_d = providerOptions == null ? void 0 : providerOptions[this.providerOptionsName]) != null ? _d : {}
442
+ (_e = providerOptions == null ? void 0 : providerOptions[this.providerOptionsName]) != null ? _e : {}
433
443
  ).filter(
434
444
  ([key]) => !Object.keys(openaiCompatibleProviderOptions.shape).includes(key)
435
445
  )
@@ -623,6 +633,13 @@ var OpenAICompatibleChatLanguageModel = class {
623
633
  });
624
634
  }
625
635
  if (delta.content) {
636
+ if (isActiveReasoning) {
637
+ controller.enqueue({
638
+ type: "reasoning-end",
639
+ id: "reasoning-0"
640
+ });
641
+ isActiveReasoning = false;
642
+ }
626
643
  if (!isActiveText) {
627
644
  controller.enqueue({ type: "text-start", id: "txt-0" });
628
645
  isActiveText = true;
@@ -634,6 +651,13 @@ var OpenAICompatibleChatLanguageModel = class {
634
651
  });
635
652
  }
636
653
  if (delta.tool_calls != null) {
654
+ if (isActiveReasoning) {
655
+ controller.enqueue({
656
+ type: "reasoning-end",
657
+ id: "reasoning-0"
658
+ });
659
+ isActiveReasoning = false;
660
+ }
637
661
  for (const toolCallDelta of delta.tool_calls) {
638
662
  const index = (_c = toolCallDelta.index) != null ? _c : toolCalls.length;
639
663
  if (toolCalls[index] == null) {
@@ -1529,7 +1553,7 @@ async function fileToBlob(file) {
1529
1553
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1530
1554
 
1531
1555
  // src/version.ts
1532
- var VERSION = true ? "2.0.7" : "0.0.0-test";
1556
+ var VERSION = true ? "2.0.9" : "0.0.0-test";
1533
1557
 
1534
1558
  // src/openai-compatible-provider.ts
1535
1559
  function createOpenAICompatible(options) {