@sap-ai-sdk/orchestration 0.1.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 (145) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +32 -0
  3. package/dist/client/api/index.d.ts +2 -0
  4. package/dist/client/api/index.d.ts.map +1 -0
  5. package/dist/client/api/index.js +7 -0
  6. package/dist/client/api/index.js.map +1 -0
  7. package/dist/client/api/schema/azure-content-safety-filter-config.d.ts +13 -0
  8. package/dist/client/api/schema/azure-content-safety-filter-config.d.ts.map +1 -0
  9. package/dist/client/api/schema/azure-content-safety-filter-config.js +2 -0
  10. package/dist/client/api/schema/azure-content-safety-filter-config.js.map +1 -0
  11. package/dist/client/api/schema/azure-content-safety.d.ts +11 -0
  12. package/dist/client/api/schema/azure-content-safety.d.ts.map +1 -0
  13. package/dist/client/api/schema/azure-content-safety.js +2 -0
  14. package/dist/client/api/schema/azure-content-safety.js.map +1 -0
  15. package/dist/client/api/schema/azure-threshold.d.ts +5 -0
  16. package/dist/client/api/schema/azure-threshold.d.ts.map +1 -0
  17. package/dist/client/api/schema/azure-threshold.js +7 -0
  18. package/dist/client/api/schema/azure-threshold.js.map +1 -0
  19. package/dist/client/api/schema/chat-message.d.ts +14 -0
  20. package/dist/client/api/schema/chat-message.d.ts.map +1 -0
  21. package/dist/client/api/schema/chat-message.js +7 -0
  22. package/dist/client/api/schema/chat-message.js.map +1 -0
  23. package/dist/client/api/schema/chat-messages.d.ts +6 -0
  24. package/dist/client/api/schema/chat-messages.d.ts.map +1 -0
  25. package/dist/client/api/schema/chat-messages.js +2 -0
  26. package/dist/client/api/schema/chat-messages.js.map +1 -0
  27. package/dist/client/api/schema/completion-post-request.d.ts +20 -0
  28. package/dist/client/api/schema/completion-post-request.d.ts.map +1 -0
  29. package/dist/client/api/schema/completion-post-request.js +2 -0
  30. package/dist/client/api/schema/completion-post-request.js.map +1 -0
  31. package/dist/client/api/schema/completion-post-response.d.ts +15 -0
  32. package/dist/client/api/schema/completion-post-response.d.ts.map +1 -0
  33. package/dist/client/api/schema/completion-post-response.js +2 -0
  34. package/dist/client/api/schema/completion-post-response.js.map +1 -0
  35. package/dist/client/api/schema/dpi-config.d.ts +20 -0
  36. package/dist/client/api/schema/dpi-config.d.ts.map +1 -0
  37. package/dist/client/api/schema/dpi-config.js +2 -0
  38. package/dist/client/api/schema/dpi-config.js.map +1 -0
  39. package/dist/client/api/schema/dpi-entities.d.ts +5 -0
  40. package/dist/client/api/schema/dpi-entities.d.ts.map +1 -0
  41. package/dist/client/api/schema/dpi-entities.js +7 -0
  42. package/dist/client/api/schema/dpi-entities.js.map +1 -0
  43. package/dist/client/api/schema/dpi-entity-config.d.ts +11 -0
  44. package/dist/client/api/schema/dpi-entity-config.d.ts.map +1 -0
  45. package/dist/client/api/schema/dpi-entity-config.js +2 -0
  46. package/dist/client/api/schema/dpi-entity-config.js.map +1 -0
  47. package/dist/client/api/schema/error-response.d.ts +25 -0
  48. package/dist/client/api/schema/error-response.d.ts.map +1 -0
  49. package/dist/client/api/schema/error-response.js +2 -0
  50. package/dist/client/api/schema/error-response.js.map +1 -0
  51. package/dist/client/api/schema/filter-config.d.ts +6 -0
  52. package/dist/client/api/schema/filter-config.d.ts.map +1 -0
  53. package/dist/client/api/schema/filter-config.js +2 -0
  54. package/dist/client/api/schema/filter-config.js.map +1 -0
  55. package/dist/client/api/schema/filtering-config.d.ts +12 -0
  56. package/dist/client/api/schema/filtering-config.d.ts.map +1 -0
  57. package/dist/client/api/schema/filtering-config.js +2 -0
  58. package/dist/client/api/schema/filtering-config.js.map +1 -0
  59. package/dist/client/api/schema/filtering-module-config.d.ts +15 -0
  60. package/dist/client/api/schema/filtering-module-config.d.ts.map +1 -0
  61. package/dist/client/api/schema/filtering-module-config.js +2 -0
  62. package/dist/client/api/schema/filtering-module-config.js.map +1 -0
  63. package/dist/client/api/schema/generic-module-result.d.ts +15 -0
  64. package/dist/client/api/schema/generic-module-result.d.ts.map +1 -0
  65. package/dist/client/api/schema/generic-module-result.js +7 -0
  66. package/dist/client/api/schema/generic-module-result.js.map +1 -0
  67. package/dist/client/api/schema/grounding-filter.d.ts +36 -0
  68. package/dist/client/api/schema/grounding-filter.d.ts.map +1 -0
  69. package/dist/client/api/schema/grounding-filter.js +7 -0
  70. package/dist/client/api/schema/grounding-filter.js.map +1 -0
  71. package/dist/client/api/schema/grounding-module-config.d.ts +26 -0
  72. package/dist/client/api/schema/grounding-module-config.d.ts.map +1 -0
  73. package/dist/client/api/schema/grounding-module-config.js +2 -0
  74. package/dist/client/api/schema/grounding-module-config.js.map +1 -0
  75. package/dist/client/api/schema/index.d.ts +28 -0
  76. package/dist/client/api/schema/index.d.ts.map +1 -0
  77. package/dist/client/api/schema/index.js +33 -0
  78. package/dist/client/api/schema/index.js.map +1 -0
  79. package/dist/client/api/schema/llm-choice.d.ts +21 -0
  80. package/dist/client/api/schema/llm-choice.d.ts.map +1 -0
  81. package/dist/client/api/schema/llm-choice.js +2 -0
  82. package/dist/client/api/schema/llm-choice.js.map +1 -0
  83. package/dist/client/api/schema/llm-module-config.d.ts +27 -0
  84. package/dist/client/api/schema/llm-module-config.d.ts.map +1 -0
  85. package/dist/client/api/schema/llm-module-config.js +7 -0
  86. package/dist/client/api/schema/llm-module-config.js.map +1 -0
  87. package/dist/client/api/schema/llm-module-result.d.ts +38 -0
  88. package/dist/client/api/schema/llm-module-result.d.ts.map +1 -0
  89. package/dist/client/api/schema/llm-module-result.js +2 -0
  90. package/dist/client/api/schema/llm-module-result.js.map +1 -0
  91. package/dist/client/api/schema/masking-module-config.d.ts +12 -0
  92. package/dist/client/api/schema/masking-module-config.d.ts.map +1 -0
  93. package/dist/client/api/schema/masking-module-config.js +2 -0
  94. package/dist/client/api/schema/masking-module-config.js.map +1 -0
  95. package/dist/client/api/schema/masking-provider-config.d.ts +6 -0
  96. package/dist/client/api/schema/masking-provider-config.d.ts.map +1 -0
  97. package/dist/client/api/schema/masking-provider-config.js +2 -0
  98. package/dist/client/api/schema/masking-provider-config.js.map +1 -0
  99. package/dist/client/api/schema/module-configs.d.ts +16 -0
  100. package/dist/client/api/schema/module-configs.d.ts.map +1 -0
  101. package/dist/client/api/schema/module-configs.js +2 -0
  102. package/dist/client/api/schema/module-configs.js.map +1 -0
  103. package/dist/client/api/schema/module-results.d.ts +17 -0
  104. package/dist/client/api/schema/module-results.d.ts.map +1 -0
  105. package/dist/client/api/schema/module-results.js +2 -0
  106. package/dist/client/api/schema/module-results.js.map +1 -0
  107. package/dist/client/api/schema/orchestration-config.d.ts +8 -0
  108. package/dist/client/api/schema/orchestration-config.d.ts.map +1 -0
  109. package/dist/client/api/schema/orchestration-config.js +2 -0
  110. package/dist/client/api/schema/orchestration-config.js.map +1 -0
  111. package/dist/client/api/schema/templating-module-config.d.ts +26 -0
  112. package/dist/client/api/schema/templating-module-config.d.ts.map +1 -0
  113. package/dist/client/api/schema/templating-module-config.js +2 -0
  114. package/dist/client/api/schema/templating-module-config.js.map +1 -0
  115. package/dist/client/api/schema/token-usage.d.ts +21 -0
  116. package/dist/client/api/schema/token-usage.d.ts.map +1 -0
  117. package/dist/client/api/schema/token-usage.js +7 -0
  118. package/dist/client/api/schema/token-usage.js.map +1 -0
  119. package/dist/index.d.ts +6 -0
  120. package/dist/index.d.ts.map +1 -0
  121. package/dist/index.js +4 -0
  122. package/dist/index.js.map +1 -0
  123. package/dist/internal.d.ts +6 -0
  124. package/dist/internal.d.ts.map +1 -0
  125. package/dist/internal.js +6 -0
  126. package/dist/internal.js.map +1 -0
  127. package/dist/orchestration-client.d.ts +30 -0
  128. package/dist/orchestration-client.d.ts.map +1 -0
  129. package/dist/orchestration-client.js +61 -0
  130. package/dist/orchestration-client.js.map +1 -0
  131. package/dist/orchestration-filter-utility.d.ts +8 -0
  132. package/dist/orchestration-filter-utility.d.ts.map +1 -0
  133. package/dist/orchestration-filter-utility.js +19 -0
  134. package/dist/orchestration-filter-utility.js.map +1 -0
  135. package/dist/orchestration-response.d.ts +33 -0
  136. package/dist/orchestration-response.d.ts.map +1 -0
  137. package/dist/orchestration-response.js +57 -0
  138. package/dist/orchestration-response.js.map +1 -0
  139. package/dist/orchestration-types.d.ts +36 -0
  140. package/dist/orchestration-types.d.ts.map +1 -0
  141. package/dist/orchestration-types.js +2 -0
  142. package/dist/orchestration-types.js.map +1 -0
  143. package/internal.d.ts +3 -0
  144. package/internal.js +2 -0
  145. package/package.json +44 -0
@@ -0,0 +1,30 @@
1
+ import { CustomRequestConfig } from '@sap-ai-sdk/core';
2
+ import { ResourceGroupConfiguration } from '@sap-ai-sdk/ai-api/internal.js';
3
+ import { CompletionPostRequest } from './client/api/schema/index.js';
4
+ import { OrchestrationModuleConfig, Prompt } from './orchestration-types.js';
5
+ import { OrchestrationResponse } from './orchestration-response.js';
6
+ /**
7
+ * Get the orchestration client.
8
+ */
9
+ export declare class OrchestrationClient {
10
+ private config;
11
+ private deploymentConfig?;
12
+ /**
13
+ * Creates an instance of the orchestration client.
14
+ * @param config - Orchestration module configuration.
15
+ * @param deploymentConfig - Deployment configuration.
16
+ */
17
+ constructor(config: OrchestrationModuleConfig, deploymentConfig?: ResourceGroupConfiguration | undefined);
18
+ /**
19
+ * Creates a completion for the chat messages.
20
+ * @param prompt - Prompt configuration.
21
+ * @param requestConfig - Request configuration.
22
+ * @returns The completion result.
23
+ */
24
+ chatCompletion(prompt?: Prompt, requestConfig?: CustomRequestConfig): Promise<OrchestrationResponse>;
25
+ }
26
+ /**
27
+ * @internal
28
+ */
29
+ export declare function constructCompletionPostRequest(config: OrchestrationModuleConfig, prompt?: Prompt): CompletionPostRequest;
30
+ //# sourceMappingURL=orchestration-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-client.d.ts","sourceRoot":"","sources":["../src/orchestration-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAEL,0BAA0B,EAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;GAEG;AACH,qBAAa,mBAAmB;IAO5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB,CAAC;IAP3B;;;;OAIG;gBAEO,MAAM,EAAE,yBAAyB,EACjC,gBAAgB,CAAC,EAAE,0BAA0B,YAAA;IAGvD;;;;;OAKG;IACG,cAAc,CAClB,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,qBAAqB,CAAC;CAiBlC;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,yBAAyB,EACjC,MAAM,CAAC,EAAE,MAAM,GACd,qBAAqB,CAoBvB"}
@@ -0,0 +1,61 @@
1
+ import { executeRequest } from '@sap-ai-sdk/core';
2
+ import { resolveDeploymentId } from '@sap-ai-sdk/ai-api/internal.js';
3
+ import { OrchestrationResponse } from './orchestration-response.js';
4
+ /**
5
+ * Get the orchestration client.
6
+ */
7
+ export class OrchestrationClient {
8
+ config;
9
+ deploymentConfig;
10
+ /**
11
+ * Creates an instance of the orchestration client.
12
+ * @param config - Orchestration module configuration.
13
+ * @param deploymentConfig - Deployment configuration.
14
+ */
15
+ constructor(config, deploymentConfig) {
16
+ this.config = config;
17
+ this.deploymentConfig = deploymentConfig;
18
+ }
19
+ /**
20
+ * Creates a completion for the chat messages.
21
+ * @param prompt - Prompt configuration.
22
+ * @param requestConfig - Request configuration.
23
+ * @returns The completion result.
24
+ */
25
+ async chatCompletion(prompt, requestConfig) {
26
+ const body = constructCompletionPostRequest(this.config, prompt);
27
+ const deploymentId = await resolveDeploymentId({
28
+ scenarioId: 'orchestration',
29
+ resourceGroup: this.deploymentConfig?.resourceGroup
30
+ });
31
+ const response = await executeRequest({
32
+ url: `/inference/deployments/${deploymentId}/completion`
33
+ }, body, requestConfig);
34
+ return new OrchestrationResponse(response);
35
+ }
36
+ }
37
+ /**
38
+ * @internal
39
+ */
40
+ export function constructCompletionPostRequest(config, prompt) {
41
+ return {
42
+ orchestration_config: {
43
+ module_configurations: {
44
+ templating_module_config: {
45
+ template: config.templatingConfig.template
46
+ },
47
+ llm_module_config: config.llmConfig,
48
+ ...(Object.keys(config?.filterConfig || {}).length && {
49
+ filtering_module_config: config.filterConfig
50
+ })
51
+ }
52
+ },
53
+ ...(prompt?.inputParams && {
54
+ input_params: prompt.inputParams
55
+ }),
56
+ ...(prompt?.messagesHistory && {
57
+ messages_history: prompt.messagesHistory
58
+ })
59
+ };
60
+ }
61
+ //# sourceMappingURL=orchestration-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-client.js","sourceRoot":"","sources":["../src/orchestration-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,mBAAmB,EAEpB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAOpB;IACA;IAPV;;;;OAIG;IACH,YACU,MAAiC,EACjC,gBAA6C;QAD7C,WAAM,GAAN,MAAM,CAA2B;QACjC,qBAAgB,GAAhB,gBAAgB,CAA6B;IACpD,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAClB,MAAe,EACf,aAAmC;QAEnC,MAAM,IAAI,GAAG,8BAA8B,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAAC;YAC7C,UAAU,EAAE,eAAe;YAC3B,aAAa,EAAE,IAAI,CAAC,gBAAgB,EAAE,aAAa;SACpD,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC;YACE,GAAG,EAAE,0BAA0B,YAAY,aAAa;SACzD,EACD,IAAI,EACJ,aAAa,CACd,CAAC;QAEF,OAAO,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAAiC,EACjC,MAAe;IAEf,OAAO;QACL,oBAAoB,EAAE;YACpB,qBAAqB,EAAE;gBACrB,wBAAwB,EAAE;oBACxB,QAAQ,EAAE,MAAM,CAAC,gBAAgB,CAAC,QAAQ;iBAC3C;gBACD,iBAAiB,EAAE,MAAM,CAAC,SAAS;gBACnC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI;oBACpD,uBAAuB,EAAE,MAAM,CAAC,YAAY;iBAC7C,CAAC;aACH;SACF;QACD,GAAG,CAAC,MAAM,EAAE,WAAW,IAAI;YACzB,YAAY,EAAE,MAAM,CAAC,WAAW;SACjC,CAAC;QACF,GAAG,CAAC,MAAM,EAAE,eAAe,IAAI;YAC7B,gBAAgB,EAAE,MAAM,CAAC,eAAe;SACzC,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { AzureContentSafety, FilteringConfig } from './client/api/index.js';
2
+ /**
3
+ * Convenience function to create Azure filters.
4
+ * @param filter - Filtering configuration for Azure filter. If skipped, the default Azure filter configuration is used.
5
+ * @returns An object with the Azure filtering configuration.
6
+ */
7
+ export declare function azureContentFilter(filter?: AzureContentSafety): FilteringConfig;
8
+ //# sourceMappingURL=orchestration-filter-utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-filter-utility.d.ts","sourceRoot":"","sources":["../src/orchestration-filter-utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,CAAC,EAAE,kBAAkB,GAC1B,eAAe,CAYjB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Convenience function to create Azure filters.
3
+ * @param filter - Filtering configuration for Azure filter. If skipped, the default Azure filter configuration is used.
4
+ * @returns An object with the Azure filtering configuration.
5
+ */
6
+ export function azureContentFilter(filter) {
7
+ if (filter && !Object.keys(filter).length) {
8
+ throw new Error('Filter property cannot be an empty object');
9
+ }
10
+ return {
11
+ filters: [
12
+ {
13
+ type: 'azure_content_safety',
14
+ ...(filter && { config: filter })
15
+ }
16
+ ]
17
+ };
18
+ }
19
+ //# sourceMappingURL=orchestration-filter-utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-filter-utility.js","sourceRoot":"","sources":["../src/orchestration-filter-utility.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA2B;IAE3B,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,sBAAsB;gBAC5B,GAAG,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;aAClC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { HttpResponse } from '@sap-cloud-sdk/http-client';
2
+ import { CompletionPostResponse, TokenUsage } from './client/api/schema/index.js';
3
+ /**
4
+ * Representation of an orchestration response.
5
+ */
6
+ export declare class OrchestrationResponse {
7
+ readonly rawResponse: HttpResponse;
8
+ /**
9
+ * The completion post response.
10
+ */
11
+ readonly data: CompletionPostResponse;
12
+ constructor(rawResponse: HttpResponse);
13
+ /**
14
+ * Usage of tokens in the response.
15
+ * @returns Token usage.
16
+ */
17
+ getTokenUsage(): TokenUsage;
18
+ /**
19
+ * Reason for stopping the completion.
20
+ * @param choiceIndex - The index of the choice to parse.
21
+ * @returns The finish reason.
22
+ */
23
+ getFinishReason(choiceIndex?: number): string | undefined;
24
+ /**
25
+ * Parses the orchestration response and returns the content.
26
+ * @param choiceIndex - The index of the choice to parse.
27
+ * @returns The message content.
28
+ */
29
+ getContent(choiceIndex?: number): string | undefined;
30
+ private getChoices;
31
+ private logInvalidChoiceIndex;
32
+ }
33
+ //# sourceMappingURL=orchestration-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-response.d.ts","sourceRoot":"","sources":["../src/orchestration-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EACL,sBAAsB,EACtB,UAAU,EACX,MAAM,8BAA8B,CAAC;AAOtC;;GAEG;AACH,qBAAa,qBAAqB;aAKJ,WAAW,EAAE,YAAY;IAJrD;;OAEG;IACH,SAAgB,IAAI,EAAE,sBAAsB,CAAC;gBACjB,WAAW,EAAE,YAAY;IAIrD;;;OAGG;IACH,aAAa,IAAI,UAAU;IAG3B;;;;OAIG;IACH,eAAe,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS;IAKpD;;;;OAIG;IACH,UAAU,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS;IAa/C,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,qBAAqB;CAK9B"}
@@ -0,0 +1,57 @@
1
+ import { createLogger } from '@sap-cloud-sdk/util';
2
+ const logger = createLogger({
3
+ package: 'gen-ai-hub',
4
+ messageContext: 'orchestration-response'
5
+ });
6
+ /**
7
+ * Representation of an orchestration response.
8
+ */
9
+ export class OrchestrationResponse {
10
+ rawResponse;
11
+ /**
12
+ * The completion post response.
13
+ */
14
+ data;
15
+ constructor(rawResponse) {
16
+ this.rawResponse = rawResponse;
17
+ this.data = rawResponse.data;
18
+ }
19
+ /**
20
+ * Usage of tokens in the response.
21
+ * @returns Token usage.
22
+ */
23
+ getTokenUsage() {
24
+ return this.data.orchestration_result.usage;
25
+ }
26
+ /**
27
+ * Reason for stopping the completion.
28
+ * @param choiceIndex - The index of the choice to parse.
29
+ * @returns The finish reason.
30
+ */
31
+ getFinishReason(choiceIndex = 0) {
32
+ this.logInvalidChoiceIndex(choiceIndex);
33
+ return this.getChoices()[choiceIndex]?.finish_reason;
34
+ }
35
+ /**
36
+ * Parses the orchestration response and returns the content.
37
+ * @param choiceIndex - The index of the choice to parse.
38
+ * @returns The message content.
39
+ */
40
+ getContent(choiceIndex = 0) {
41
+ this.logInvalidChoiceIndex(choiceIndex);
42
+ if (this.getChoices()[choiceIndex]?.message?.content === '' &&
43
+ this.getChoices()[choiceIndex]?.finish_reason === 'content_filter') {
44
+ throw new Error('Content generated by the LLM was filtered by the output filter. Please try again with a different prompt or filter configuration.');
45
+ }
46
+ return this.getChoices()[choiceIndex]?.message?.content;
47
+ }
48
+ getChoices() {
49
+ return this.data.orchestration_result.choices;
50
+ }
51
+ logInvalidChoiceIndex(choiceIndex) {
52
+ if (choiceIndex < 0 || choiceIndex >= this.getChoices().length) {
53
+ logger.error(`Choice index ${choiceIndex} is out of bounds.`);
54
+ }
55
+ }
56
+ }
57
+ //# sourceMappingURL=orchestration-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-response.js","sourceRoot":"","sources":["../src/orchestration-response.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,MAAM,MAAM,GAAG,YAAY,CAAC;IAC1B,OAAO,EAAE,YAAY;IACrB,cAAc,EAAE,wBAAwB;CACzC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAKJ;IAJ5B;;OAEG;IACa,IAAI,CAAyB;IAC7C,YAA4B,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;QACnD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;IAC9C,CAAC;IACD;;;;OAIG;IACH,eAAe,CAAC,WAAW,GAAG,CAAC;QAC7B,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,WAAW,GAAG,CAAC;QACxB,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACxC,IACE,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE;YACvD,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC,EAAE,aAAa,KAAK,gBAAgB,EAClE,CAAC;YACD,MAAM,IAAI,KAAK,CACb,mIAAmI,CACpI,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;IAC1D,CAAC;IAEO,UAAU;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;IAChD,CAAC;IAEO,qBAAqB,CAAC,WAAmB;QAC/C,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,CAAC;YAC/D,MAAM,CAAC,KAAK,CAAC,gBAAgB,WAAW,oBAAoB,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import { ChatMessages, FilteringModuleConfig, LLMModuleConfig, TemplatingModuleConfig } from './client/api/index.js';
2
+ /**
3
+ * Prompt configuration.
4
+ */
5
+ export interface Prompt {
6
+ /**
7
+ * History.
8
+ */
9
+ messagesHistory?: ChatMessages;
10
+ /**
11
+ * Template parameters.
12
+ */
13
+ inputParams?: Record<string, string>;
14
+ }
15
+ /**
16
+ * LLMModule configuration.
17
+ */
18
+ export type LlmConfig = LLMModuleConfig;
19
+ /**
20
+ * Orchestration module configuration.
21
+ */
22
+ export interface OrchestrationModuleConfig {
23
+ /**
24
+ * Templating configuration options.
25
+ */
26
+ templatingConfig: TemplatingModuleConfig;
27
+ /**
28
+ * Llm configuration options.
29
+ */
30
+ llmConfig: LlmConfig;
31
+ /**
32
+ * Filter configuration options.
33
+ */
34
+ filterConfig?: FilteringModuleConfig;
35
+ }
36
+ //# sourceMappingURL=orchestration-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-types.d.ts","sourceRoot":"","sources":["../src/orchestration-types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,YAAY,CAAC;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAGD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IAExC;;OAEG;IACH,gBAAgB,EAAE,sBAAsB,CAAC;IACzC;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=orchestration-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-types.js","sourceRoot":"","sources":["../src/orchestration-types.ts"],"names":[],"mappings":""}
package/internal.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ // eslint-disable-next-line import/no-internal-modules
2
+ export * from './dist/internal.js';
3
+ // # sourceMappingURL=internal.d.ts.map
package/internal.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/internal.js';
2
+ //# sourceMappingURL=internal.js.map
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@sap-ai-sdk/orchestration",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "sap-ai-sdk",
8
+ "orchestration",
9
+ "llm-access"
10
+ ],
11
+ "type": "module",
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "files": [
15
+ "dist/**/*.js",
16
+ "dist/**/*.js.map",
17
+ "dist/**/*.d.ts",
18
+ "dist/**/*.d.ts.map",
19
+ "internal.js",
20
+ "internal.d.ts"
21
+ ],
22
+ "dependencies": {
23
+ "@sap-cloud-sdk/http-client": "^3.20.0",
24
+ "@sap-cloud-sdk/connectivity": "^3.20.0",
25
+ "@sap-cloud-sdk/util": "^3.20.0",
26
+ "@sap-cloud-sdk/openapi": "^3.20.0",
27
+ "@sap-ai-sdk/core": "^0.1.0",
28
+ "@sap-ai-sdk/ai-api": "^0.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "@sap-cloud-sdk/openapi-generator": "^3.20.0",
32
+ "typescript": "^5.5.4",
33
+ "nock": "^13.5.5"
34
+ },
35
+ "scripts": {
36
+ "compile": "tsc",
37
+ "compile:cjs": "tsc -p tsconfig.cjs.json",
38
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
39
+ "lint": "eslint \"**/*.ts\" && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -c",
40
+ "lint:fix": "eslint \"**/*.ts\" --fix && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -w --log-level error",
41
+ "generate": "openapi-generator --generateESM --clearOutputDir -i ./src/spec/api.yaml -o ./src/client && pnpm lint:fix",
42
+ "check:public-api": "node --loader ts-node/esm ../../scripts/check-public-api-cli.ts"
43
+ }
44
+ }