Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sap-ai-sdk/document-grounding

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap-ai-sdk/document-grounding

> [!warning] > This package is still in **beta** and is subject to breaking changes. Use it with caution.

  • 1.4.1-20241222013110.0
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@sap-ai-sdk/document-grounding

[!warning] This package is still in beta and is subject to breaking changes. Use it with caution.

SAP Cloud SDK for AI is the official Software Development Kit (SDK) for SAP AI Core, SAP Generative AI Hub, and Orchestration Service.

This package incorporates generative AI document grounding capabilities into your AI activities in SAP AI Core and SAP AI Launchpad.

Table of Contents

  • Installation
  • Prerequisites
  • Usage
  • Local Testing
  • Support, Feedback, Contribution
  • License

Installation

$ npm install @sap-ai-sdk/document-grounding

Prerequisites

Accessing the AI Core Service via the SDK

The SDK automatically retrieves the AI Core service credentials and resolves the access token needed for authentication.

  • In Cloud Foundry, it's accessed from the VCAP_SERVICES environment variable.
  • In Kubernetes / Kyma environments, you have to mount the service binding as a secret instead, for more information refer to this documentation.

Usage

The examples below demonstrate the usage of the most commonly used APIs in SAP AI Core document grounding service. In addition to the examples below, you can find more sample code here.

Create a Collection

import
const response =
  await CollectionsApi.vectorV1VectorEndpointsCreateCollection(
    {
      title: 'ai-sdk-js-e2e',
      embeddingConfig: {
        modelName: 'text-embedding-ada-002-v2'
      },
      metadata: []
    },
    {
      'AI-Resource-Group': 'default'
    }
  ).executeRaw();

const collectionId = (response.headers.location as string).split('/').at(-2);

Create a Document

const response: DocumentsListResponse =
  await DocumentsApi.vectorV1VectorEndpointsCreateDocuments(
    collectionId,
    {
      documents: [
        {
          metadata: [],
          chunks: [
            {
              content:
                'SAP Cloud SDK for AI is the official Software Development Kit (SDK) for SAP AI Core, SAP Generative AI Hub, and Orchestration Service.',
              metadata: []
            }
          ]
        }
      ]
    },
    {
      'AI-Resource-Group': 'default'
    }
  ).execute();

Custom Destination

When calling the execute() method, it is possible to provide a custom destination. For example, when querying deployments targeting a destination with the name my-destination, the following code can be used:

const response = await CollectionsApi.vectorV1VectorEndpointsDeleteCollection(
  collectionId,
  {
    'AI-Resource-Group': 'default'
  }
).execute({
  destinationName: 'my-destination'
});

Local Testing

For local testing instructions, refer to this section.

Support, Feedback, Contribution

Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.

License

The SAP Cloud SDK for AI is released under the Apache License Version 2.0.

Keywords

FAQs

Package last updated on 22 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc