-
Notifications
You must be signed in to change notification settings - Fork 43
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
Expose embeddings API #490
Conversation
edgedb/ai/core.py
Outdated
stream=True, | ||
).to_httpx_request(), | ||
) as event_source: | ||
event_source.response.raise_for_status() | ||
for sse in event_source.iter_sse(): | ||
yield sse.data | ||
|
||
def generate_custom_embeddings(self, *inputs: str, model: str): |
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.
working on the JS version of this but my instinct was to name this generateEmbeddings
. Is there a significance to the "custom" here? Does it help to denote that these are not the automatically indexed ones?
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.
Yeah, that was my intention, but I'm not sure this "custom" makes sense (like in English).
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 wonder if custom
communicates enough to pay for the cost. search
would be even more specific and point at the intended use case, but maybe that's too restrictive since you might use it outside of ext::ai::search
? Does generate_embeddings
make it seem too much like you're triggering something rather than doing this one-off embedding generation?
The only reason I ask is that having "custom" here would make me as a developer want to know more about what "custom" means and what other non-custom methods their might be. Maybe that's a good thing and worth adding here, but it feels a little like an unnecessary mental speed bump.
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.
Does
generate_embeddings
make it seem too much like you're triggering something rather than doing this one-off embedding generation?
Yeah, I had the same struggle. I thought about retrieve_embeddings()
, which is just worse. (maybe generate_oneoff_embeddings()
?)
Maybe that's a good thing and worth adding here, but it feels a little like an unnecessary mental speed bump.
Right, I'll also change it to generate_embeddings()
and add an explanation in the docs.
): | ||
if context is None: | ||
context = self.context | ||
) -> typing.Iterator[str]: |
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.
This returned str
is a JSON string like:
{"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " blocking"}}
This PR adds
EdgeDBAI.generate_embeddings()
function to allow users to generate embedding vectors without using the AI index in EdgeDB with custom input text.I'll create another PR to add docs.