Vector Embeddings: Add example w/ Cloud SDK for AI#1914
Conversation
Co-authored-by: Matthias Kuhr <52661546+MatKuhr@users.noreply.github.com>
|
@renejeglinsky could you please review and merge? |
|
I removed the profiled content as we want to reduce the usage of this toggle and maybe even remove it completely. |
| :::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))); | ||
| ``` | ||
| ::: |
There was a problem hiding this comment.
@MattSchur Do you know whom we could ask from the Node.js side to provide an example?
| ).run({ | ||
| input: 'How to use vector embeddings in CAP?' | ||
| }); | ||
| const questionEmbedding = response.getEmbedding(); |
There was a problem hiding this comment.
@MatKuhr AFAIK CAP Node.js expects the vector as String. @johannes-vogel is this still the case?
| new OpenAiEmbeddingRequest(List.of(book.getDescription()))); | ||
| book.setEmbedding(CdsVector.of(response.getEmbeddingVectors().get(0))); | ||
| ``` | ||
| ::: |
There was a problem hiding this comment.
| ::: | |
| ```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
There was a problem hiding this comment.
response.getEmbedding() returns number[]. Why would a string be expected? That seems unexpected to me.. Especially if its a string representation of an array..
There was a problem hiding this comment.
@David-Kunz is the Node runtime still expecting the embedding vector as String?
There was a problem hiding this comment.
@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>
…to vector-embeddings
|
@renejeglinsky can we merge this PR with this release and update the Node.js examples with another PR? |
Adds example code and link to SAP Cloud SDK for AI