Skip to content

server : add support for "encoding_format": "base64" to the */embeddings endpoints - #10967

Merged
ngxson merged 3 commits into
ggml-org:masterfrom
elk-cloner:openai_base64
Dec 24, 2024
Merged

ngxson merged 3 commits into
ggml-org:masterfrom
elk-cloner:openai_base64

Conversation

@elk-cloner

Copy link
Copy Markdown
Contributor

Add base64 encoding format support for embeddings endpoints

Overview

This PR implements support for base64 format in embedding responses, aligning with OpenAI's API functionality and improving payload efficiency.

Changes

  • Added encoding_format parameter support to embedding endpoints
  • Implemented base64 encoding for embedding vectors when specified
  • Updated response handling to support both float and base64 formats
  • Added tests to verify base64 encoding functionality

Related Issue

Closes #10887

@elk-cloner
elk-cloner requested a review from ngxson as a code owner December 24, 2024 15:06
@github-actions github-actions Bot added examples python python script changes server labels Dec 24, 2024
assert len(floats) > 0
assert all(isinstance(x, float) for x in floats)
except Exception as e:
pytest.fail(f"Invalid base64 format: {str(e)}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's a bad practice to use try..catch inside a test, because if one of the assert fails, it won't let you know it happens at exactly which line of code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ngxson, thanks for the hint. my bad, I forgot to remove it.

@ngxson ngxson changed the title Add support for "encoding_format": "base64" to the */embeddings endpoints server : add support for "encoding_format": "base64" to the */embeddings endpoints Dec 24, 2024
@ngxson
ngxson merged commit 9ba399d into ggml-org:master Dec 24, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Feb 26, 2025
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples python python script changes server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: support "encoding_format": "base64" in the */embeddings endpoints

2 participants