feat: OpenAI-compatible /api/embeddings endpoint with provider-agnostic OpenWebUI architecture#14667
feat: OpenAI-compatible /api/embeddings endpoint with provider-agnostic OpenWebUI architecture#14667tjbck merged 7 commits intoopen-webui:devfrom
/api/embeddings endpoint with provider-agnostic OpenWebUI architecture#14667Conversation
/api/embeddings endpoint with provider-agnostic OpenWebUI architecture
|
Funny, I added a comment to #13898 just one hour ago, hoping for it to get picked up again. But this PR looks much cleaner at a first glance, very nice! |
Yes, I hope this PR meets the author's quality requirements. Let's cross finger... |
|
It seems to be well separated and maintainable code, so I'm going to use it anyway. 😅 I really want this for our users. |
|
Hi @Ithanil, The code with your suggestions has been pushed. Thanks for your feedback. |
|
Tested your implementation both with your suggested Python code as well as the Continue.dev Extension for VSCode. Works for admin user as well as regular user, but only if he has access to the embeddings model. Perfect! |
|
Amazing addition, will refactor here and there but this can be merged as it is! Thanks for the hard work! |
|
Thank you @tjbck! Your kind words motivate me to keep working hard and to continue loving coding while contributing to the open source community. |
|
It doesn't seem to be working with embedding models through external API instead of local Ollama. Would you be able to help that out? |
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
In this PR, I solve this feature request.
With this PR, a new endpoint
/api/embeddingsis introduced to the backend, enabling direct access to the embeddings functionality. This route is fully compatible with OpenAI, Ollama, and pipeline-based embedding providers available in Open WebUI, while preserving the existing/openai/embeddingsroute for backward compatibility. This enhancement streamlines integration by providing a unified and intuitive API for generating embeddings across multiple backends.There's a big difference with my previous, I follow the suggestion of the author in this comment:
For this, my PR:
/api/embeddingsendpoint following the OpenWebUI generic dispatch pattern.Added
/api/embeddingsthat maps to the existing OpenAI embeddings functionalityutils/embeddings.pymodeled afterutils/chat.py.Changed
/api/embeddingsendpoint inmain.pyto use the new, extensible dispatch system.Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Python code used for testing:
Response gotten:
Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.