Skip to content
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

Merged
merged 5 commits into from
May 28, 2024
Merged

Expose embeddings API #490

merged 5 commits into from
May 28, 2024

Conversation

fantix
Copy link
Member

@fantix fantix commented May 1, 2024

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.

@fantix fantix requested review from 1st1 and elprans May 1, 2024 16:55
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):

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?

Copy link
Member Author

@fantix fantix May 1, 2024

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).

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.

Copy link
Member Author

@fantix fantix May 1, 2024

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.

edgedb/ai/core.py Outdated Show resolved Hide resolved
):
if context is None:
context = self.context
) -> typing.Iterator[str]:
Copy link
Member Author

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"}}

@fantix fantix requested a review from elprans May 2, 2024 22:19
@fantix fantix merged commit 7386cd0 into master May 28, 2024
42 checks passed
@fantix fantix deleted the ai branch May 28, 2024 15:18
fantix added a commit that referenced this pull request Jun 19, 2024
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)
@fantix fantix mentioned this pull request Jun 19, 2024
fantix added a commit that referenced this pull request Jun 19, 2024
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants