-
Notifications
You must be signed in to change notification settings - Fork 114
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
change embedding response object to list for openai compatibility #444
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Changes the OpenAI embedding response object type from 'embedding' to 'list' to align with OpenAI's API specification, improving compatibility with external services like KubeAI.
- Changed
object
field enum/const from 'embedding' to 'list' in/docs/assets/openapi.json
OpenAIEmbeddingResult schema - Updated
OpenAIEmbeddingResult
class in/libs/infinity_emb/infinity_emb/fastapi_schemas/pymodels.py
to use 'list' as object type - Added test file
/libs/infinity_emb/tests/unit_test/fastapi_schemas/test_response.py
to verify response object is 'list' - Potential backwards compatibility concerns for clients relying on 'embedding' value need consideration
3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
class OpenAIEmbeddingResult(BaseModel): | ||
object: Literal["embedding"] = "embedding" | ||
object: Literal["list"] = "list" | ||
data: list[_EmbeddingObject] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This is a breaking change that could affect existing clients. Consider adding a version flag or deprecation period to maintain backward compatibility.
def test_embedding_response(): | ||
res = OpenAIEmbeddingResult(data=[], model="hi", usage={"prompt_tokens": 5, "total_tokens": 10}) | ||
assert res.model_dump()["object"] == "list" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: test only verifies object field, should also verify data, model and usage fields are present and correctly structured
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #444 +/- ##
=======================================
Coverage 79.18% 79.18%
=======================================
Files 41 41
Lines 3248 3248
=======================================
Hits 2572 2572
Misses 676 676 ☔ View full report in Codecov by Sentry. |
Thanks! Seems like I missed that! |
Description
Return list instead of embedding in response to be compatible with openai.
Respone definition from OpenAI see here
Related Issue
#371
Types of Change
Checklist
Additional Notes
Maybe we need to add backwards compatibility if someone relies on the embedding field.
License
By submitting this PR, I confirm that my contribution is made under the terms of the MIT license.