@sap-ai-sdk/foundation-models 1.3.1-20241118013144.0 → 1.3.1-20241119013140.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.
Files changed (41) hide show
  1. package/dist/azure-openai/azure-openai-chat-client.d.ts +12 -0
  2. package/dist/azure-openai/azure-openai-chat-client.d.ts.map +1 -1
  3. package/dist/azure-openai/azure-openai-chat-client.js +36 -2
  4. package/dist/azure-openai/azure-openai-chat-client.js.map +1 -1
  5. package/dist/azure-openai/azure-openai-chat-completion-stream-chunk-response.d.ts +26 -0
  6. package/dist/azure-openai/azure-openai-chat-completion-stream-chunk-response.d.ts.map +1 -0
  7. package/dist/azure-openai/azure-openai-chat-completion-stream-chunk-response.js +37 -0
  8. package/dist/azure-openai/azure-openai-chat-completion-stream-chunk-response.js.map +1 -0
  9. package/dist/azure-openai/azure-openai-chat-completion-stream-response.d.ts +33 -0
  10. package/dist/azure-openai/azure-openai-chat-completion-stream-response.d.ts.map +1 -0
  11. package/dist/azure-openai/azure-openai-chat-completion-stream-response.js +48 -0
  12. package/dist/azure-openai/azure-openai-chat-completion-stream-response.js.map +1 -0
  13. package/dist/azure-openai/azure-openai-chat-completion-stream.d.ts +49 -0
  14. package/dist/azure-openai/azure-openai-chat-completion-stream.d.ts.map +1 -0
  15. package/dist/azure-openai/azure-openai-chat-completion-stream.js +118 -0
  16. package/dist/azure-openai/azure-openai-chat-completion-stream.js.map +1 -0
  17. package/dist/azure-openai/index.d.ts +3 -0
  18. package/dist/azure-openai/index.d.ts.map +1 -1
  19. package/dist/azure-openai/index.js +3 -0
  20. package/dist/azure-openai/index.js.map +1 -1
  21. package/dist/azure-openai/stream/index.d.ts +2 -0
  22. package/dist/azure-openai/stream/index.d.ts.map +1 -0
  23. package/dist/azure-openai/stream/index.js +2 -0
  24. package/dist/azure-openai/stream/index.js.map +1 -0
  25. package/dist/azure-openai/stream/line-decoder.d.ts +21 -0
  26. package/dist/azure-openai/stream/line-decoder.d.ts.map +1 -0
  27. package/dist/azure-openai/stream/line-decoder.js +81 -0
  28. package/dist/azure-openai/stream/line-decoder.js.map +1 -0
  29. package/dist/azure-openai/stream/sse-decoder.d.ts +35 -0
  30. package/dist/azure-openai/stream/sse-decoder.d.ts.map +1 -0
  31. package/dist/azure-openai/stream/sse-decoder.js +67 -0
  32. package/dist/azure-openai/stream/sse-decoder.js.map +1 -0
  33. package/dist/azure-openai/stream/sse-stream.d.ts +25 -0
  34. package/dist/azure-openai/stream/sse-stream.d.ts.map +1 -0
  35. package/dist/azure-openai/stream/sse-stream.js +172 -0
  36. package/dist/azure-openai/stream/sse-stream.js.map +1 -0
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/package.json +3 -3
@@ -2,6 +2,8 @@ import { type CustomRequestConfig } from '@sap-ai-sdk/core';
2
2
  import { type ModelDeployment } from '@sap-ai-sdk/ai-api/internal.js';
3
3
  import { type AzureOpenAiChatModel } from './model-types.js';
4
4
  import { AzureOpenAiChatCompletionResponse } from './azure-openai-chat-completion-response.js';
5
+ import { AzureOpenAiChatCompletionStreamResponse } from './azure-openai-chat-completion-stream-response.js';
6
+ import type { AzureOpenAiChatCompletionStreamChunkResponse } from './azure-openai-chat-completion-stream-chunk-response.js';
5
7
  import type { AzureOpenAiCreateChatCompletionRequest } from './client/inference/schema/index.js';
6
8
  /**
7
9
  * Azure OpenAI client for chat completion.
@@ -20,5 +22,15 @@ export declare class AzureOpenAiChatClient {
20
22
  * @returns The completion result.
21
23
  */
22
24
  run(data: AzureOpenAiCreateChatCompletionRequest, requestConfig?: CustomRequestConfig): Promise<AzureOpenAiChatCompletionResponse>;
25
+ /**
26
+ * Creates a completion stream for the chat messages.
27
+ * @param data - The input parameters for the chat completion.
28
+ * @param controller - The abort controller.
29
+ * @param requestConfig - The request configuration.
30
+ * @returns A response containing the chat completion stream.
31
+ */
32
+ stream(data: AzureOpenAiCreateChatCompletionRequest, controller?: AbortController, requestConfig?: CustomRequestConfig): Promise<AzureOpenAiChatCompletionStreamResponse<AzureOpenAiChatCompletionStreamChunkResponse>>;
33
+ private executeRequest;
34
+ private createStream;
23
35
  }
24
36
  //# sourceMappingURL=azure-openai-chat-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"azure-openai-chat-client.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAc,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;AAEjG;;GAEG;AACH,qBAAa,qBAAqB;IAKpB,OAAO,CAAC,eAAe;IAJnC;;;OAGG;gBACiB,eAAe,EAAE,eAAe,CAAC,oBAAoB,CAAC;IAE1E;;;;;OAKG;IACG,GAAG,CACP,IAAI,EAAE,sCAAsC,EAC5C,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,iCAAiC,CAAC;CAiB9C"}
1
+ {"version":3,"file":"azure-openai-chat-client.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAc,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,uCAAuC,EAAE,MAAM,mDAAmD,CAAC;AAE5G,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,yDAAyD,CAAC;AAE5H,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;AAEjG;;GAEG;AACH,qBAAa,qBAAqB;IAKpB,OAAO,CAAC,eAAe;IAJnC;;;OAGG;gBACiB,eAAe,EAAE,eAAe,CAAC,oBAAoB,CAAC;IAE1E;;;;;OAKG;IACG,GAAG,CACP,IAAI,EAAE,sCAAsC,EAC5C,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,iCAAiC,CAAC;IAK7C;;;;;;OAMG;IACG,MAAM,CACV,IAAI,EAAE,sCAAsC,EAC5C,UAAU,kBAAwB,EAClC,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CACR,uCAAuC,CAAC,4CAA4C,CAAC,CACtF;YAUa,cAAc;YAoBd,YAAY;CAqB3B"}
@@ -2,6 +2,8 @@ import { executeRequest } from '@sap-ai-sdk/core';
2
2
  import { getDeploymentId, getResourceGroup } from '@sap-ai-sdk/ai-api/internal.js';
3
3
  import { apiVersion } from './model-types.js';
4
4
  import { AzureOpenAiChatCompletionResponse } from './azure-openai-chat-completion-response.js';
5
+ import { AzureOpenAiChatCompletionStreamResponse } from './azure-openai-chat-completion-stream-response.js';
6
+ import { AzureOpenAiChatCompletionStream } from './azure-openai-chat-completion-stream.js';
5
7
  /**
6
8
  * Azure OpenAI client for chat completion.
7
9
  */
@@ -21,14 +23,46 @@ export class AzureOpenAiChatClient {
21
23
  * @returns The completion result.
22
24
  */
23
25
  async run(data, requestConfig) {
26
+ const response = await this.executeRequest(data, requestConfig);
27
+ return new AzureOpenAiChatCompletionResponse(response);
28
+ }
29
+ /**
30
+ * Creates a completion stream for the chat messages.
31
+ * @param data - The input parameters for the chat completion.
32
+ * @param controller - The abort controller.
33
+ * @param requestConfig - The request configuration.
34
+ * @returns A response containing the chat completion stream.
35
+ */
36
+ async stream(data, controller = new AbortController(), requestConfig) {
37
+ const response = new AzureOpenAiChatCompletionStreamResponse();
38
+ response.stream = (await this.createStream(data, controller, requestConfig))
39
+ ._pipe(AzureOpenAiChatCompletionStream._processChunk)
40
+ ._pipe(AzureOpenAiChatCompletionStream._processFinishReason, response)
41
+ ._pipe(AzureOpenAiChatCompletionStream._processTokenUsage, response);
42
+ return response;
43
+ }
44
+ async executeRequest(data, requestConfig) {
24
45
  const deploymentId = await getDeploymentId(this.modelDeployment, 'azure-openai');
25
46
  const resourceGroup = getResourceGroup(this.modelDeployment);
26
- const response = await executeRequest({
47
+ return executeRequest({
27
48
  url: `/inference/deployments/${deploymentId}/chat/completions`,
28
49
  apiVersion,
29
50
  resourceGroup
30
51
  }, data, requestConfig);
31
- return new AzureOpenAiChatCompletionResponse(response);
52
+ }
53
+ async createStream(data, controller, requestConfig) {
54
+ const response = await this.executeRequest({
55
+ ...data,
56
+ stream: true,
57
+ stream_options: {
58
+ include_usage: true
59
+ }
60
+ }, {
61
+ ...requestConfig,
62
+ responseType: 'stream',
63
+ signal: controller.signal
64
+ });
65
+ return AzureOpenAiChatCompletionStream._create(response, controller);
32
66
  }
33
67
  }
34
68
  //# sourceMappingURL=azure-openai-chat-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"azure-openai-chat-client.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAA6B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAG/F;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAKZ;IAJpB;;;OAGG;IACH,YAAoB,eAAsD;QAAtD,oBAAe,GAAf,eAAe,CAAuC;IAAG,CAAC;IAE9E;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,IAA4C,EAC5C,aAAmC;QAEnC,MAAM,YAAY,GAAG,MAAM,eAAe,CACxC,IAAI,CAAC,eAAe,EACpB,cAAc,CACf,CAAC;QACF,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC;YACE,GAAG,EAAE,0BAA0B,YAAY,mBAAmB;YAC9D,UAAU;YACV,aAAa;SACd,EACD,IAAI,EACJ,aAAa,CACd,CAAC;QACF,OAAO,IAAI,iCAAiC,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;CACF"}
1
+ {"version":3,"file":"azure-openai-chat-client.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAA6B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,uCAAuC,EAAE,MAAM,mDAAmD,CAAC;AAC5G,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAK3F;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAKZ;IAJpB;;;OAGG;IACH,YAAoB,eAAsD;QAAtD,oBAAe,GAAf,eAAe,CAAuC;IAAG,CAAC;IAE9E;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,IAA4C,EAC5C,aAAmC;QAEnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAChE,OAAO,IAAI,iCAAiC,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CACV,IAA4C,EAC5C,UAAU,GAAG,IAAI,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AI chat completion stream chunk response.
4
+ */
5
+ export declare class AzureOpenAiChatCompletionStreamChunkResponse {
6
+ readonly data: any;
7
+ constructor(data: any);
8
+ /**
9
+ * Usage of tokens in the chunk response.
10
+ * @returns Token usage.
11
+ */
12
+ getTokenUsage(): AzureOpenAiCompletionUsage | null;
13
+ /**
14
+ * Reason for stopping the completion stream chunk.
15
+ * @param choiceIndex - The index of the choice to parse.
16
+ * @returns The finish reason.
17
+ */
18
+ getFinishReason(choiceIndex?: number): string | undefined;
19
+ /**
20
+ * Parses the chunk response and returns the delta content.
21
+ * @param choiceIndex - The index of the choice to parse.
22
+ * @returns The message delta content.
23
+ */
24
+ getDeltaContent(choiceIndex?: number): string | undefined | null;
25
+ }
26
+ //# sourceMappingURL=azure-openai-chat-completion-stream-chunk-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-openai-chat-completion-stream-chunk-response.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-stream-chunk-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAErF;;GAEG;AACH,qBAAa,4CAA4C;aAC3B,IAAI,EAAE,GAAG;gBAAT,IAAI,EAAE,GAAG;IAKrC;;;OAGG;IACH,aAAa,IAAI,0BAA0B,GAAG,IAAI;IAIlD;;;;OAIG;IACH,eAAe,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS;IAKpD;;;;OAIG;IACH,eAAe,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI;CAI5D"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Azure OpenAI chat completion stream chunk response.
3
+ */
4
+ export class AzureOpenAiChatCompletionStreamChunkResponse {
5
+ data;
6
+ constructor(data) {
7
+ this.data = data;
8
+ // TODO: Change `any` to `CreateChatCompletionStreamResponse` once the preview spec becomes stable.
9
+ this.data = data;
10
+ }
11
+ /**
12
+ * Usage of tokens in the chunk response.
13
+ * @returns Token usage.
14
+ */
15
+ getTokenUsage() {
16
+ return this.data.usage;
17
+ }
18
+ /**
19
+ * Reason for stopping the completion stream chunk.
20
+ * @param choiceIndex - The index of the choice to parse.
21
+ * @returns The finish reason.
22
+ */
23
+ getFinishReason(choiceIndex = 0) {
24
+ return this.data.choices.find((c) => c.index === choiceIndex)
25
+ ?.finish_reason;
26
+ }
27
+ /**
28
+ * Parses the chunk response and returns the delta content.
29
+ * @param choiceIndex - The index of the choice to parse.
30
+ * @returns The message delta content.
31
+ */
32
+ getDeltaContent(choiceIndex = 0) {
33
+ return this.data.choices.find((c) => c.index === choiceIndex)?.delta
34
+ .content;
35
+ }
36
+ }
37
+ //# sourceMappingURL=azure-openai-chat-completion-stream-chunk-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-openai-chat-completion-stream-chunk-response.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-stream-chunk-response.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,4CAA4C;IAC3B;IAA5B,YAA4B,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;QACnC,mGAAmG;QACnG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,WAAW,GAAG,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC;YAChE,EAAE,aAAa,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,WAAW,GAAG,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,EAAE,KAAK;aACtE,OAAO,CAAC;IACb,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ import type { AzureOpenAiCompletionUsage } from './client/inference/schema/index.js';
2
+ import type { AzureOpenAiChatCompletionStream } from './azure-openai-chat-completion-stream.js';
3
+ /**
4
+ * Azure OpenAI chat completion stream response.
5
+ */
6
+ export declare class AzureOpenAiChatCompletionStreamResponse<T> {
7
+ private _usage;
8
+ /**
9
+ * Finish reasons for all choices.
10
+ */
11
+ private _finishReasons;
12
+ private _stream;
13
+ getTokenUsage(): AzureOpenAiCompletionUsage | undefined;
14
+ /**
15
+ * @internal
16
+ */
17
+ _setTokenUsage(usage: AzureOpenAiCompletionUsage): void;
18
+ getFinishReason(choiceIndex?: number): string | undefined | null;
19
+ /**
20
+ * @internal
21
+ */
22
+ _getFinishReasons(): Map<number, string>;
23
+ /**
24
+ * @internal
25
+ */
26
+ _setFinishReasons(finishReasons: Map<number, string>): void;
27
+ get stream(): AzureOpenAiChatCompletionStream<T>;
28
+ /**
29
+ * @internal
30
+ */
31
+ set stream(stream: AzureOpenAiChatCompletionStream<T>);
32
+ }
33
+ //# sourceMappingURL=azure-openai-chat-completion-stream-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-openai-chat-completion-stream-response.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-stream-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAEhG;;GAEG;AACH,qBAAa,uCAAuC,CAAC,CAAC;IACpD,OAAO,CAAC,MAAM,CAAyC;IACvD;;OAEG;IACH,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,OAAO,CAAiD;IAEzD,aAAa,IAAI,0BAA0B,GAAG,SAAS;IAI9D;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,0BAA0B,GAAG,IAAI;IAIhD,eAAe,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI;IAIlE;;OAEG;IACH,iBAAiB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIxC;;OAEG;IACH,iBAAiB,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAI3D,IAAI,MAAM,IAAI,+BAA+B,CAAC,CAAC,CAAC,CAK/C;IAED;;OAEG;IACH,IAAI,MAAM,CAAC,MAAM,EAAE,+BAA+B,CAAC,CAAC,CAAC,EAEpD;CACF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Azure OpenAI chat completion stream response.
3
+ */
4
+ export class AzureOpenAiChatCompletionStreamResponse {
5
+ _usage;
6
+ /**
7
+ * Finish reasons for all choices.
8
+ */
9
+ _finishReasons = new Map();
10
+ _stream;
11
+ getTokenUsage() {
12
+ return this._usage;
13
+ }
14
+ /**
15
+ * @internal
16
+ */
17
+ _setTokenUsage(usage) {
18
+ this._usage = usage;
19
+ }
20
+ getFinishReason(choiceIndex = 0) {
21
+ return this._finishReasons.get(choiceIndex);
22
+ }
23
+ /**
24
+ * @internal
25
+ */
26
+ _getFinishReasons() {
27
+ return this._finishReasons;
28
+ }
29
+ /**
30
+ * @internal
31
+ */
32
+ _setFinishReasons(finishReasons) {
33
+ this._finishReasons = finishReasons;
34
+ }
35
+ get stream() {
36
+ if (!this._stream) {
37
+ throw new Error('Response stream is undefined.');
38
+ }
39
+ return this._stream;
40
+ }
41
+ /**
42
+ * @internal
43
+ */
44
+ set stream(stream) {
45
+ this._stream = stream;
46
+ }
47
+ }
48
+ //# sourceMappingURL=azure-openai-chat-completion-stream-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-openai-chat-completion-stream-response.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-stream-response.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,uCAAuC;IAC1C,MAAM,CAAyC;IACvD;;OAEG;IACK,cAAc,GAAwB,IAAI,GAAG,EAAE,CAAC;IAChD,OAAO,CAAiD;IAEzD,aAAa;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,KAAiC;QAC9C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,eAAe,CAAC,WAAW,GAAG,CAAC;QACpC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,aAAkC;QAClD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED,IAAI,MAAM;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM,CAAC,MAA0C;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,49 @@
1
+ import { SseStream } from './stream/index.js';
2
+ import { AzureOpenAiChatCompletionStreamChunkResponse } from './azure-openai-chat-completion-stream-chunk-response.js';
3
+ import type { HttpResponse } from '@sap-cloud-sdk/http-client';
4
+ import type { AzureOpenAiChatCompletionStreamResponse } from './azure-openai-chat-completion-stream-response.js';
5
+ /**
6
+ * Chat completion stream containing post-processing functions.
7
+ */
8
+ export declare class AzureOpenAiChatCompletionStream<Item> extends SseStream<Item> {
9
+ iterator: () => AsyncIterator<Item>;
10
+ /**
11
+ * Create a chat completion stream based on the http response.
12
+ * @param response - Http response.
13
+ * @returns Chat completion stream.
14
+ * @internal
15
+ */
16
+ static _create(response: HttpResponse, controller: AbortController): AzureOpenAiChatCompletionStream<any>;
17
+ /**
18
+ * Wrap raw chunk data with chunk response class to provide helper functions.
19
+ * @param stream - Chat completion stream.
20
+ * @internal
21
+ */
22
+ static _processChunk(stream: AzureOpenAiChatCompletionStream<any>): AsyncGenerator<AzureOpenAiChatCompletionStreamChunkResponse>;
23
+ /**
24
+ * @internal
25
+ */
26
+ static _processFinishReason(stream: AzureOpenAiChatCompletionStream<AzureOpenAiChatCompletionStreamChunkResponse>, response?: AzureOpenAiChatCompletionStreamResponse<any>): AsyncGenerator<AzureOpenAiChatCompletionStreamChunkResponse>;
27
+ /**
28
+ * @internal
29
+ */
30
+ static _processTokenUsage(stream: AzureOpenAiChatCompletionStream<AzureOpenAiChatCompletionStreamChunkResponse>, response?: AzureOpenAiChatCompletionStreamResponse<any>): AsyncGenerator<AzureOpenAiChatCompletionStreamChunkResponse>;
31
+ /**
32
+ * Transform a stream of chunks into a stream of content strings.
33
+ * @param stream - Chat completion stream.
34
+ * @param choiceIndex - The index of the choice to parse.
35
+ * @internal
36
+ */
37
+ static _processContentStream(stream: AzureOpenAiChatCompletionStream<AzureOpenAiChatCompletionStreamChunkResponse>, choiceIndex?: number): AsyncGenerator<string>;
38
+ constructor(iterator: () => AsyncIterator<Item>, controller: AbortController);
39
+ /**
40
+ * Pipe the stream through a processing function.
41
+ * @param processFn - The function to process the input stream.
42
+ * @param response - The `AzureOpenAiChatCompletionStreamResponse` object for process function to store finish reason, token usage, etc.
43
+ * @returns The output stream containing processed items.
44
+ * @internal
45
+ */
46
+ _pipe<TReturn>(processFn: (stream: AzureOpenAiChatCompletionStream<Item>, response?: AzureOpenAiChatCompletionStreamResponse<any>) => AsyncIterator<TReturn>, response?: AzureOpenAiChatCompletionStreamResponse<any>): AzureOpenAiChatCompletionStream<TReturn>;
47
+ toContentStream(this: AzureOpenAiChatCompletionStream<AzureOpenAiChatCompletionStreamChunkResponse>, choiceIndex?: number): AzureOpenAiChatCompletionStream<string>;
48
+ }
49
+ //# sourceMappingURL=azure-openai-chat-completion-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-openai-chat-completion-stream.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,4CAA4C,EAAE,MAAM,yDAAyD,CAAC;AACvH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,mDAAmD,CAAC;AAOjH;;GAEG;AACH,qBAAa,+BAA+B,CAAC,IAAI,CAAE,SAAQ,SAAS,CAAC,IAAI,CAAC;IA8G/D,QAAQ,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC;IA7G5C;;;;;OAKG;WACW,OAAO,CACnB,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,eAAe,GAC1B,+BAA+B,CAAC,GAAG,CAAC;IAMvC;;;;OAIG;WACW,aAAa,CACzB,MAAM,EAAE,+BAA+B,CAAC,GAAG,CAAC,GAC3C,cAAc,CAAC,4CAA4C,CAAC;IAM/D;;OAEG;WACW,oBAAoB,CAChC,MAAM,EAAE,+BAA+B,CAAC,4CAA4C,CAAC,EACrF,QAAQ,CAAC,EAAE,uCAAuC,CAAC,GAAG,CAAC,GACtD,cAAc,CAAC,4CAA4C,CAAC;IAoC/D;;OAEG;WACW,kBAAkB,CAC9B,MAAM,EAAE,+BAA+B,CAAC,4CAA4C,CAAC,EACrF,QAAQ,CAAC,EAAE,uCAAuC,CAAC,GAAG,CAAC,GACtD,cAAc,CAAC,4CAA4C,CAAC;IAa/D;;;;;OAKG;WACW,qBAAqB,CACjC,MAAM,EAAE,+BAA+B,CAAC,4CAA4C,CAAC,EACrF,WAAW,SAAI,GACd,cAAc,CAAC,MAAM,CAAC;gBAWhB,QAAQ,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC,EAC1C,UAAU,EAAE,eAAe;IAK7B;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EACX,SAAS,EAAE,CACT,MAAM,EAAE,+BAA+B,CAAC,IAAI,CAAC,EAC7C,QAAQ,CAAC,EAAE,uCAAuC,CAAC,GAAG,CAAC,KACpD,aAAa,CAAC,OAAO,CAAC,EAC3B,QAAQ,CAAC,EAAE,uCAAuC,CAAC,GAAG,CAAC,GACtD,+BAA+B,CAAC,OAAO,CAAC;IAapC,eAAe,CACpB,IAAI,EAAE,+BAA+B,CAAC,4CAA4C,CAAC,EACnF,WAAW,CAAC,EAAE,MAAM,GACnB,+BAA+B,CAAC,MAAM,CAAC;CAU3C"}
@@ -0,0 +1,118 @@
1
+ import { createLogger } from '@sap-cloud-sdk/util';
2
+ import { SseStream } from './stream/index.js';
3
+ import { AzureOpenAiChatCompletionStreamChunkResponse } from './azure-openai-chat-completion-stream-chunk-response.js';
4
+ const logger = createLogger({
5
+ package: 'foundation-models',
6
+ messageContext: 'azure-openai-chat-completion-stream'
7
+ });
8
+ /**
9
+ * Chat completion stream containing post-processing functions.
10
+ */
11
+ export class AzureOpenAiChatCompletionStream extends SseStream {
12
+ iterator;
13
+ /**
14
+ * Create a chat completion stream based on the http response.
15
+ * @param response - Http response.
16
+ * @returns Chat completion stream.
17
+ * @internal
18
+ */
19
+ static _create(response, controller) {
20
+ // TODO: Change `any` to `CreateChatCompletionStreamResponse` once the preview spec becomes stable.
21
+ const stream = SseStream.transformToSseStream(response, controller); // TODO: Change `any` to `CreateChatCompletionStreamResponse` once the preview spec becomes stable.
22
+ return new AzureOpenAiChatCompletionStream(stream.iterator, controller);
23
+ }
24
+ /**
25
+ * Wrap raw chunk data with chunk response class to provide helper functions.
26
+ * @param stream - Chat completion stream.
27
+ * @internal
28
+ */
29
+ static async *_processChunk(stream // TODO: Change `any` to `CreateChatCompletionStreamResponse` once the preview spec becomes stable.
30
+ ) {
31
+ for await (const chunk of stream) {
32
+ yield new AzureOpenAiChatCompletionStreamChunkResponse(chunk);
33
+ }
34
+ }
35
+ /**
36
+ * @internal
37
+ */
38
+ static async *_processFinishReason(stream, response) {
39
+ for await (const chunk of stream) {
40
+ chunk.data.choices.forEach((choice) => {
41
+ const choiceIndex = choice.index;
42
+ if (choiceIndex >= 0) {
43
+ const finishReason = chunk.getFinishReason(choiceIndex);
44
+ if (finishReason) {
45
+ if (response) {
46
+ response._getFinishReasons().set(choiceIndex, finishReason);
47
+ }
48
+ switch (finishReason) {
49
+ case 'content_filter':
50
+ logger.error(`Choice ${choiceIndex}: Stream finished with content filter hit.`);
51
+ break;
52
+ case 'length':
53
+ logger.error(`Choice ${choiceIndex}: Stream finished with token length exceeded.`);
54
+ break;
55
+ case 'stop':
56
+ logger.debug(`Choice ${choiceIndex}: Stream finished.`);
57
+ break;
58
+ default:
59
+ logger.error(`Choice ${choiceIndex}: Stream finished with unknown reason '${finishReason}'.`);
60
+ }
61
+ }
62
+ }
63
+ });
64
+ yield chunk;
65
+ }
66
+ }
67
+ /**
68
+ * @internal
69
+ */
70
+ static async *_processTokenUsage(stream, response) {
71
+ for await (const chunk of stream) {
72
+ const usage = chunk.getTokenUsage();
73
+ if (usage) {
74
+ if (response) {
75
+ response._setTokenUsage(usage);
76
+ }
77
+ logger.debug(`Token usage: ${JSON.stringify(usage)}`);
78
+ }
79
+ yield chunk;
80
+ }
81
+ }
82
+ /**
83
+ * Transform a stream of chunks into a stream of content strings.
84
+ * @param stream - Chat completion stream.
85
+ * @param choiceIndex - The index of the choice to parse.
86
+ * @internal
87
+ */
88
+ static async *_processContentStream(stream, choiceIndex = 0) {
89
+ for await (const chunk of stream) {
90
+ const deltaContent = chunk.getDeltaContent(choiceIndex);
91
+ if (!deltaContent) {
92
+ continue;
93
+ }
94
+ yield deltaContent;
95
+ }
96
+ }
97
+ constructor(iterator, controller) {
98
+ super(iterator, controller);
99
+ this.iterator = iterator;
100
+ }
101
+ /**
102
+ * Pipe the stream through a processing function.
103
+ * @param processFn - The function to process the input stream.
104
+ * @param response - The `AzureOpenAiChatCompletionStreamResponse` object for process function to store finish reason, token usage, etc.
105
+ * @returns The output stream containing processed items.
106
+ * @internal
107
+ */
108
+ _pipe(processFn, response) {
109
+ if (response) {
110
+ return new AzureOpenAiChatCompletionStream(() => processFn(this, response), this.controller);
111
+ }
112
+ return new AzureOpenAiChatCompletionStream(() => processFn(this), this.controller);
113
+ }
114
+ toContentStream(choiceIndex) {
115
+ return new AzureOpenAiChatCompletionStream(() => AzureOpenAiChatCompletionStream._processContentStream(this, choiceIndex), this.controller);
116
+ }
117
+ }
118
+ //# sourceMappingURL=azure-openai-chat-completion-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-openai-chat-completion-stream.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,4CAA4C,EAAE,MAAM,yDAAyD,CAAC;AAIvH,MAAM,MAAM,GAAG,YAAY,CAAC;IAC1B,OAAO,EAAE,mBAAmB;IAC5B,cAAc,EAAE,qCAAqC;CACtD,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,OAAO,+BAAsC,SAAQ,SAAe;IA8G/D;IA7GT;;;;;OAKG;IACI,MAAM,CAAC,OAAO,CACnB,QAAsB,EACtB,UAA2B;QAE3B,mGAAmG;QACnG,MAAM,MAAM,GAAG,SAAS,CAAC,oBAAoB,CAAM,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,mGAAmG;QAC7K,OAAO,IAAI,+BAA+B,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC1E,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,CACzB,MAA4C,CAAC,mGAAmG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AEpB,WAAoB;QAEpB,OAAO,IAAI,+BAA+B,CACxC,GAAG,EAAE,CACH,+BAA+B,CAAC,qBAAqB,CACnD,IAAI,EACJ,WAAW,CACZ,EACH,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC;CACF"}
@@ -3,5 +3,8 @@ export * from './azure-openai-chat-client.js';
3
3
  export * from './azure-openai-embedding-client.js';
4
4
  export * from './azure-openai-chat-completion-response.js';
5
5
  export * from './azure-openai-embedding-response.js';
6
+ export * from './azure-openai-chat-completion-stream-chunk-response.js';
7
+ export * from './azure-openai-chat-completion-stream-response.js';
8
+ export * from './azure-openai-chat-completion-stream.js';
6
9
  export * from './model-types.js';
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/azure-openai/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/azure-openai/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,yDAAyD,CAAC;AACxE,cAAc,mDAAmD,CAAC;AAClE,cAAc,0CAA0C,CAAC;AACzD,cAAc,kBAAkB,CAAC"}
@@ -3,5 +3,8 @@ export * from './azure-openai-chat-client.js';
3
3
  export * from './azure-openai-embedding-client.js';
4
4
  export * from './azure-openai-chat-completion-response.js';
5
5
  export * from './azure-openai-embedding-response.js';
6
+ export * from './azure-openai-chat-completion-stream-chunk-response.js';
7
+ export * from './azure-openai-chat-completion-stream-response.js';
8
+ export * from './azure-openai-chat-completion-stream.js';
6
9
  export * from './model-types.js';
7
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/azure-openai/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/azure-openai/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,yDAAyD,CAAC;AACxE,cAAc,mDAAmD,CAAC;AAClE,cAAc,0CAA0C,CAAC;AACzD,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { SseStream } from './sse-stream.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/azure-openai/stream/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { SseStream } from './sse-stream.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/azure-openai/stream/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,21 @@
1
+ type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;
2
+ /**
3
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
4
+ * reading lines from text.
5
+ *
6
+ * Https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258.
7
+ * @internal
8
+ */
9
+ export declare class LineDecoder {
10
+ static NEWLINE_CHARS: Set<string>;
11
+ static NEWLINE_REGEXP: RegExp;
12
+ buffer: string[];
13
+ trailingCR: boolean;
14
+ textDecoder: any;
15
+ constructor();
16
+ decode(chunk: Bytes): string[];
17
+ decodeText(bytes: Bytes): string;
18
+ flush(): string[];
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=line-decoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-decoder.d.ts","sourceRoot":"","sources":["../../../src/azure-openai/stream/line-decoder.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3E;;;;;;GAMG;AACH,qBAAa,WAAW;IAEtB,MAAM,CAAC,aAAa,cAAyB;IAC7C,MAAM,CAAC,cAAc,SAAkB;IAEvC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC;;IAOjB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE;IA4C9B,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IA2BhC,KAAK,IAAI,MAAM,EAAE;CAUlB"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
3
+ * reading lines from text.
4
+ *
5
+ * Https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258.
6
+ * @internal
7
+ */
8
+ export class LineDecoder {
9
+ // prettier-ignore
10
+ static NEWLINE_CHARS = new Set(['\n', '\r']);
11
+ static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
12
+ buffer;
13
+ trailingCR;
14
+ textDecoder; // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
15
+ constructor() {
16
+ this.buffer = [];
17
+ this.trailingCR = false;
18
+ }
19
+ decode(chunk) {
20
+ let text = this.decodeText(chunk);
21
+ if (this.trailingCR) {
22
+ text = '\r' + text;
23
+ this.trailingCR = false;
24
+ }
25
+ if (text.endsWith('\r')) {
26
+ this.trailingCR = true;
27
+ text = text.slice(0, -1);
28
+ }
29
+ if (!text) {
30
+ return [];
31
+ }
32
+ const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
33
+ let lines = text.split(LineDecoder.NEWLINE_REGEXP);
34
+ // if there is a trailing new line then the last entry will be an empty
35
+ // string which we don't care about
36
+ if (trailingNewline) {
37
+ lines.pop();
38
+ }
39
+ if (lines.length === 1 && !trailingNewline) {
40
+ this.buffer.push(lines[0]);
41
+ return [];
42
+ }
43
+ if (this.buffer.length) {
44
+ lines = [this.buffer.join('') + lines[0], ...lines.slice(1)];
45
+ this.buffer = [];
46
+ }
47
+ if (!trailingNewline) {
48
+ this.buffer = [lines.pop() || ''];
49
+ }
50
+ return lines;
51
+ }
52
+ decodeText(bytes) {
53
+ if (bytes == null) {
54
+ return '';
55
+ }
56
+ if (typeof bytes === 'string') {
57
+ return bytes;
58
+ }
59
+ // Node:
60
+ if (typeof Buffer !== 'undefined') {
61
+ if (bytes instanceof Buffer) {
62
+ return bytes.toString();
63
+ }
64
+ if (bytes instanceof Uint8Array) {
65
+ return Buffer.from(bytes).toString();
66
+ }
67
+ throw new Error(`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`);
68
+ }
69
+ throw new Error('Unexpected: Buffer is not available as globals. Please report this error.');
70
+ }
71
+ flush() {
72
+ if (!this.buffer.length && !this.trailingCR) {
73
+ return [];
74
+ }
75
+ const lines = [this.buffer.join('')];
76
+ this.buffer = [];
77
+ this.trailingCR = false;
78
+ return lines;
79
+ }
80
+ }
81
+ //# sourceMappingURL=line-decoder.js.map
@@ -0,0 +1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,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YAC5C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @internal
3
+ * Server-Sent Event, see {@link https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events}.
4
+ */
5
+ export interface ServerSentEvent {
6
+ /**
7
+ * Name of the event if field name is `event`.
8
+ */
9
+ event: string | null;
10
+ /**
11
+ * Value of the data if field name is `data`.
12
+ */
13
+ data: string;
14
+ /**
15
+ * Raw string chunks. Each line is either in format `data: ...` or `event: ...`.
16
+ */
17
+ raw: string[];
18
+ }
19
+ /**
20
+ * Server-Sent Event decoder.
21
+ * @internal
22
+ */
23
+ export declare class SSEDecoder {
24
+ private data;
25
+ private event;
26
+ private chunks;
27
+ constructor();
28
+ /**
29
+ * Decode the line into structured server sent event.
30
+ * @param line - Line to decode.
31
+ * @returns Server sent event if the line is empty meaning the end of the received event, or null if there are more lines to come.
32
+ */
33
+ decode(line: string): ServerSentEvent | null;
34
+ }
35
+ //# sourceMappingURL=sse-decoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-decoder.d.ts","sourceRoot":"","sources":["../../../src/azure-openai/stream/sse-decoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,IAAI,CAAW;IACvB,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,MAAM,CAAW;;IAQzB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;CA2C7C"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Server-Sent Event decoder.
3
+ * @internal
4
+ */
5
+ export class SSEDecoder {
6
+ data;
7
+ event;
8
+ chunks;
9
+ constructor() {
10
+ this.event = null;
11
+ this.data = [];
12
+ this.chunks = [];
13
+ }
14
+ /**
15
+ * Decode the line into structured server sent event.
16
+ * @param line - Line to decode.
17
+ * @returns Server sent event if the line is empty meaning the end of the received event, or null if there are more lines to come.
18
+ */
19
+ decode(line) {
20
+ if (line.endsWith('\r')) {
21
+ line = line.substring(0, line.length - 1);
22
+ }
23
+ if (!line) {
24
+ // empty line and we didn't previously encounter any messages
25
+ if (!this.event && !this.data.length) {
26
+ return null;
27
+ }
28
+ const sse = {
29
+ event: this.event,
30
+ data: this.data.join('\n'),
31
+ raw: this.chunks
32
+ };
33
+ this.event = null;
34
+ this.data = [];
35
+ this.chunks = [];
36
+ return sse;
37
+ }
38
+ this.chunks.push(line);
39
+ if (line.startsWith(':')) {
40
+ return null;
41
+ }
42
+ const [fieldname, _, value] = partition(line, ':');
43
+ const trimedValue = value.startsWith(' ') ? value.substring(1) : value;
44
+ if (fieldname === 'event') {
45
+ this.event = trimedValue;
46
+ }
47
+ else if (fieldname === 'data') {
48
+ this.data.push(trimedValue);
49
+ }
50
+ else {
51
+ throw new Error(`Invalid SSE payload: ${line}`);
52
+ }
53
+ return null;
54
+ }
55
+ }
56
+ function partition(str, delimiter) {
57
+ const index = str.indexOf(delimiter);
58
+ if (index !== -1) {
59
+ return [
60
+ str.substring(0, index),
61
+ delimiter,
62
+ str.substring(index + delimiter.length)
63
+ ];
64
+ }
65
+ return [str, '', ''];
66
+ }
67
+ //# sourceMappingURL=sse-decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-decoder.js","sourceRoot":"","sources":["../../../src/azure-openai/stream/sse-decoder.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,MAAM,OAAO,UAAU;IACb,IAAI,CAAW;IACf,KAAK,CAAgB;IACrB,MAAM,CAAW;IAEzB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAY;QACjB,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,6DAA6D;YAC7D,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,GAAG,GAAoB;gBAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC1B,GAAG,EAAE,IAAI,CAAC,MAAM;aACjB,CAAC;YAEF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YAEjB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACnD,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAEvE,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;QAC3B,CAAC;aAAM,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,SAAiB;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO;YACL,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC;YACvB,SAAS;YACT,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC;SACxC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { ServerSentEvent } from './sse-decoder.js';
2
+ import type { HttpResponse } from '@sap-cloud-sdk/http-client';
3
+ /**
4
+ * Stream implemented as an async iterable.
5
+ * @internal
6
+ */
7
+ export declare class SseStream<Item> implements AsyncIterable<Item> {
8
+ iterator: () => AsyncIterator<Item>;
9
+ protected static transformToSseStream<Item>(response: HttpResponse, controller: AbortController): SseStream<Item>;
10
+ controller: AbortController;
11
+ constructor(iterator: () => AsyncIterator<Item>, controller: AbortController);
12
+ [Symbol.asyncIterator](): AsyncIterator<Item>;
13
+ }
14
+ /**
15
+ * @internal
16
+ */
17
+ export declare function _iterSseMessages(response: HttpResponse, controller: AbortController): AsyncGenerator<ServerSentEvent, void, unknown>;
18
+ /**
19
+ * This is an internal helper function that's just used for testing.
20
+ * @param chunks - The chunks to decode.
21
+ * @returns The decoded lines.
22
+ * @internal
23
+ */
24
+ export declare function _decodeChunks(chunks: string[]): string[];
25
+ //# sourceMappingURL=sse-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-stream.d.ts","sourceRoot":"","sources":["../../../src/azure-openai/stream/sse-stream.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAS/D;;;GAGG;AACH,qBAAa,SAAS,CAAC,IAAI,CAAE,YAAW,aAAa,CAAC,IAAI,CAAC;IA6DhD,QAAQ,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC;IA5D5C,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,EACxC,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,eAAe,GAC1B,SAAS,CAAC,IAAI,CAAC;IAsDlB,UAAU,EAAE,eAAe,CAAC;gBAGnB,QAAQ,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC,EAC1C,UAAU,EAAE,eAAe;IAK7B,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC;CAG9C;AAED;;GAEG;AACH,wBAAuB,gBAAgB,CACrC,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,eAAe,GAC1B,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAyBhD;AA0ED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAQxD"}
@@ -0,0 +1,172 @@
1
+ import { createLogger } from '@sap-cloud-sdk/util';
2
+ import { LineDecoder } from './line-decoder.js';
3
+ import { SSEDecoder } from './sse-decoder.js';
4
+ const logger = createLogger({
5
+ package: 'foundation-models',
6
+ messageContext: 'azure-openai-sse-stream'
7
+ });
8
+ /**
9
+ * Stream implemented as an async iterable.
10
+ * @internal
11
+ */
12
+ export class SseStream {
13
+ iterator;
14
+ static transformToSseStream(response, controller) {
15
+ let consumed = false;
16
+ async function* iterator() {
17
+ if (consumed) {
18
+ throw new Error('Cannot iterate over a consumed stream.');
19
+ }
20
+ consumed = true;
21
+ let done = false;
22
+ try {
23
+ for await (const sse of _iterSseMessages(response, controller)) {
24
+ if (done) {
25
+ continue;
26
+ }
27
+ if (sse.data.startsWith('[DONE]')) {
28
+ done = true;
29
+ continue;
30
+ }
31
+ try {
32
+ const data = JSON.parse(sse.data);
33
+ if (data?.error) {
34
+ throw new Error(data.error);
35
+ }
36
+ // Yield also the event if it exists, otherwise just the data
37
+ yield sse.event === null
38
+ ? data
39
+ : { event: sse.event, data };
40
+ }
41
+ catch (e) {
42
+ logger.error(`Could not parse message into JSON: ${sse.data}`);
43
+ logger.error(`From chunk: ${sse.raw}`);
44
+ throw e;
45
+ }
46
+ }
47
+ done = true;
48
+ }
49
+ catch (e) {
50
+ // Ignore the error if controller was aborted
51
+ if (e instanceof Error && e.name === 'CanceledError') {
52
+ return;
53
+ }
54
+ logger.error('Error while iterating over SSE stream:', e);
55
+ }
56
+ finally {
57
+ // Make sure that the controller is aborted if the stream was not fully consumed
58
+ if (!done) {
59
+ controller.abort();
60
+ }
61
+ }
62
+ }
63
+ return new SseStream(iterator, controller);
64
+ }
65
+ controller;
66
+ constructor(iterator, controller) {
67
+ this.iterator = iterator;
68
+ this.controller = controller;
69
+ }
70
+ [Symbol.asyncIterator]() {
71
+ return this.iterator();
72
+ }
73
+ }
74
+ /**
75
+ * @internal
76
+ */
77
+ export async function* _iterSseMessages(response, controller) {
78
+ if (!response.data) {
79
+ controller.abort();
80
+ throw new Error('Attempted to iterate over a response with no body');
81
+ }
82
+ const sseDecoder = new SSEDecoder();
83
+ const lineDecoder = new LineDecoder();
84
+ const iter = response.data;
85
+ for await (const sseChunk of iterSseChunks(iter)) {
86
+ for (const line of lineDecoder.decode(sseChunk)) {
87
+ const sse = sseDecoder.decode(line);
88
+ if (sse) {
89
+ yield sse;
90
+ }
91
+ }
92
+ }
93
+ for (const line of lineDecoder.flush()) {
94
+ const sse = sseDecoder.decode(line);
95
+ if (sse) {
96
+ yield sse;
97
+ }
98
+ }
99
+ }
100
+ /**
101
+ * Given an async iterable iterator, iterates over it and yields full
102
+ * SSE chunks, i.e. yields when a double new-line is encountered.
103
+ * @param iterator - Async iterable iterator.
104
+ * @returns Async generator of Uint8Array.
105
+ * @internal
106
+ */
107
+ async function* iterSseChunks(iterator) {
108
+ let data = new Uint8Array();
109
+ for await (const chunk of iterator) {
110
+ if (chunk == null) {
111
+ continue;
112
+ }
113
+ const binaryChunk = chunk instanceof ArrayBuffer
114
+ ? new Uint8Array(chunk)
115
+ : typeof chunk === 'string'
116
+ ? new TextEncoder().encode(chunk)
117
+ : chunk;
118
+ const newData = new Uint8Array(data.length + binaryChunk.length);
119
+ newData.set(data);
120
+ newData.set(binaryChunk, data.length);
121
+ data = newData;
122
+ let patternIndex;
123
+ while ((patternIndex = findDoubleNewlineIndex(data)) !== -1) {
124
+ yield data.slice(0, patternIndex);
125
+ data = data.slice(patternIndex);
126
+ }
127
+ }
128
+ if (data.length) {
129
+ yield data;
130
+ }
131
+ }
132
+ function findDoubleNewlineIndex(buffer) {
133
+ // This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
134
+ // and returns the index right after the first occurrence of any pattern,
135
+ // or -1 if none of the patterns are found.
136
+ const newline = 0x0a; // \n
137
+ const carriage = 0x0d; // \r
138
+ for (let i = 0; i < buffer.length - 2; i++) {
139
+ if (buffer[i] === newline && buffer[i + 1] === newline) {
140
+ // \n\n
141
+ return i + 2;
142
+ }
143
+ if (buffer[i] === carriage && buffer[i + 1] === carriage) {
144
+ // \r\r
145
+ return i + 2;
146
+ }
147
+ if (buffer[i] === carriage &&
148
+ buffer[i + 1] === newline &&
149
+ i + 3 < buffer.length &&
150
+ buffer[i + 2] === carriage &&
151
+ buffer[i + 3] === newline) {
152
+ // \r\n\r\n
153
+ return i + 4;
154
+ }
155
+ }
156
+ return -1;
157
+ }
158
+ /**
159
+ * This is an internal helper function that's just used for testing.
160
+ * @param chunks - The chunks to decode.
161
+ * @returns The decoded lines.
162
+ * @internal
163
+ */
164
+ export function _decodeChunks(chunks) {
165
+ const decoder = new LineDecoder();
166
+ const lines = [];
167
+ for (const chunk of chunks) {
168
+ lines.push(...decoder.decode(chunk));
169
+ }
170
+ return lines;
171
+ }
172
+ //# sourceMappingURL=sse-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-stream.js","sourceRoot":"","sources":["../../../src/azure-openai/stream/sse-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,MAAM,MAAM,GAAG,YAAY,CAAC;IAC1B,OAAO,EAAE,mBAAmB;IAC5B,cAAc,EAAE,yBAAyB;CAC1C,CAAC,CAAC;AAIH;;;GAGG;AACH,MAAM,OAAO,SAAS;IA6DX;IA5DC,MAAM,CAAC,oBAAoB,CACnC,QAAsB,EACtB,UAA2B;QAE3B,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,KAAK,SAAS,CAAC,CAAC,QAAQ;YACtB,IAAI,QAAQ,EAAE,CAAC;gBACb,M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,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export type { AzureOpenAiChatModel, AzureOpenAiEmbeddingModel, AzureOpenAiEmbeddingParameters, AzureOpenAiEmbeddingOutput } from './azure-openai/index.js';
2
- export { AzureOpenAiChatClient, AzureOpenAiEmbeddingClient, AzureOpenAiChatCompletionResponse, AzureOpenAiEmbeddingResponse } from './azure-openai/index.js';
2
+ export { AzureOpenAiChatClient, AzureOpenAiEmbeddingClient, AzureOpenAiChatCompletionResponse, AzureOpenAiEmbeddingResponse, AzureOpenAiChatCompletionStreamChunkResponse, AzureOpenAiChatCompletionStreamResponse, AzureOpenAiChatCompletionStream } from './azure-openai/index.js';
3
3
  export type { AzureOpenAiCreateChatCompletionRequest, AzureOpenAiChatCompletionsRequestCommon, AzureOpenAiChatCompletionRequestMessage, AzureOpenAiChatCompletionRequestMessageRole, AzureOpenAiAzureChatExtensionConfiguration, AzureOpenAiAzureChatExtensionType, AzureOpenAiChatCompletionResponseFormat, AzureOpenAiChatCompletionTool, AzureOpenAiChatCompletionToolType, AzureOpenAiChatCompletionFunctionParameters, AzureOpenAiChatCompletionToolChoiceOption, AzureOpenAiChatCompletionNamedToolChoice, AzureOpenAiChatCompletionFunction, AzureOpenAiChatCompletionRequestMessageSystem, AzureOpenAiChatCompletionRequestMessageUser, AzureOpenAiChatCompletionRequestMessageAssistant, AzureOpenAiChatCompletionRequestMessageTool, AzureOpenAiChatCompletionMessageToolCall, AzureOpenAiAzureChatExtensionsMessageContext, AzureOpenAiToolCallType, AzureOpenAiCitation, AzureOpenAiChatCompletionRequestMessageFunction, AzureOpenAiChatCompletionRequestMessageContentPart, AzureOpenAiChatCompletionRequestMessageContentPartType, AzureOpenAiCreateChatCompletionResponse, AzureOpenAiChatCompletionsResponseCommon, AzureOpenAiPromptFilterResults, AzureOpenAiPromptFilterResult, AzureOpenAiContentFilterPromptResults, AzureOpenAiContentFilterResultsBase, AzureOpenAiContentFilterSeverityResult, AzureOpenAiContentFilterDetectedResult, AzureOpenAiError, AzureOpenAiErrorBase, AzureOpenAiInnerError, AzureOpenAiInnerErrorCode, AzureOpenAiChatCompletionChoiceCommon, AzureOpenAiChatCompletionResponseMessage, AzureOpenAiContentFilterChoiceResults, AzureOpenAiChatCompletionChoiceLogProbs, AzureOpenAiChatCompletionResponseMessageRole, AzureOpenAiChatCompletionFunctionCall, AzureOpenAiContentFilterDetectedWithCitationResult, AzureOpenAiChatCompletionTokenLogprob, AzureOpenAiCompletionUsage, AzureOpenAiChatCompletionResponseObject } from './azure-openai/client/inference/schema/index.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC7B,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,sCAAsC,EACtC,uCAAuC,EACvC,uCAAuC,EACvC,2CAA2C,EAC3C,0CAA0C,EAC1C,iCAAiC,EACjC,uCAAuC,EACvC,6BAA6B,EAC7B,iCAAiC,EACjC,2CAA2C,EAC3C,yCAAyC,EACzC,wCAAwC,EACxC,iCAAiC,EACjC,6CAA6C,EAC7C,2CAA2C,EAC3C,gDAAgD,EAChD,2CAA2C,EAC3C,wCAAwC,EACxC,4CAA4C,EAC5C,uBAAuB,EACvB,mBAAmB,EACnB,+CAA+C,EAC/C,kDAAkD,EAClD,sDAAsD,EACtD,uCAAuC,EACvC,wCAAwC,EACxC,8BAA8B,EAC9B,6BAA6B,EAC7B,qCAAqC,EACrC,mCAAmC,EACnC,sCAAsC,EACtC,sCAAsC,EACtC,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,qCAAqC,EACrC,wCAAwC,EACxC,qCAAqC,EACrC,uCAAuC,EACvC,4CAA4C,EAC5C,qCAAqC,EACrC,kDAAkD,EAClD,qCAAqC,EACrC,0BAA0B,EAC1B,uCAAuC,EACxC,MAAM,iDAAiD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,4CAA4C,EAC5C,uCAAuC,EACvC,+BAA+B,EAChC,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,sCAAsC,EACtC,uCAAuC,EACvC,uCAAuC,EACvC,2CAA2C,EAC3C,0CAA0C,EAC1C,iCAAiC,EACjC,uCAAuC,EACvC,6BAA6B,EAC7B,iCAAiC,EACjC,2CAA2C,EAC3C,yCAAyC,EACzC,wCAAwC,EACxC,iCAAiC,EACjC,6CAA6C,EAC7C,2CAA2C,EAC3C,gDAAgD,EAChD,2CAA2C,EAC3C,wCAAwC,EACxC,4CAA4C,EAC5C,uBAAuB,EACvB,mBAAmB,EACnB,+CAA+C,EAC/C,kDAAkD,EAClD,sDAAsD,EACtD,uCAAuC,EACvC,wCAAwC,EACxC,8BAA8B,EAC9B,6BAA6B,EAC7B,qCAAqC,EACrC,mCAAmC,EACnC,sCAAsC,EACtC,sCAAsC,EACtC,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,qCAAqC,EACrC,wCAAwC,EACxC,qCAAqC,EACrC,uCAAuC,EACvC,4CAA4C,EAC5C,qCAAqC,EACrC,kDAAkD,EAClD,qCAAqC,EACrC,0BAA0B,EAC1B,uCAAuC,EACxC,MAAM,iDAAiD,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { AzureOpenAiChatClient, AzureOpenAiEmbeddingClient, AzureOpenAiChatCompletionResponse, AzureOpenAiEmbeddingResponse } from './azure-openai/index.js';
1
+ export { AzureOpenAiChatClient, AzureOpenAiEmbeddingClient, AzureOpenAiChatCompletionResponse, AzureOpenAiEmbeddingResponse, AzureOpenAiChatCompletionStreamChunkResponse, AzureOpenAiChatCompletionStreamResponse, AzureOpenAiChatCompletionStream } from './azure-openai/index.js';
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC7B,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,4CAA4C,EAC5C,uCAAuC,EACvC,+BAA+B,EAChC,MAAM,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ai-sdk/foundation-models",
3
- "version": "1.3.1-20241118013144.0",
3
+ "version": "1.3.1-20241119013140.0",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -22,8 +22,8 @@
22
22
  "dependencies": {
23
23
  "@sap-cloud-sdk/http-client": "^3.22.2",
24
24
  "@sap-cloud-sdk/util": "^3.22.2",
25
- "@sap-ai-sdk/ai-api": "^1.3.1-20241118013144.0",
26
- "@sap-ai-sdk/core": "^1.3.1-20241118013144.0"
25
+ "@sap-ai-sdk/ai-api": "^1.3.1-20241119013140.0",
26
+ "@sap-ai-sdk/core": "^1.3.1-20241119013140.0"
27
27
  },
28
28
  "scripts": {
29
29
  "compile": "tsc",