-
Notifications
You must be signed in to change notification settings - Fork 127
Vector Embeddings: Add example w/ Cloud SDK for AI #1914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise LGTM!
Co-authored-by: Matthias Kuhr <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@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.
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?
).run({ | ||
input: 'How to use vector embeddings in CAP?' | ||
}); | ||
const questionEmbedding = response.getEmbedding(); |
There was a problem hiding this comment.
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?
``` | ||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::: | |
```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.
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..
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 <[email protected]>
…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