- Notifications
You must be signed in to change notification settings - Fork328
Embeddings support in the SDK#1475
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
.map(|v| { | ||
v.as_str() | ||
.with_context(|| "only text embeddings are supported") | ||
.unwrap() |
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.
You can collect into aResult<Vec<_>>
so you can?
theResult
instead of panicking if the value is not astr
.
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.
Something like
let texts = texts.0.as_array().with_context(||"embed_batch takes an array of texts")?.iter().map(|v|{ v.as_str().with_context(||"only text embeddings are supported").map(|s| s.to_string())}).collect::<anyhow::Result<Vec<String>>>()?;
I think will work.
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.
I don't think we want that. The API accepts an array of strings, so if someone passes in an array of objects that can be cast to a string, they will get embeddings of integers, or whatever else they passed in, which will make them think that everything is fine.
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.
We are still callingas_str
here so if it was an object, it wouldn't be treated as a string. I was merely suggesting usingResult::Err
instead ofunwrap
. But all is good.
SilasMarvin commentedMay 22, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
A test for both in Rust, Python, and JavaScript would be nice |
Do these tests run in CI or only locally? They require a PostgresML installation to be running somewhere right? |
I can't seem to find instructions for setting up the JS environment for testing this. I did the Python one from memory, but it would be nice to have a short README for developers. I'm going to skip the JS tests for now and come back to them when I have a moment. |
SDK
pgml.embed()
support intoBuiltins
, with single and batch mode.