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

Python code defaults to 'base64' encoding_format in the embeddings endpoint, but docs say it should be 'float' #1490

Open
1 task done
hillarysanders opened this issue Jun 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@hillarysanders
Copy link

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Hi, your docs say that the default encoding_format in your embeddings/create endpoint is float, however your python package code applies a default of 'base64' when a value isn't supplied.

Can you switch this to 'float' so the python package is conformant with your docs?

To Reproduce

Run an OpenAI embeddings query with the python client:

import openai
client = openai.OpenAI(...)
response = client.embeddings.create(
   model=<model>,
   input="I am a string to embed!",
   # notably, NOT specifying encoding_format here
) 

Uses base64 encoding instead of float, oddly.

Code snippets

NA

OS

macOS

Python version

3.12.3

Library version

1.35.0

@hillarysanders hillarysanders added the bug Something isn't working label Jun 19, 2024
@dgellow
Copy link

dgellow commented Jun 21, 2024

Hi @hillarysanders,

Thanks for reporting this, very good catch. Let me try to figure out where the issue is coming from, the OpenAPI spec we are using as the source to generate the SDK does indeed specify float as the default value.

@RobertCraigie
Copy link
Collaborator

@hillarysanders The Python SDK should only default to base64 if you don't specify an encoding_format & have numpy installed.

We do this as it's more performant for the API to response with base64 & then decode directly in the SDK than to receive floats from the API.

Did you run into any issues here or would an update to the docs mentioning this behaviour suffice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants