{"id":20484497,"url":"https://github.com/sap-samples/cap-ai-vector-engine-sample","last_synced_at":"2025-09-07T01:35:23.161Z","repository":{"id":241268022,"uuid":"803883300","full_name":"SAP-samples/cap-ai-vector-engine-sample","owner":"SAP-samples","description":"This repository contains sample code for a CAP application utilizing the CAP-LLM-Plugin to establish a connection to SAP AI Core and SAP HANA Cloud for creating and storing vector embeddings, perform similarity searches and requesting RAG responses. ","archived":false,"fork":false,"pushed_at":"2025-03-17T09:54:50.000Z","size":783,"stargazers_count":14,"open_issues_count":3,"forks_count":8,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-13T14:48:53.651Z","etag":null,"topics":["ai","cap","cloud-application-programming-model","gen-ai","hana-cloud","sap-btp"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-21T14:45:37.000Z","updated_at":"2025-04-04T03:37:09.000Z","dependencies_parsed_at":"2025-04-13T14:43:29.578Z","dependency_job_id":"004b1cd7-15cb-4e68-9090-8d0ebcca51f0","html_url":"https://github.com/SAP-samples/cap-ai-vector-engine-sample","commit_stats":null,"previous_names":["sap-samples/cap-ai-vector-engine-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SAP-samples/cap-ai-vector-engine-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fcap-ai-vector-engine-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fcap-ai-vector-engine-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fcap-ai-vector-engine-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fcap-ai-vector-engine-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP-samples","download_url":"https://codeload.github.com/SAP-samples/cap-ai-vector-engine-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fcap-ai-vector-engine-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273986614,"owners_count":25202704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","cap","cloud-application-programming-model","gen-ai","hana-cloud","sap-btp"],"created_at":"2024-11-15T16:23:18.746Z","updated_at":"2025-09-07T01:35:23.129Z","avatar_url":"https://github.com/SAP-samples.png","language":"JavaScript","readme":"# CAP with SAP HANA Vector Engine \u0026 SAP Core AI\n\n[![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/cap-ai-vector-engine-sample)](https://api.reuse.software/info/github.com/SAP-samples/cap-ai-vector-engine-sample)\n\n## Description\nThis repository contains a code sample on how to build a Cloud Application Programming Model application exposing functionality of SAP AI Core and SAP HANA Cloud Vector Engine using the CAP LLM Plugin. The code also shows how a developer can leverage vector embeddings to provide contextual information to an LLM.\n\nFor more information about the end-to-end scenario, take a look at the [architecture documentation](/documentation/architecture.md).\n\nIf you want an instructional experience learning about the CAP LLM Plugin, SAP AI Core and SAP Generative AI Hub follow the [Expose capabilities of SAP AI Core with the SAP Cloud Application Programming Model CodeJam](https://github.com/SAP-samples/codejam-cap-llm/tree/main).\n\n## Requirements\n* A suitable IDE like Visual Studio Code or Neovim\n* Install the [Cloud Foundry CLI](https://developers.sap.com/tutorials/cp-cf-download-cli.html)\n* Install the [hana-cli](https://github.com/SAP-samples/hana-developer-cli-tool-example) (optional)\n* Create an [SAP BTP account](https://help.sap.com/docs/btp/sap-business-technology-platform/trial-accounts-and-free-tier)\n* Create an instance of [SAP HANA Cloud](https://developers.sap.com/tutorials/hana-cloud-deploying.html).\n* Create an instance of [SAP AI Core](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-service-instance)\n* Create [deployments](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-deployment-for-generative-ai-model-in-sap-ai-core) for model support ChatCompletion `gpt-35-turbo or gpt-4` and embedding model `text-embedding-ada-002`\n* Create a [destination](https://help.sap.com/docs/btp/sap-business-technology-platform/create-destination) for Generative AI Hub in the SAP BTP Cockpit of your subaccount based on the Service Key of SAP AI Core:\n```\nName: GENERATIVE_AI_HUB\nDescription: SAP AI Core deployed service (generative AI hub)\nURL: \u003cAI-API-OF-AI-CORE-SERVICE-KEY\u003e/v2 # make sure to add /v2!\nType: HTTP\nProxyType: Internet\nAuthentication: OAuth2ClientCredentials\ntokenServiceURL: \u003cTOKEN-SERVICE-URL-OF-AI-CORE-SERVICE-KEY\u003e/oauth/token\nclientId: \u003cYOUR-CLIENT-ID-OF-AI-CORE-SERVICE-KEY\u003e\nclientSecret: \u003cYOUR-CLIENT-SECRET-OF-AI-CORE-SERVICE-KEY\u003e\n# Additional Properties:\nURL.headers.AI-Resource-Group: default # adjust if necessary\nURL.headers.Content-Type: application/json\nHTML5.DynamicDestination: true\n```\n* The SAP BTP account needs the following entitlements:\n\n| Name              | Service/Application | Plan |\n| :---------------- | :------ | :---- |\n| AI Core        |   `aicore`   | `extended` |\n| AI Launchpad           |   `ai-launchpad`   | `standard` |\n| HANA Cloud    |  `hana-cloud`   | `hana` |\n| SAP HANA Schemas \u0026 HDI Containers    |  `hdi-shared`   | `free` |\n\n## Download and Installation\n1. Clone this GitHub repository to your local machine and open it in VS Code or any other suitable editor.\n2. Run `npm install` in the root to install all dependencies\n3. Connect to your SAP BTP subaccount:  \n`cf login -a \u003csubaccount-endpoint\u003e`\n4. Bind the following services to the application:  \n    - SAP HDI instance, hdi-shared\n    `cds bind --to \u003chdi-shared-instance\u003e:\u003cservice-key-name\u003e`\n    - SAP BTP, Destination Service  \n    `cds bind --to \u003cdestination\u003e`\n5. Build the database artifacts for the SAP HANA Cloud deployment:  \n`cds build --for hana`\n6. Deploy database artifacts to SAP HANA Cloud:  \n`cds deploy --to hana:\u003chdi-shared-service-instance\u003e`\n7. For [hybrid testing](https://cap.cloud.sap/docs/advanced/hybrid-testing) execute:  \n`cds watch --profile hybrid`\n\n## How to use the application\nTo properly run through the use case there are four API endpoints you can call which can be found in the [API Documentation](documentation/api-documentation.md).\n\nThere are two services defined in this CAP application:\n\n* The **Embedding Storage**; includes the input text chunking, creation of vector embeddings, storing and deletion of the vector embeddings in the SAP HANA Cloud vector engine.\n* The **Roadshow Service**; includes calls for retrieving the RAG response and execution of a similarity search.\n\n## Further Information\n* [Generative AI Hub TechBytes sample](https://github.com/SAP-samples/sap-tech-bytes/tree/2024-29-01-generative-ai-hub)\n* [CAP LLM Plugin samples](https://github.com/SAP-samples/cap-llm-plugin-samples/)\n* [CAP LLM Plugin npm](https://www.npmjs.com/package/cap-llm-plugin)\n* [CAP Vector Embeddings](https://cap.cloud.sap/docs/guides/databases-hana#vector-embeddings)\n* [Retrieval Augmented Generation with GenAI on SAP BTP](https://discovery-center.cloud.sap/refArchDetail/ref-arch-open-ai)\n* [What is SAP AI Core?](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/what-is-sap-ai-core)\n* [Combine the Power of AI with Business Context Using SAP HANA Cloud Vector Engine](https://news.sap.com/2024/04/sap-hana-cloud-vector-engine-ai-with-business-context/)\n\n## Known Issues\nNo known issues.\n\n## How to obtain support\n[Create an issue](https://github.com/SAP-samples/\u003crepository-name\u003e/issues) in this repository if you find a bug or have questions about the content.\n \nFor additional support, [ask a question in SAP Community](https://answers.sap.com/questions/ask.html).\n\n## Contributing\nIf you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses [the standard DCO text of the Linux Foundation](https://developercertificate.org/).\n\n## License\nCopyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap-samples%2Fcap-ai-vector-engine-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap-samples%2Fcap-ai-vector-engine-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap-samples%2Fcap-ai-vector-engine-sample/lists"}