@jerome-benoit/sap-ai-provider 4.6.9 → 4.7.1
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/LICENSE +202 -0
- package/README.md +22 -32
- package/dist/{chunk-EXOXZ5OU.js → chunk-4JIMBRMV.js} +44 -7
- package/dist/chunk-4JIMBRMV.js.map +1 -0
- package/dist/{chunk-4RRRJBEL.js → chunk-BZWUUBX2.js} +407 -275
- package/dist/chunk-BZWUUBX2.js.map +1 -0
- package/dist/chunk-HDOSHLV6.js +190 -0
- package/dist/chunk-HDOSHLV6.js.map +1 -0
- package/dist/chunk-OA6TJHD2.js +93 -0
- package/dist/chunk-OA6TJHD2.js.map +1 -0
- package/dist/{chunk-DYFBCE2W.js → chunk-RUCURXS7.js} +60 -6
- package/dist/chunk-RUCURXS7.js.map +1 -0
- package/dist/{chunk-F4MUYVQJ.js → chunk-XIWHF23D.js} +1919 -955
- package/dist/chunk-XIWHF23D.js.map +1 -0
- package/dist/{foundation-models-embedding-model-strategy-3MMM3QDC.js → foundation-models-embedding-model-strategy-TACUPFS2.js} +8 -4
- package/dist/foundation-models-embedding-model-strategy-TACUPFS2.js.map +1 -0
- package/dist/{foundation-models-language-model-strategy-OPGTN6DA.js → foundation-models-language-model-strategy-LLWYUGA3.js} +15 -10
- package/dist/foundation-models-language-model-strategy-LLWYUGA3.js.map +1 -0
- package/dist/index.cjs +2546 -1311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -66
- package/dist/index.d.ts +68 -66
- package/dist/index.js +11 -172
- package/dist/index.js.map +1 -1
- package/dist/{orchestration-embedding-model-strategy-R6G6VVU6.js → orchestration-embedding-model-strategy-RYI3HWRZ.js} +14 -4
- package/dist/orchestration-embedding-model-strategy-RYI3HWRZ.js.map +1 -0
- package/dist/{orchestration-language-model-strategy-KFW3CFRY.js → orchestration-language-model-strategy-NIUPRYDW.js} +53 -77
- package/dist/orchestration-language-model-strategy-NIUPRYDW.js.map +1 -0
- package/package.json +18 -14
- package/LICENSE.md +0 -187
- package/dist/chunk-4RRRJBEL.js.map +0 -1
- package/dist/chunk-DYFBCE2W.js.map +0 -1
- package/dist/chunk-EXOXZ5OU.js.map +0 -1
- package/dist/chunk-F4MUYVQJ.js.map +0 -1
- package/dist/chunk-NQJIUL3F.js +0 -61
- package/dist/chunk-NQJIUL3F.js.map +0 -1
- package/dist/foundation-models-embedding-model-strategy-3MMM3QDC.js.map +0 -1
- package/dist/foundation-models-language-model-strategy-OPGTN6DA.js.map +0 -1
- package/dist/orchestration-embedding-model-strategy-R6G6VVU6.js.map +0 -1
- package/dist/orchestration-language-model-strategy-KFW3CFRY.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -531,29 +531,15 @@ const dpiConfig = buildDpiMaskingProvider({
|
|
|
531
531
|
|
|
532
532
|
### Content Filtering
|
|
533
533
|
|
|
534
|
-
|
|
535
|
-
import "dotenv/config"; // Load environment variables
|
|
536
|
-
import { buildAzureContentSafetyFilter, createSAPAIProvider } from "@jerome-benoit/sap-ai-provider";
|
|
537
|
-
|
|
538
|
-
const provider = createSAPAIProvider({
|
|
539
|
-
defaultSettings: {
|
|
540
|
-
filtering: {
|
|
541
|
-
input: {
|
|
542
|
-
filters: [
|
|
543
|
-
buildAzureContentSafetyFilter("input", {
|
|
544
|
-
hate: "ALLOW_SAFE",
|
|
545
|
-
violence: "ALLOW_SAFE_LOW_MEDIUM",
|
|
546
|
-
}),
|
|
547
|
-
],
|
|
548
|
-
},
|
|
549
|
-
},
|
|
550
|
-
},
|
|
551
|
-
});
|
|
552
|
-
```
|
|
534
|
+
Content filtering is available through the Orchestration API.
|
|
553
535
|
|
|
536
|
+
**Complete example:**
|
|
537
|
+
[examples/example-content-filtering.ts](./examples/example-content-filtering.ts)\
|
|
554
538
|
**Complete documentation:**
|
|
555
539
|
[API Reference - Content Filtering](./API_REFERENCE.md#buildazurecontentsafetyfiltertype-config)
|
|
556
540
|
|
|
541
|
+
**Run it:** `npx tsx examples/example-content-filtering.ts`
|
|
542
|
+
|
|
557
543
|
### Document Grounding (RAG)
|
|
558
544
|
|
|
559
545
|
Ground LLM responses in your own documents using vector databases.
|
|
@@ -567,24 +553,27 @@ Ground LLM responses in your own documents using vector databases.
|
|
|
567
553
|
const provider = createSAPAIProvider({
|
|
568
554
|
defaultSettings: {
|
|
569
555
|
grounding: buildDocumentGroundingConfig({
|
|
570
|
-
filters: [
|
|
571
|
-
|
|
572
|
-
id: "vector-store-1", // Your vector database ID
|
|
573
|
-
data_repositories: ["*"], // Search all repositories
|
|
574
|
-
},
|
|
575
|
-
],
|
|
576
|
-
placeholders: {
|
|
577
|
-
input: ["?question"],
|
|
578
|
-
output: "groundingOutput",
|
|
579
|
-
},
|
|
556
|
+
filters: [{ id: "vector-store-1", data_repositories: ["*"] }],
|
|
557
|
+
placeholders: { input: ["groundingRequest"], output: "groundingOutput" },
|
|
580
558
|
}),
|
|
581
559
|
},
|
|
582
560
|
});
|
|
583
561
|
|
|
584
|
-
|
|
585
|
-
|
|
562
|
+
const result = await generateText({
|
|
563
|
+
model: provider("gpt-4.1"),
|
|
564
|
+
prompt: "Question: {{?groundingRequest}}\nContext: {{?groundingOutput}}",
|
|
565
|
+
providerOptions: {
|
|
566
|
+
"sap-ai": {
|
|
567
|
+
escapeTemplatePlaceholders: false,
|
|
568
|
+
placeholderValues: { groundingRequest: "What is SAP?" },
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
});
|
|
586
572
|
```
|
|
587
573
|
|
|
574
|
+
Set `escapeTemplatePlaceholders` to `false` only when intentionally sending SAP
|
|
575
|
+
or Jinja placeholders in prompts or messages.
|
|
576
|
+
|
|
588
577
|
**Run it:** `npx tsx examples/example-document-grounding.ts`
|
|
589
578
|
|
|
590
579
|
### Translation
|
|
@@ -736,6 +725,7 @@ features:
|
|
|
736
725
|
| `example-streaming-chat.ts` | Streaming responses | Real-time text generation, SSE |
|
|
737
726
|
| `example-image-recognition.ts` | Multi-modal with images | Vision models, image analysis |
|
|
738
727
|
| `example-data-masking.ts` | Data privacy integration | DPI masking, anonymization |
|
|
728
|
+
| `example-content-filtering.ts` | Content filtering | Azure Content Safety, orchestration |
|
|
739
729
|
| `example-document-grounding.ts` | Document grounding (RAG) | Vector store, retrieval-augmented gen |
|
|
740
730
|
| `example-translation.ts` | Input/output translation | Multi-language support, SAP translation |
|
|
741
731
|
| `example-embeddings.ts` | Text embeddings | Vector generation, semantic similarity |
|
|
@@ -847,4 +837,4 @@ for details.
|
|
|
847
837
|
|
|
848
838
|
## License
|
|
849
839
|
|
|
850
|
-
Apache License 2.0 - see [LICENSE](./LICENSE
|
|
840
|
+
Apache License 2.0 - see [LICENSE](./LICENSE) for details.
|
|
@@ -17,6 +17,9 @@ function safeJsonStringify(value) {
|
|
|
17
17
|
return String(value);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
function wrapAsTextContent(text, cacheControl) {
|
|
21
|
+
return cacheControl ? { cache_control: cacheControl, text, type: "text" } : { text, type: "text" };
|
|
22
|
+
}
|
|
20
23
|
var JINJA2_DELIMITERS_PATTERN = /\{(?=[{%#])/g;
|
|
21
24
|
var JINJA2_DELIMITERS_ESCAPED_PATTERN = new RegExp(`\\{${ZERO_WIDTH_SPACE}([{%#])`, "g");
|
|
22
25
|
function convertToSAPMessages(prompt, options = {}) {
|
|
@@ -24,24 +27,47 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
24
27
|
const includeReasoning = options.includeReasoning ?? false;
|
|
25
28
|
const escapeTemplatePlaceholders = options.escapeTemplatePlaceholders ?? true;
|
|
26
29
|
const maybeEscape = (text) => escapeTemplatePlaceholders ? escapeOrchestrationPlaceholders(text) : text;
|
|
30
|
+
const parser = options.parsePartProviderOptions;
|
|
31
|
+
const parsePart = parser ? (providerOptions) => parser(providerOptions, options.warnings) : () => void 0;
|
|
27
32
|
for (const message of prompt) {
|
|
28
33
|
switch (message.role) {
|
|
29
34
|
case "assistant": {
|
|
30
35
|
let text = "";
|
|
36
|
+
const textParts = [];
|
|
37
|
+
let anyCacheControl = false;
|
|
31
38
|
const toolCalls = [];
|
|
32
39
|
for (const part of message.content) {
|
|
33
40
|
switch (part.type) {
|
|
34
41
|
case "reasoning": {
|
|
35
42
|
if (includeReasoning && part.text) {
|
|
36
|
-
|
|
43
|
+
const escaped = `<think>${maybeEscape(part.text)}</think>`;
|
|
44
|
+
text += escaped;
|
|
45
|
+
textParts.push({ text: escaped });
|
|
37
46
|
}
|
|
38
47
|
break;
|
|
39
48
|
}
|
|
40
49
|
case "text": {
|
|
41
|
-
|
|
50
|
+
const escaped = maybeEscape(part.text);
|
|
51
|
+
if (!escaped) break;
|
|
52
|
+
const partOpts = parsePart(part.providerOptions);
|
|
53
|
+
const cacheControl = partOpts?.cacheControl;
|
|
54
|
+
text += escaped;
|
|
55
|
+
textParts.push(cacheControl ? { cacheControl, text: escaped } : { text: escaped });
|
|
56
|
+
if (cacheControl) anyCacheControl = true;
|
|
42
57
|
break;
|
|
43
58
|
}
|
|
44
59
|
case "tool-call": {
|
|
60
|
+
const partOpts = parsePart(part.providerOptions);
|
|
61
|
+
if (partOpts?.cacheControl && options.warnings) {
|
|
62
|
+
const feature = "cacheControl on assistant tool-call";
|
|
63
|
+
if (!options.warnings.some((w) => w.feature === feature)) {
|
|
64
|
+
options.warnings.push({
|
|
65
|
+
details: "SAP orchestration does not expose cache_control on the assistant tool-call envelope.",
|
|
66
|
+
feature,
|
|
67
|
+
type: "unsupported"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
45
71
|
let argumentsJson;
|
|
46
72
|
if (typeof part.input === "string") {
|
|
47
73
|
argumentsJson = part.input;
|
|
@@ -62,7 +88,7 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
62
88
|
}
|
|
63
89
|
if (text || toolCalls.length > 0) {
|
|
64
90
|
const assistantMessage = {
|
|
65
|
-
content: text,
|
|
91
|
+
content: anyCacheControl ? textParts.map((p) => wrapAsTextContent(p.text, p.cacheControl)) : text,
|
|
66
92
|
role: "assistant",
|
|
67
93
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
68
94
|
};
|
|
@@ -71,8 +97,11 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
71
97
|
break;
|
|
72
98
|
}
|
|
73
99
|
case "system": {
|
|
100
|
+
const partOpts = parsePart(message.providerOptions);
|
|
101
|
+
const cacheControl = partOpts?.cacheControl;
|
|
102
|
+
const text = maybeEscape(message.content);
|
|
74
103
|
const systemMessage = {
|
|
75
|
-
content:
|
|
104
|
+
content: cacheControl ? [wrapAsTextContent(text, cacheControl)] : text,
|
|
76
105
|
role: "system"
|
|
77
106
|
};
|
|
78
107
|
messages.push(systemMessage);
|
|
@@ -81,9 +110,12 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
81
110
|
case "tool": {
|
|
82
111
|
for (const part of message.content) {
|
|
83
112
|
if (part.type === "tool-result") {
|
|
113
|
+
const partOpts = parsePart(part.providerOptions);
|
|
114
|
+
const cacheControl = partOpts?.cacheControl;
|
|
84
115
|
const serializedOutput = safeJsonStringify(part.output);
|
|
116
|
+
const escaped = maybeEscape(serializedOutput);
|
|
85
117
|
const toolMessage = {
|
|
86
|
-
content:
|
|
118
|
+
content: cacheControl ? [wrapAsTextContent(escaped, cacheControl)] : escaped,
|
|
87
119
|
role: "tool",
|
|
88
120
|
tool_call_id: part.toolCallId
|
|
89
121
|
};
|
|
@@ -95,6 +127,8 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
95
127
|
case "user": {
|
|
96
128
|
const contentParts = [];
|
|
97
129
|
for (const part of message.content) {
|
|
130
|
+
const partOpts = parsePart(part.providerOptions);
|
|
131
|
+
const cacheControl = partOpts?.cacheControl;
|
|
98
132
|
switch (part.type) {
|
|
99
133
|
case "file": {
|
|
100
134
|
const fileDataUrl = buildDataUrl(part);
|
|
@@ -112,6 +146,7 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
112
146
|
);
|
|
113
147
|
}
|
|
114
148
|
contentParts.push({
|
|
149
|
+
...cacheControl ? { cache_control: cacheControl } : {},
|
|
115
150
|
image_url: {
|
|
116
151
|
url: fileDataUrl
|
|
117
152
|
},
|
|
@@ -119,6 +154,7 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
119
154
|
});
|
|
120
155
|
} else {
|
|
121
156
|
contentParts.push({
|
|
157
|
+
...cacheControl ? { cache_control: cacheControl } : {},
|
|
122
158
|
file: {
|
|
123
159
|
file_data: fileDataUrl,
|
|
124
160
|
...part.filename ? { filename: part.filename } : {}
|
|
@@ -130,6 +166,7 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
130
166
|
}
|
|
131
167
|
case "text": {
|
|
132
168
|
contentParts.push({
|
|
169
|
+
...cacheControl ? { cache_control: cacheControl } : {},
|
|
133
170
|
text: maybeEscape(part.text),
|
|
134
171
|
type: "text"
|
|
135
172
|
});
|
|
@@ -143,7 +180,7 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
143
180
|
}
|
|
144
181
|
}
|
|
145
182
|
const firstPart = contentParts[0];
|
|
146
|
-
const userMessage = contentParts.length === 1 && firstPart?.type === "text" ? {
|
|
183
|
+
const userMessage = contentParts.length === 1 && firstPart?.type === "text" && firstPart.cache_control === void 0 ? {
|
|
147
184
|
content: firstPart.text ?? "",
|
|
148
185
|
role: "user"
|
|
149
186
|
} : {
|
|
@@ -202,4 +239,4 @@ export {
|
|
|
202
239
|
escapeOrchestrationPlaceholders,
|
|
203
240
|
unescapeOrchestrationPlaceholders
|
|
204
241
|
};
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
242
|
+
//# sourceMappingURL=chunk-4JIMBRMV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/convert-to-sap-messages.ts"],"sourcesContent":["import type {\n AssistantChatMessage,\n ChatMessage,\n SystemChatMessage,\n ToolChatMessage,\n UserChatMessage,\n} from \"@sap-ai-sdk/orchestration\";\n\nimport {\n InvalidPromptError,\n LanguageModelV3Prompt,\n type SharedV3Warning,\n UnsupportedFunctionalityError,\n} from \"@ai-sdk/provider\";\nimport { Buffer } from \"node:buffer\";\n\nimport type { CacheControl, ParsePartProviderOptions } from \"./sap-ai-provider-options.js\";\n\n/**\n * Options for converting Vercel AI SDK prompts to SAP AI SDK messages.\n * @see {@link convertToSAPMessages}\n */\nexport interface ConvertToSAPMessagesOptions {\n /**\n * Whether to escape Jinja2 template delimiters (`{{`, `{%`, `{#`) in message content.\n * This prevents SAP orchestration from interpreting user content as template syntax.\n * @default true\n */\n readonly escapeTemplatePlaceholders?: boolean;\n /**\n * Whether to include assistant reasoning parts (wrapped in `<think>` tags).\n * @default false\n */\n readonly includeReasoning?: boolean;\n /**\n * Optional callback that reads per-part `providerOptions['sap-ai']` (e.g. Anthropic\n * `cacheControl`) and forwards the result onto the SAP message item. Strategies that\n * do not honour part-level directives (Foundation Models) leave this undefined.\n * @default undefined\n */\n readonly parsePartProviderOptions?: ParsePartProviderOptions;\n /**\n * Optional sink for validation warnings raised by `parsePartProviderOptions`.\n * Each invalid `cacheControl` directive (or other future per-part option)\n * surfaces here so the strategy layer can forward the warning to the AI SDK\n * call result rather than dropping it silently.\n */\n readonly warnings?: SharedV3Warning[];\n}\n\n/**\n * @internal\n */\nconst ZERO_WIDTH_SPACE = \"\\u200B\";\n\n/**\n * Safely serializes a value to JSON string, handling edge cases that would cause JSON.stringify to throw.\n *\n * Handles:\n * - Circular references (objects that reference themselves)\n * - BigInt values (converted to string representation)\n * - Undefined values and symbols (handled by JSON.stringify's default behavior)\n * @param value - The value to serialize.\n * @returns JSON string representation, or a fallback string representation if serialization fails.\n * @internal\n */\nfunction safeJsonStringify(value: unknown): string {\n try {\n return JSON.stringify(value, (_key, val) =>\n typeof val === \"bigint\" ? val.toString() : (val as unknown),\n );\n } catch {\n return String(value);\n }\n}\n\n/**\n * Wraps a text payload as a SAP `TextContent` block, attaching `cache_control` when set.\n * @param text - Pre-escaped text payload.\n * @param cacheControl - Optional Anthropic prompt-cache directive.\n * @returns SAP `TextContent` block.\n */\nfunction wrapAsTextContent(\n text: string,\n cacheControl: CacheControl | undefined,\n): { cache_control?: CacheControl; text: string; type: \"text\" } {\n return cacheControl\n ? { cache_control: cacheControl, text, type: \"text\" }\n : { text, type: \"text\" };\n}\n\n/**\n * @internal\n */\nconst JINJA2_DELIMITERS_PATTERN = /\\{(?=[{%#])/g;\n\n/**\n * @internal\n */\nconst JINJA2_DELIMITERS_ESCAPED_PATTERN = new RegExp(`\\\\{${ZERO_WIDTH_SPACE}([{%#])`, \"g\");\n\n/**\n * @internal\n */\ninterface UserContentItem {\n readonly cache_control?: { ttl?: \"1h\" | \"5m\"; type: \"ephemeral\" };\n readonly file?: {\n readonly file_data: string;\n readonly filename?: string;\n };\n readonly image_url?: {\n readonly url: string;\n };\n readonly text?: string;\n readonly type: \"file\" | \"image_url\" | \"text\";\n}\n\n/**\n * Converts Vercel AI SDK prompt to SAP AI SDK ChatMessage array.\n *\n * Handles all Vercel AI SDK message types:\n * - `system` → `SystemChatMessage`\n * - `user` (text/images) → `UserChatMessage`\n * - `assistant` (text/tool-calls) → `AssistantChatMessage`\n * - `tool` (tool results) → `ToolChatMessage`\n * @param prompt - The Vercel AI SDK LanguageModelV3Prompt to convert.\n * @param options - Conversion options.\n * @param options.escapeTemplatePlaceholders - Whether to escape Jinja2 template delimiters (default: true).\n * @param options.includeReasoning - Whether to include assistant reasoning parts (default: false).\n * @param options.parsePartProviderOptions - Optional callback to read per-part `providerOptions['sap-ai']`. Strategies opt in to honour part-level directives such as Anthropic `cacheControl`.\n * @param options.warnings - Optional sink the parser pushes Zod validation issues into.\n * @returns SAP AI SDK ChatMessage array ready for orchestration requests.\n * @throws {UnsupportedFunctionalityError} When encountering unsupported content types or file formats.\n * @throws {InvalidPromptError} When encountering unsupported message roles.\n */\nexport function convertToSAPMessages(\n prompt: LanguageModelV3Prompt,\n options: ConvertToSAPMessagesOptions = {},\n): ChatMessage[] {\n const messages: ChatMessage[] = [];\n const includeReasoning = options.includeReasoning ?? false;\n const escapeTemplatePlaceholders = options.escapeTemplatePlaceholders ?? true;\n\n const maybeEscape = (text: string): string =>\n escapeTemplatePlaceholders ? escapeOrchestrationPlaceholders(text) : text;\n\n const parser = options.parsePartProviderOptions;\n const parsePart = parser\n ? (providerOptions: unknown) => parser(providerOptions, options.warnings)\n : () => undefined;\n\n for (const message of prompt) {\n switch (message.role) {\n case \"assistant\": {\n let text = \"\";\n const textParts: {\n cacheControl?: { ttl?: \"1h\" | \"5m\"; type: \"ephemeral\" };\n text: string;\n }[] = [];\n let anyCacheControl = false;\n const toolCalls: {\n function: { arguments: string; name: string };\n id: string;\n type: \"function\";\n }[] = [];\n\n for (const part of message.content) {\n switch (part.type) {\n case \"reasoning\": {\n if (includeReasoning && part.text) {\n const escaped = `<think>${maybeEscape(part.text)}</think>`;\n text += escaped;\n textParts.push({ text: escaped });\n }\n break;\n }\n case \"text\": {\n const escaped = maybeEscape(part.text);\n if (!escaped) break;\n const partOpts = parsePart(part.providerOptions);\n const cacheControl = partOpts?.cacheControl;\n text += escaped;\n textParts.push(cacheControl ? { cacheControl, text: escaped } : { text: escaped });\n if (cacheControl) anyCacheControl = true;\n break;\n }\n case \"tool-call\": {\n const partOpts = parsePart(part.providerOptions);\n if (partOpts?.cacheControl && options.warnings) {\n const feature = \"cacheControl on assistant tool-call\";\n if (\n !options.warnings.some((w) => (w as { feature?: string }).feature === feature)\n ) {\n options.warnings.push({\n details:\n \"SAP orchestration does not expose cache_control on the assistant tool-call envelope.\",\n feature,\n type: \"unsupported\",\n });\n }\n }\n // Normalize tool call input to JSON string (Vercel AI SDK provides strings or objects)\n let argumentsJson: string;\n if (typeof part.input === \"string\") {\n argumentsJson = part.input;\n } else {\n argumentsJson = JSON.stringify(part.input);\n }\n\n // Escape tool call arguments if needed (they may contain placeholder syntax)\n toolCalls.push({\n function: {\n arguments: maybeEscape(argumentsJson),\n name: part.toolName,\n },\n id: part.toolCallId,\n type: \"function\",\n });\n break;\n }\n }\n }\n\n if (text || toolCalls.length > 0) {\n const assistantMessage: AssistantChatMessage = {\n content: anyCacheControl\n ? textParts.map((p) => wrapAsTextContent(p.text, p.cacheControl))\n : text,\n role: \"assistant\",\n tool_calls: toolCalls.length > 0 ? toolCalls : undefined,\n };\n messages.push(assistantMessage);\n }\n break;\n }\n\n case \"system\": {\n const partOpts = parsePart(message.providerOptions);\n const cacheControl = partOpts?.cacheControl;\n const text = maybeEscape(message.content);\n const systemMessage: SystemChatMessage = {\n content: cacheControl ? [wrapAsTextContent(text, cacheControl)] : text,\n role: \"system\",\n };\n messages.push(systemMessage);\n break;\n }\n\n case \"tool\": {\n for (const part of message.content) {\n if (part.type === \"tool-result\") {\n const partOpts = parsePart(part.providerOptions);\n const cacheControl = partOpts?.cacheControl;\n const serializedOutput = safeJsonStringify(part.output);\n const escaped = maybeEscape(serializedOutput);\n const toolMessage: ToolChatMessage = {\n content: cacheControl ? [wrapAsTextContent(escaped, cacheControl)] : escaped,\n role: \"tool\",\n tool_call_id: part.toolCallId,\n };\n messages.push(toolMessage);\n }\n }\n break;\n }\n\n case \"user\": {\n const contentParts: UserContentItem[] = [];\n\n for (const part of message.content) {\n const partOpts = parsePart(part.providerOptions);\n const cacheControl = partOpts?.cacheControl;\n switch (part.type) {\n case \"file\": {\n const fileDataUrl = buildDataUrl(part);\n\n if (part.mediaType.startsWith(\"image/\")) {\n const supportedFormats = [\n \"image/png\",\n \"image/jpeg\",\n \"image/jpg\",\n \"image/gif\",\n \"image/webp\",\n ];\n if (!supportedFormats.includes(part.mediaType.toLowerCase())) {\n console.warn(\n `Image format ${part.mediaType} may not be supported by all models. ` +\n `Recommended formats: PNG, JPEG, GIF, WebP`,\n );\n }\n\n contentParts.push({\n ...(cacheControl ? { cache_control: cacheControl } : {}),\n image_url: {\n url: fileDataUrl,\n },\n type: \"image_url\",\n });\n } else {\n contentParts.push({\n ...(cacheControl ? { cache_control: cacheControl } : {}),\n file: {\n file_data: fileDataUrl,\n ...(part.filename ? { filename: part.filename } : {}),\n },\n type: \"file\",\n });\n }\n break;\n }\n case \"text\": {\n contentParts.push({\n ...(cacheControl ? { cache_control: cacheControl } : {}),\n text: maybeEscape(part.text),\n type: \"text\",\n });\n break;\n }\n default: {\n throw new UnsupportedFunctionalityError({\n functionality: `Content type ${(part as { type: string }).type}`,\n });\n }\n }\n }\n\n const firstPart = contentParts[0];\n const userMessage: UserChatMessage =\n contentParts.length === 1 &&\n firstPart?.type === \"text\" &&\n firstPart.cache_control === undefined\n ? {\n content: firstPart.text ?? \"\",\n role: \"user\",\n }\n : {\n content: contentParts,\n role: \"user\",\n };\n\n messages.push(userMessage);\n break;\n }\n\n default: {\n const _exhaustiveCheck: never = message;\n throw new InvalidPromptError({\n message: `Unsupported role: ${(_exhaustiveCheck as { role: string }).role}`,\n prompt: JSON.stringify(message),\n });\n }\n }\n }\n\n return messages;\n}\n\n/**\n * Escapes Jinja2 template delimiters by inserting zero-width spaces.\n *\n * Converts `{{`, `{%`, `{#` to `{\\u200B{`, `{\\u200B%`, `{\\u200B#` respectively.\n * This prevents SAP orchestration from interpreting user content as template syntax.\n * @param text - The text to escape.\n * @returns The escaped text with zero-width spaces inserted.\n * @see {@link unescapeOrchestrationPlaceholders} for the reverse operation.\n */\nexport function escapeOrchestrationPlaceholders(text: string): string {\n if (!text) return text;\n return text.replaceAll(JINJA2_DELIMITERS_PATTERN, `{${ZERO_WIDTH_SPACE}`);\n}\n\n/**\n * Reverses escaping by removing zero-width spaces from template delimiters.\n *\n * Useful for processing model responses that may contain escaped delimiters.\n * @param text - The text to unescape.\n * @returns The unescaped text with zero-width spaces removed.\n * @see {@link escapeOrchestrationPlaceholders} for the escaping operation.\n */\nexport function unescapeOrchestrationPlaceholders(text: string): string {\n if (!text) return text;\n return text.replaceAll(JINJA2_DELIMITERS_ESCAPED_PATTERN, \"{$1\");\n}\n\n/**\n * Builds a data URL from a file part's data and media type.\n *\n * Supports URL, base64 string, Uint8Array, Buffer, and buffer-like objects.\n * @internal\n * @param part - The file part containing data and mediaType.\n * @param part.data - The file data as URL, base64 string, or Uint8Array.\n * @param part.mediaType - The MIME type of the file.\n * @returns The data URL string.\n * @throws {UnsupportedFunctionalityError} If the data type is not supported.\n */\nfunction buildDataUrl(part: { data: string | Uint8Array | URL; mediaType: string }): string {\n if (part.data instanceof URL) {\n return part.data.toString();\n }\n\n if (typeof part.data === \"string\") {\n return `data:${part.mediaType};base64,${part.data}`;\n }\n\n if (part.data instanceof Uint8Array) {\n const base64Data = Buffer.from(part.data).toString(\"base64\");\n return `data:${part.mediaType};base64,${base64Data}`;\n }\n\n if (Buffer.isBuffer(part.data)) {\n const base64Data = Buffer.from(part.data).toString(\"base64\");\n return `data:${part.mediaType};base64,${base64Data}`;\n }\n\n const maybeBufferLike = part.data as unknown;\n\n if (\n maybeBufferLike !== null &&\n typeof maybeBufferLike === \"object\" &&\n \"toString\" in (maybeBufferLike as Record<string, unknown>)\n ) {\n const base64Data = (\n maybeBufferLike as {\n toString: (encoding?: string) => string;\n }\n ).toString(\"base64\");\n return `data:${part.mediaType};base64,${base64Data}`;\n }\n\n throw new UnsupportedFunctionalityError({\n functionality: \"Unsupported file data type. Expected URL, base64 string, or Uint8Array.\",\n });\n}\n"],"mappings":";;;AAQA;AAAA,EACE;AAAA,EAGA;AAAA,OACK;AACP,SAAS,cAAc;AAuCvB,IAAM,mBAAmB;AAazB,SAAS,kBAAkB,OAAwB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