@sap-ai-sdk/document-grounding 1.11.1-20250414013204.0 → 1.11.1-20250415013200.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -92
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,13 +10,7 @@ This package incorporates generative AI document grounding capabilities into you
|
|
|
10
10
|
### Table of Contents
|
|
11
11
|
|
|
12
12
|
- [Installation](#installation)
|
|
13
|
-
- [
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [Create a Collection](#create-a-collection)
|
|
16
|
-
- [Create a Document](#create-a-document)
|
|
17
|
-
- [Custom Destination](#custom-destination)
|
|
18
|
-
- [Error Handling](#error-handling)
|
|
19
|
-
- [Local Testing](#local-testing)
|
|
13
|
+
- [Documentation](#documentation)
|
|
20
14
|
- [Support, Feedback, Contribution](#support-feedback-contribution)
|
|
21
15
|
- [License](#license)
|
|
22
16
|
|
|
@@ -26,92 +20,9 @@ This package incorporates generative AI document grounding capabilities into you
|
|
|
26
20
|
$ npm install @sap-ai-sdk/document-grounding
|
|
27
21
|
```
|
|
28
22
|
|
|
29
|
-
##
|
|
23
|
+
## Documentation
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
- Configure the project with **Node.js v20 or higher** and **native ESM** support.
|
|
33
|
-
|
|
34
|
-
> **Accessing the AI Core Service via the SDK**
|
|
35
|
-
>
|
|
36
|
-
> The SDK automatically retrieves the `AI Core` service credentials and resolves the access token needed for authentication.
|
|
37
|
-
>
|
|
38
|
-
> - In Cloud Foundry, it's accessed from the `VCAP_SERVICES` environment variable.
|
|
39
|
-
> - In Kubernetes / Kyma environments, you have to mount the service binding as a secret instead, for more information refer to [this documentation](https://www.npmjs.com/package/@sap/xsenv#usage-in-kubernetes).
|
|
40
|
-
|
|
41
|
-
## Usage
|
|
42
|
-
|
|
43
|
-
The examples below demonstrate the usage of the most commonly used APIs in SAP AI Core document grounding service.
|
|
44
|
-
In addition to the examples below, you can find more **sample code** [here](https://github.com/SAP/ai-sdk-js/blob/main/sample-code/src/document-grounding.ts).
|
|
45
|
-
|
|
46
|
-
> Ensure that if you define your own resource group, it has the correct label to use the document grounding service.
|
|
47
|
-
> When creating the resource group on SAP AI Launchpad, add the key-value pair label: `document-grounding: true`.
|
|
48
|
-
> Alternatively, you can create the resource group via the orchestration API.
|
|
49
|
-
> For more details, refer to the [Creating a Resource Group for Grounding](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-resource-group-for-ai-data-management?locale=en-US) guide.
|
|
50
|
-
|
|
51
|
-
### Create a Collection
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
const response = await VectorApi.createCollection(
|
|
55
|
-
{
|
|
56
|
-
title: 'ai-sdk-js-e2e',
|
|
57
|
-
embeddingConfig: {
|
|
58
|
-
modelName: 'text-embedding-3-small'
|
|
59
|
-
},
|
|
60
|
-
metadata: []
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
'AI-Resource-Group': 'default'
|
|
64
|
-
}
|
|
65
|
-
).executeRaw();
|
|
66
|
-
|
|
67
|
-
const collectionId = (response.headers.location as string).split('/').at(-2);
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Create a Document
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
const response: DocumentsListResponse = await VectorApi.createDocuments(
|
|
74
|
-
collectionId,
|
|
75
|
-
{
|
|
76
|
-
documents: [
|
|
77
|
-
{
|
|
78
|
-
metadata: [],
|
|
79
|
-
chunks: [
|
|
80
|
-
{
|
|
81
|
-
content:
|
|
82
|
-
'SAP Cloud SDK for AI is the official Software Development Kit (SDK) for SAP AI Core, SAP Generative AI Hub, and Orchestration Service.',
|
|
83
|
-
metadata: []
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
'AI-Resource-Group': 'default'
|
|
91
|
-
}
|
|
92
|
-
).execute();
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Custom Destination
|
|
96
|
-
|
|
97
|
-
When calling the `execute()` method, it is possible to provide a custom destination.
|
|
98
|
-
For example, when querying deployments targeting a destination with the name `my-destination`, the following code can be used:
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
const response = await VectorApi.deleteCollectionById(collectionId, {
|
|
102
|
-
'AI-Resource-Group': 'default'
|
|
103
|
-
}).execute({
|
|
104
|
-
destinationName: 'my-destination'
|
|
105
|
-
});
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Error Handling
|
|
109
|
-
|
|
110
|
-
For error handling instructions, refer to this [section](https://github.com/SAP/ai-sdk-js/blob/main/README.md#error-handling).
|
|
111
|
-
|
|
112
|
-
## Local Testing
|
|
113
|
-
|
|
114
|
-
For local testing instructions, refer to this [section](https://github.com/SAP/ai-sdk-js/blob/main/README.md#local-testing).
|
|
25
|
+
Visit the [SAP Cloud SDK for AI (JavaScript)](https://sap.github.io/ai-sdk/docs/js/overview-cloud-sdk-for-ai-js) documentation portal to learn more about its capabilities and detailed usage.
|
|
115
26
|
|
|
116
27
|
## Support, Feedback, Contribution
|
|
117
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ai-sdk/document-grounding",
|
|
3
|
-
"version": "1.11.1-
|
|
3
|
+
"version": "1.11.1-20250415013200.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"internal.d.ts"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@sap-ai-sdk/core": "^1.11.1-
|
|
25
|
+
"@sap-ai-sdk/core": "^1.11.1-20250415013200.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"compile": "tsc",
|