-
Notifications
You must be signed in to change notification settings - Fork 44
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"}}
New Features ============ * Support EdgeDB 5.0 "branch" connection option (by @vpetrovykh in #484 #485 #487) * Support EdgeDB 5.0 AI extension (by @fantix in #489 #490) Breaking Changes ================ * Enum values can now compare to user-defined enums successfully (#425) (by @fantix in bb7522c for #419) * Add optional default to codegen params (#426) (by @fantix in 21b024a for #422) Changes ======= * blocking client: fix connect and timeout, support IPv6 (#499) (by @fantix @zachary822 in 28a83fd for #486) Fixes ===== * Add test to check setting a computed global using with_globals. (#494) (by @dnwpark in 636bc0e for #494) * Fix test and add Python 3.12 in CI (by @fantix in #498 #503) * Use result of pydantic_dataclass, will silence linters (#501) (by @AdrienPensart in d88187a) * Extract ExecuteContext as in/out argument (#500) (by @fantix in 2fb7965 for #493)
New Features ============ * Support EdgeDB 5.0 "branch" connection option (by @vpetrovykh in #484 #485 #487) * Support EdgeDB 5.0 AI extension (by @fantix in #489 #490) Breaking Changes ================ * Enum values can now compare to user-defined enums successfully (#425) (by @fantix in bb7522c for #419) * Add optional default to codegen params (#426) (by @fantix in 21b024a for #422) Changes ======= * blocking client: fix connect and timeout, support IPv6 (#499) (by @fantix @zachary822 in 28a83fd for #486) Fixes ===== * Add test to check setting a computed global using with_globals. (#494) (by @dnwpark in 636bc0e for #494) * Fix test and add Python 3.12 in CI (by @fantix in #498 #503) * Use result of pydantic_dataclass, will silence linters (#501) (by @AdrienPensart in d88187a) * Extract ExecuteContext as in/out argument (#500) (by @fantix in 2fb7965 for #493)
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.