【Python】pydanticを使用しOpenAIの関数呼び出しを作成するための「openai_function_call」

スポンサーリンク

【Python】pydanticを使用しOpenAIの関数呼び出しを作成するためのライブラリ「openai_function_call」のインストールについて解説します。

「openai_function_call(https://github.com/jxnl/openai_function_call)」は、OpenAI APIの関数呼び出しと対話する際の出力解析に対する強力かつ効率的なアプローチを提供しているライブラリです。

■Python

今回のPythonのバージョンは、「3.9.9」を使用しています。(Windows11)(pythonランチャーでの確認)

■openai_function_callをインストールする

openai_function_callをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install openai-function-call

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.9.9にインストールを行うために、バージョンの切り替えを行います。

py -3.9 -m pip install openai-function-call

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting openai-function-call
Downloading openai_function_call-0.1.1-py3-none-any.whl (13 kB)
Collecting openai<0.28.0,>=0.27.8
Using cached openai-0.27.8-py3-none-any.whl (73 kB)
Collecting pydantic<2.0.0,>=1.10.9
Downloading pydantic-1.10.11-cp39-cp39-win_amd64.whl (2.2 MB)
|████████████████████████████████| 2.2 MB 1.7 MB/s
Collecting aiohttp
Using cached aiohttp-3.8.4-cp39-cp39-win_amd64.whl (323 kB)
Collecting tqdm
Using cached tqdm-4.65.0-py3-none-any.whl (77 kB)
Collecting requests>=2.20
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting typing-extensions>=4.2.0
Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Collecting idna<4,>=2.5
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2023.5.7-py3-none-any.whl (156 kB)
Collecting charset-normalizer<4,>=2
Downloading charset_normalizer-3.2.0-cp39-cp39-win_amd64.whl (96 kB)
|████████████████████████████████| 96 kB 2.9 MB/s
Collecting urllib3<3,>=1.21.1
Using cached urllib3-2.0.3-py3-none-any.whl (123 kB)
Collecting yarl<2.0,>=1.0
Using cached yarl-1.9.2-cp39-cp39-win_amd64.whl (61 kB)
Collecting async-timeout<5.0,>=4.0.0a3
Using cached async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting multidict<7.0,>=4.5
Using cached multidict-6.0.4-cp39-cp39-win_amd64.whl (28 kB)
Collecting frozenlist>=1.1.1
Downloading frozenlist-1.4.0-cp39-cp39-win_amd64.whl (44 kB)
|████████████████████████████████| 44 kB 1.2 MB/s
Collecting attrs>=17.3.0
Using cached attrs-23.1.0-py3-none-any.whl (61 kB)
Collecting aiosignal>=1.1.2
Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Collecting colorama
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Installing collected packages: multidict, idna, frozenlist, yarl, urllib3, colorama, charset-normalizer, certifi, attrs, async-timeout, aiosignal, typing-extensions, tqdm, requests, aiohttp, pydantic, openai, openai-function-call
WARNING: The script normalizer.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script tqdm.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script openai.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed aiohttp-3.8.4 aiosignal-1.3.1 async-timeout-4.0.2 attrs-23.1.0 certifi-2023.5.7 charset-normalizer-3.2.0 colorama-0.4.6 frozenlist-1.4.0 idna-3.4 multidict-6.0.4 openai-0.27.8 openai-function-call-0.1.1 pydantic-1.10.11 requests-2.31.0 tqdm-4.65.0 typing-extensions-4.7.1 urllib3-2.0.3 yarl-1.9.2
WARNING: You are using pip version 21.2.4; however, version 23.1.2 is available.
You should consider upgrading via the 'C:\Program Files\Python39\python.exe -m pip install --upgrade pip' command.

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、openai_function_callが正常にインストールされたことになりますが、「WARNING」と表示されました。「WARNING」はエラーではなく警告で、インストールは行われているので、今回は一旦無視しています。

なお、今回はopenai_function_callのバージョン0.1.1をインストールしました。

コメント

タイトルとURLをコピーしました