Azure-Samples / openai

The repository for all Azure OpenAI Samples complementing the OpenAI cookbook.
https://aka.ms/azure-openai
MIT License
1.05k stars 353 forks source link

Update function calling sample notebooks to the new OpenAI v1 SDK #98

Closed yalaudah closed 6 months ago

yalaudah commented 6 months ago

Purpose

The OpenAI Python SDK's 1.0 release in November introduced significant updates along with breaking changes. This necessitates an update of all function-calling notebooks within this repository to align with the new v1.x SDK version, moving away from the deprecated v0.x versions.

This PR updates the notebooks to use the newer v1.x SDK.

Does this introduce a breaking change?

[x] Yes
[ ] No

The notebooks are already broken since the openai package version is not fixed, and v1 of the package introduced breaking changes. This PR updates the code in the function calling notebooks to work with the new SDK, but other code in the repo would also need to be updated.

There is a migration guide here: https://github.com/openai/openai-python/discussions/742 as well as documentation specific to those using Azure OpenAI service.

I used the latter for this PR.

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[x] Other... Please describe: Compatibility Update

Updating notebooks from the deprecated v0.x openai python library to the newer v1.x SDK.

How to Test

update config.json with a valid AZURE_OPENAI_ENDPOINT, MODEL_NAME and OPENAI_API_VERSION, then run the following:

git clone https://github.com/yalaudah/openai
cd openai/Basic_Samples/Functions
git checkout update-notebook-openai-sdk
virtualenv pr
source pr/bin/activate
pip install -r requirements.txt
pip install papermill
papermill working_with_functions.ipynb working_with_functions_output.ipynb

What to Check

Verify that the notebook works as expected.

xiaogou159 commented 6 months ago

I'm still seeing the previous version in the function call notebook. When will the update for OpenAI v1 be complete?

yalaudah commented 6 months ago

@xiaogou159 the PR hasn't been completed yet. It will be ready to be merged today.