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

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

Merged
merged 3 commits into from
Dec 24, 2024

Conversation

elk-cloner
Copy link
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
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
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 ggerganov:master Dec 24, 2024
50 checks passed
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