npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cap-js/ai

v1.2.0

Published

CAP cds-plugin for AI capabilities

Readme

REUSE status

CAP AI plugin for Node.js

@cap-js/ai adds UI recommendations powered by SAP AI Core, simplified access to SAP AI Core resources, and vector embedding support for CAP applications.

Recommendations

The plugin adds SAP-RPT-1 recommendations to draft-enabled entities. Fields with a value help are included automatically:

@odata.draft.enabled
entity Books {
  key ID    : Integer;
      title : String;
      genre : Association to Genres;
      price : Decimal;
}

annotate Genres with @cds.odata.valuelist;

Recommendations as default values

Use @UI.RecommendationState to opt individual fields in or out:

annotate Books with {
  genre @UI.RecommendationState: 0;
  price @UI.RecommendationState;
}

A production deployment requires an SAP AI Core service binding. Without one, local development uses a mock implementation for UI smoke tests. See Recommendations for regression targets, request behavior, data handling, and deployment lifecycle.

SAP AI Core

The plugin provides an AICore CAP service for managing resource groups, deployments, and configurations:

const aiCore = await cds.connect.to('AICore');
const { resourceGroups, deployments } = aiCore.entities;

const groups = await aiCore.run(SELECT.from(resourceGroups));
await aiCore.stop(deployments, { id: '<deployment id>' });

See SAP AI Core integration for setup, supported queries, helper methods, and multitenancy.

Local vector embeddings with SQLite (experimental)

[!WARNING] The SQLite extensions, local vector embeddings, local model management, and the related tooling are experimental facilities for local development. Breaking changes are expected, including changes caused by SQLite's synchronous function interface and by local model management. Use SAP HANA's vector engine for production vector workloads.

@cap-js/ai redirects the standard sqlite database so that VECTOR_EMBEDDING and the vector functions run locally against a real ONNX model — no external service, and no code changes versus SAP HANA. This lets you develop and test semantic search on SQLite. The following searches Bookshop's books by the meaning of their descriptions.

  1. Install the local-development dependencies:

    npm add -D @cap-js/ai @cap-js/sqlite@^3.1 @huggingface/hub@^2.15.0 \
      @huggingface/[email protected] [email protected]

    This requires @sap/cds ^10.1 and @cap-js/sqlite ^3.1 (the package's other capabilities still support @sap/cds 9). No configuration is needed: the standard sqlite and sqlite:memory databases pick up the local implementation automatically.

  2. Expose the search as an OData function. It ranks books by the cosine similarity between an embedded search phrase and each book's embedded description:

    using { sap.capire.bookshop.Books } from '@capire/bookshop';
    
    service SearchService {
      function searchBooks(phrase : String) returns array of {
        title : String;
        relevance : Double;
      };
    }
    const cds = require('@sap/cds')
    
    module.exports = class SearchService extends cds.ApplicationService { init() {
      this.on('searchBooks', ({ data: { phrase } }) =>
        SELECT.from('sap.capire.bookshop.Books')
          .columns`title, cosine_similarity(
            vector_embedding(descr, 'DOCUMENT', 'SAP_GXY.20250407'),
            vector_embedding(${phrase}, 'QUERY', 'SAP_GXY.20250407')) as relevance`
          .orderBy`relevance desc`
      )
      return super.init()
    }}

    The model name is ignored on SQLite — the locally configured model is used — and honored on SAP HANA, so the same query runs unchanged on both. This embeds every book's description on each request; for repeated searches, persist the embeddings instead (see Local vector embeddings).

  3. Run the app and call the function:

    cds watch

    In another terminal:

    curl "http://localhost:4004/odata/v4/search/searchBooks(phrase='a%20haunting%20poem%20about%20lost%20love')"

On the first start, @cap-js/ai warns if the configured model is missing, downloads it to .cds/models, and initializes it; later starts reuse it. The function returns the books ranked by relevance to the phrase.

The current default is sentence-transformers/all-MiniLM-L6-v2, chosen only as the most-downloaded reasonably small model matching the sentence-similarity task, ONNX format, and Apache-2.0 license. This is not a recommendation and may change while the feature is experimental — set cds.requires.db.embedding.model to pin it. Browse alternatives among trending Apache-2.0 sentence-similarity models with ONNX artifacts, then validate your choice with the provided tooling.

See Choosing a model and Local vector embeddings for compatibility checks, explicit or shared provisioning, runtime behavior, and limitations.

Advanced

Test the plugin locally

The sample application is in tests/bookshop.

npm test

Integration tests require an SAP AI Core binding:

cds bind ai-core -2 <your-ai-core-service-instance>
npm run test:hybrid

Support, feedback, and contributing

This project welcomes feature requests, bug reports, and contributions through GitHub issues. See the Contribution Guidelines for development information.

Security

Report potential security issues through the project's security policy, not through public issues.

Code of Conduct

Participation in this project is governed by the Code of Conduct.

Licensing

Copyright 2026 SAP SE or an SAP affiliate company and ai contributors. See LICENSE and the REUSE report.