Skip to content

Vector Embeddings: Add example w/ Cloud SDK for AI#1914

Merged
MattSchur merged 12 commits into
mainfrom
vector-embeddings
Jul 2, 2025
Merged

Vector Embeddings: Add example w/ Cloud SDK for AI#1914
MattSchur merged 12 commits into
mainfrom
vector-embeddings

Conversation

@MattSchur

Copy link
Copy Markdown
Contributor

Adds example code and link to SAP Cloud SDK for AI

@MattSchur MattSchur requested a review from renejeglinsky as a code owner June 10, 2025 14:10
@MattSchur MattSchur requested a review from agoerler June 10, 2025 14:14

@MatKuhr MatKuhr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM!

Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
Co-authored-by: Matthias Kuhr <52661546+MatKuhr@users.noreply.github.com>
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
@MattSchur MattSchur requested a review from MatKuhr June 11, 2025 06:53

@MatKuhr MatKuhr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
@MattSchur MattSchur enabled auto-merge June 13, 2025 08:39
@MattSchur MattSchur removed the request for review from agoerler June 17, 2025 08:14
@MattSchur

Copy link
Copy Markdown
Contributor Author

@renejeglinsky could you please review and merge?

Comment thread guides/databases-hana.md
@renejeglinsky

Copy link
Copy Markdown
Contributor

I removed the profiled content as we want to reduce the usage of this toggle and maybe even remove it completely.

Comment thread guides/databases-hana.md
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md Outdated
@MattSchur MattSchur requested a review from renejeglinsky June 23, 2025 09:25
Comment thread guides/databases-hana.md Outdated
Comment thread guides/databases-hana.md
Comment on lines +278 to +285
:::details Example using SAP Cloud SDK for AI
```Java
var aiClient = OpenAiClient.forModel(OpenAiModel.TEXT_EMBEDDING_3_SMALL);
var response = aiClient.embedding(
new OpenAiEmbeddingRequest(List.of(book.getDescription())));
book.setEmbedding(CdsVector.of(response.getEmbeddingVectors().get(0)));
```
:::

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MattSchur Do you know whom we could ask from the Node.js side to provide an example?

Comment thread guides/databases-hana.md
).run({
input: 'How to use vector embeddings in CAP?'
});
const questionEmbedding = response.getEmbedding();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatKuhr AFAIK CAP Node.js expects the vector as String. @johannes-vogel is this still the case?

Comment thread guides/databases-hana.md
new OpenAiEmbeddingRequest(List.of(book.getDescription())));
book.setEmbedding(CdsVector.of(response.getEmbeddingVectors().get(0)));
```
:::

@MattSchur MattSchur Jun 23, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:::
```js [Node.js]
const response = await new AzureOpenAiEmbeddingClient(
'text-embedding-3-small'
).run({
input: bookDescription
});
const embedding = response.getEmbedding();
/```
:::

@MatKuhr is this correct? In CAP Node.js the vector embedding needs to be a string '[0.3,0.7,0.1,...]' @johannes-vogel please double check

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.getEmbedding() returns number[]. Why would a string be expected? That seems unexpected to me.. Especially if its a string representation of an array..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@David-Kunz is the Node runtime still expecting the embedding vector as String?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johannes-vogel @David-Kunz Any input from your side? Otherwise we merge w/o a Node.js version today evening.

Co-authored-by: René Jeglinsky <rene.jeglinsky@sap.com>
@MattSchur MattSchur requested a review from johannes-vogel June 24, 2025 15:59
@MattSchur MattSchur requested a review from David-Kunz June 25, 2025 15:14
@MattSchur

Copy link
Copy Markdown
Contributor Author

@renejeglinsky can we merge this PR with this release and update the Node.js examples with another PR?

@MattSchur MattSchur added this pull request to the merge queue Jul 2, 2025
Merged via the queue into main with commit 4525c8d Jul 2, 2025
4 checks passed
@MattSchur MattSchur deleted the vector-embeddings branch July 2, 2025 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants