0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

langchainでAzure OpenAIのAPIを叩くときの仕様が若干変わってたのでメモ

Last updated at Posted at 2024-01-26

背景

langchainを久々に触ったら今後若干仕様が変わるとのwarningが出たのでメモ。

使い方

環境変数は以下のように設定(API versionはこれを使ってね!っていうお触れ書きがOpenAI側からあったような気もするが、忘れたので後で追記する)

OPENAI_API_TYPE="azure"
OPENAI_API_VERSION="2023-09-01-preview"
OPENAI_API_KEY="*********************"
AZURE_OPENAI_ENDPOINT="https://xxx.openai.azure.com/

新たにlangchain-openaiをインストール。
langchain.chat_modelsから叩いていたが、langchain v0.2.0から変更になるらしい。

pip install langchain-openai

コード上では以下のように使う。

from langchain-openai import AzureChatOpenAI

llm = AzureChatOpenAI(azure_deployment="deployment_name")
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?