LoginSignup
0
0

Chroma(ChromaDB)で Azure OpenAI の embedding に対応する

Posted at

概要

ベクトルーデータベースの一つに Chroma(ChromaDB) がある。
Embedding する際のベクトル化で Azure OpenAI の API を利用するとエラーが発生する。

packages\openai\api_resources\abstract\engine_api_resource.py", line 37, in class_url       
    raise error.InvalidRequestError(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: InvalidRequestError.__init__() missing 1 required positional argument: 'param'

ドキュメントの手順を指定しても同様だった。
https://docs.trychroma.com/embeddings#openai

openai_ef = embedding_functions.OpenAIEmbeddingFunction(
api_key="YOUR_API_KEY",
api_base="YOUR_API_BASE_PATH",
api_type="azure",
model_name="text-embedding-ada-002"
)

対応方法

環境変数 OPENAI_API_VERSION に Azure OpenAI のバージョンを指定する。
スクリプト内の指定例は以下。

os.environ['OPENAI_API_VERSION'] = '2023-05-15'

スクリプトを実行するシェルでももちろん OK。
pipenv などを使っている場合は .env ファイルなどでも。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0