@jerome-benoit/sap-ai-provider 4.0.0-rc.2 → 4.0.0

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.d.cts CHANGED
@@ -491,6 +491,8 @@ declare class SAPAILanguageModel implements LanguageModelV3 {
491
491
  * to SAP AI Core - the request continues executing on the server. This is a
492
492
  * limitation of the SAP AI SDK's chatCompletion API.
493
493
  *
494
+ * @see https://github.com/SAP/ai-sdk-js/issues/1429 for tracking true cancellation support
495
+ *
494
496
  * @param options - Generation options including prompt, tools, and settings
495
497
  * @returns Promise resolving to the generation result with content, usage, and metadata
496
498
  *
@@ -532,6 +534,13 @@ declare class SAPAILanguageModel implements LanguageModelV3 {
532
534
  * - Usage format: `{ inputTokens: { total, ... }, outputTokens: { total, ... } }`
533
535
  * - Warnings only in `stream-start` event
534
536
  *
537
+ * **Note on Abort Signal:**
538
+ * The abort signal implementation uses Promise.race to reject the promise when
539
+ * the signal is aborted. However, this does not cancel the underlying HTTP request
540
+ * to SAP AI Core - the request continues executing on the server. This is a
541
+ * limitation of the SAP AI SDK's chatCompletion API.
542
+ *
543
+ * @see https://github.com/SAP/ai-sdk-js/issues/1429 for tracking true cancellation support
535
544
  * @see {@link https://sdk.vercel.ai/docs/ai-sdk-core/streaming Vercel AI SDK Streaming}
536
545
  *
537
546
  * @param options - Streaming options including prompt, tools, and settings
package/dist/index.d.ts CHANGED
@@ -491,6 +491,8 @@ declare class SAPAILanguageModel implements LanguageModelV3 {
491
491
  * to SAP AI Core - the request continues executing on the server. This is a
492
492
  * limitation of the SAP AI SDK's chatCompletion API.
493
493
  *
494
+ * @see https://github.com/SAP/ai-sdk-js/issues/1429 for tracking true cancellation support
495
+ *
494
496
  * @param options - Generation options including prompt, tools, and settings
495
497
  * @returns Promise resolving to the generation result with content, usage, and metadata
496
498
  *
@@ -532,6 +534,13 @@ declare class SAPAILanguageModel implements LanguageModelV3 {
532
534
  * - Usage format: `{ inputTokens: { total, ... }, outputTokens: { total, ... } }`
533
535
  * - Warnings only in `stream-start` event
534
536
  *
537
+ * **Note on Abort Signal:**
538
+ * The abort signal implementation uses Promise.race to reject the promise when
539
+ * the signal is aborted. However, this does not cancel the underlying HTTP request
540
+ * to SAP AI Core - the request continues executing on the server. This is a
541
+ * limitation of the SAP AI SDK's chatCompletion API.
542
+ *
543
+ * @see https://github.com/SAP/ai-sdk-js/issues/1429 for tracking true cancellation support
535
544
  * @see {@link https://sdk.vercel.ai/docs/ai-sdk-core/streaming Vercel AI SDK Streaming}
536
545
  *
537
546
  * @param options - Streaming options including prompt, tools, and settings
package/dist/index.js CHANGED
@@ -29746,9 +29746,7 @@ import {
29746
29746
  import { zodToJsonSchema } from "zod-to-json-schema";
29747
29747
 
29748
29748
  // src/convert-to-sap-messages.ts
29749
- import {
29750
- UnsupportedFunctionalityError
29751
- } from "@ai-sdk/provider";
29749
+ import { UnsupportedFunctionalityError } from "@ai-sdk/provider";
29752
29750
  import { Buffer as Buffer2 } from "buffer";
29753
29751
  function convertToSAPMessages(prompt, options = {}) {
29754
29752
  const messages = [];
@@ -29901,9 +29899,7 @@ function convertToSAPMessages(prompt, options = {}) {
29901
29899
  }
29902
29900
  default: {
29903
29901
  const _exhaustiveCheck = message;
29904
- throw new Error(
29905
- `Unsupported role: ${_exhaustiveCheck.role}`
29906
- );
29902
+ throw new Error(`Unsupported role: ${_exhaustiveCheck.role}`);
29907
29903
  }
29908
29904
  }
29909
29905
  }
@@ -30185,6 +30181,8 @@ var SAPAILanguageModel = class {
30185
30181
  * to SAP AI Core - the request continues executing on the server. This is a
30186
30182
  * limitation of the SAP AI SDK's chatCompletion API.
30187
30183
  *
30184
+ * @see https://github.com/SAP/ai-sdk-js/issues/1429 for tracking true cancellation support
30185
+ *
30188
30186
  * @param options - Generation options including prompt, tools, and settings
30189
30187
  * @returns Promise resolving to the generation result with content, usage, and metadata
30190
30188
  *
@@ -30368,6 +30366,13 @@ var SAPAILanguageModel = class {
30368
30366
  * - Usage format: `{ inputTokens: { total, ... }, outputTokens: { total, ... } }`
30369
30367
  * - Warnings only in `stream-start` event
30370
30368
  *
30369
+ * **Note on Abort Signal:**
30370
+ * The abort signal implementation uses Promise.race to reject the promise when
30371
+ * the signal is aborted. However, this does not cancel the underlying HTTP request
30372
+ * to SAP AI Core - the request continues executing on the server. This is a
30373
+ * limitation of the SAP AI SDK's chatCompletion API.
30374
+ *
30375
+ * @see https://github.com/SAP/ai-sdk-js/issues/1429 for tracking true cancellation support
30371
30376
  * @see {@link https://sdk.vercel.ai/docs/ai-sdk-core/streaming Vercel AI SDK Streaming}
30372
30377
  *
30373
30378
  * @param options - Streaming options including prompt, tools, and settings
@@ -30414,11 +30419,9 @@ var SAPAILanguageModel = class {
30414
30419
  return filtering && Object.keys(filtering).length > 0 ? { filtering } : {};
30415
30420
  })()
30416
30421
  };
30417
- const streamResponse = await client.stream(
30418
- requestBody,
30419
- options.abortSignal,
30420
- { promptTemplating: { include_usage: true } }
30421
- );
30422
+ const streamResponse = await client.stream(requestBody, options.abortSignal, {
30423
+ promptTemplating: { include_usage: true }
30424
+ });
30422
30425
  const idGenerator = new StreamIdGenerator();
30423
30426
  let textBlockId = null;
30424
30427
  const streamState = {
@@ -30705,12 +30708,9 @@ var SAPAILanguageModel = class {
30705
30708
  let parameters;
30706
30709
  if (toolWithParams.parameters && isZodSchema(toolWithParams.parameters)) {
30707
30710
  try {
30708
- const jsonSchema = zodToJsonSchema(
30709
- toolWithParams.parameters,
30710
- {
30711
- $refStrategy: "none"
30712
- }
30713
- );
30711
+ const jsonSchema = zodToJsonSchema(toolWithParams.parameters, {
30712
+ $refStrategy: "none"
30713
+ });
30714
30714
  const schemaRecord = jsonSchema;
30715
30715
  delete schemaRecord.$schema;
30716
30716
  parameters = buildSAPToolParameters(schemaRecord);
@@ -30856,11 +30856,7 @@ var SAPAILanguageModel = class {
30856
30856
  * @internal
30857
30857
  */
30858
30858
  createClient(config) {
30859
- return new OrchestrationClient(
30860
- config,
30861
- this.config.deploymentConfig,
30862
- this.config.destination
30863
- );
30859
+ return new OrchestrationClient(config, this.config.deploymentConfig, this.config.destination);
30864
30860
  }
30865
30861
  };
30866
30862
  function buildSAPToolParameters(schema) {
@@ -30889,9 +30885,7 @@ function buildSAPToolParameters(schema) {
30889
30885
  function createAISDKRequestBodySummary(options) {
30890
30886
  return {
30891
30887
  hasImageParts: options.prompt.some(
30892
- (message) => message.role === "user" && message.content.some(
30893
- (part) => part.type === "file" && part.mediaType.startsWith("image/")
30894
- )
30888
+ (message) => message.role === "user" && message.content.some((part) => part.type === "file" && part.mediaType.startsWith("image/"))
30895
30889
  ),
30896
30890
  maxOutputTokens: options.maxOutputTokens,
30897
30891
  promptMessages: options.prompt.length,
@@ -31010,9 +31004,7 @@ function createSAPAIProvider(options = {}) {
31010
31004
  };
31011
31005
  const provider = function(modelId, settings) {
31012
31006
  if (new.target) {
31013
- throw new Error(
31014
- "The SAP AI provider function cannot be called with the new keyword."
31015
- );
31007
+ throw new Error("The SAP AI provider function cannot be called with the new keyword.");
31016
31008
  }
31017
31009
  return createModel(modelId, settings);
31018
31010
  };