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

[Fix] OpenAI Embedderにdimensions設定不可の場合の対応 #14

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

lsz05
Copy link
Collaborator

@lsz05 lsz05 commented Apr 16, 2024

関連する Issue / PR

N/A

PR をマージした後の挙動の変化

修正後,text-embedding-ada-002 も正常に動くようにできました。
text-embedding-ada-002 ではdimensionsの設定が不可とされているため,今のままだと下記のエラーが出ています。

openai.BadRequestError: Error code: 400 - {'error': {'message': 'This model does not support specifying dimensions.', 'type': 'invalid_request_error', 'param': None, 'code': None}}

dimensions=Noneもできないようです。

挙動の変更を達成するために行ったこと

本PRではdimensions引数をmodel=text-embedding-ada-002の場合には送らないようにし,OpenAIEmbedder内のdimも設定と関わらず1536とします。
これで解消しました。

動作確認

  • テストが通ることを確認した

@lsz05 lsz05 marked this pull request as ready for review April 16, 2024 06:20
Copy link
Collaborator

@ryokan0123 ryokan0123 left a comment

Choose a reason for hiding this comment

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

昔のモデルなので dim の指定に対応していない、ということなのでしょうね?
LGTM です

@lsz05
Copy link
Collaborator Author

lsz05 commented Apr 16, 2024

@ryokan0123 これです
https://github.com/openai/openai-python/blob/1a83130d7aff056d83c6760e20246a26a400c0d4/src/openai/resources/embeddings.py#L68-L69
多分サーバー側が対応(新バージョンまで更新)していないと思います

@lsz05 lsz05 merged commit 26a5979 into dev Apr 16, 2024
3 checks passed
@lsz05 lsz05 mentioned this pull request Apr 24, 2024
1 task
@lsz05 lsz05 deleted the fix/openai_dim branch August 29, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants