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

Openai embedding endpoint #702

Merged
merged 11 commits into from
Dec 4, 2024
Merged

Openai embedding endpoint #702

merged 11 commits into from
Dec 4, 2024

Conversation

magdyksaleh
Copy link
Collaborator

Adding an OpenAI compatible embedding endpoint.

Also adding a batch embed functionality

Copy link
Contributor

@tgaddair tgaddair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! LGTM!

) -> Result<Json<CompatEmbedResponse>, (StatusCode, Json<ErrorResponse>)> {
metrics::increment_counter!("lorax_request_count");
tracing::debug!("Input: {}", req.input);
if let StringOrVec::Vec(inputs) = req.input {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC what's the difference between string or vec as inputs? Is it the vec just a list of strings and why we have a .map call?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but we need to handle the case that the input is a string or a list of strings. Rust is a bit weird like that. So you need a special type for that. https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-input

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting, good to know!

@magdyksaleh magdyksaleh merged commit 07b77db into main Dec 4, 2024
1 of 2 checks passed
@magdyksaleh magdyksaleh deleted the openai-embedding-endpoint branch December 4, 2024 21:20
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