Skip to content

Python: Fix notebooks 10 and 11#3557

Merged
moonbox3 merged 16 commits intomicrosoft:mainfrom
john0isaac:fix-python-notebooks
Jan 10, 2024
Merged

Python: Fix notebooks 10 and 11#3557
moonbox3 merged 16 commits intomicrosoft:mainfrom
john0isaac:fix-python-notebooks

Conversation

@john0isaac
Copy link
Contributor

@john0isaac john0isaac commented Nov 19, 2023

Motivation and Context

fix: #3514, fixed both notebooks by introducing a check before running the code that users have to define at the beginning of the notebook.

Description

Whichever service the user chooses (OpenAI - Azure OpenAI - Huggine Face) the code adjusts accordingly without the need to change anything later other than the .env file (obviously) and the Service name at the second cell of the two notebooks.

@john0isaac john0isaac requested a review from a team as a code owner November 19, 2023 21:39
@shawncal shawncal added the python Pull requests for the Python Semantic Kernel label Nov 19, 2023
@moonbox3
Copy link
Collaborator

moonbox3 commented Jan 9, 2024

Hi @john0isaac, thank you for your help with this. We've had a lot of (breaking) changes over the last few weeks/months after this PR was created. There have been updates on these notebooks since then and I believe they're working fine. If you have time, could you verify, please?

@john0isaac
Copy link
Contributor Author

@moonbox3 Thank you for checking this PR.
You are correct, I have fixed multiple things in this PR which have been addressed by other separate PRs that were already merged.

But the main problem still exists in these notebooks

Running code that calls hugging face modules, openai modules, and azure openai modules in the same cells gives you errors:
image

The main feature that this PR adds which has not been fixed in other PRs is a variable at the beginning of the notebook to choose between (openai, azure, hugging face)
set it one time
then run the whole notebook and you won't get any errors as there are checks to see which one did you choose and run the code related to it.

I will fix the merge conflicts one last time if you approve of the idea you can merge it, if not please close this PR.

@john0isaac john0isaac reopened this Jan 10, 2024
@john0isaac
Copy link
Contributor Author

john0isaac commented Jan 10, 2024

Another thing I noticed text-davinci-003 is no longer available for deployment from Azure OpenAI See MSFT reference https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/legacy-models

It was replaced by gpt-35-turbo-instruct - I added a note to the comment

Also HuggingFace import needs packages transformers, torch, and sentence-transformers. Using my check silences the import error so, I didn't add any notes around this but just wanted to let you know.

@john0isaac
Copy link
Contributor Author

@moonbox3 Done ✅.
Please check and let me know what you think about this..

Copy link
Collaborator

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

LGTM but two small changes requested, please. Thank you!

@john0isaac john0isaac requested a review from moonbox3 January 10, 2024 15:49
Copy link
Collaborator

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@juliomenendez juliomenendez left a comment

Choose a reason for hiding this comment

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

Would it make sense to refactor the Service enum to a module that can be used by all the notebooks instead of repeated in each of them? I see this being used not just in those 2 notebooks in the future.
Otherwise, LGTM

@john0isaac
Copy link
Contributor Author

john0isaac commented Jan 10, 2024

@juliomenendez I believe you are correct, at the time I submitted the PR this issue was only present in the last two notebooks.
Other notebooks have other checks or different guidance for which cells to run and which not to run.
But I agree with you.

Copy link
Contributor

@juliomenendez juliomenendez left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@moonbox3
Copy link
Collaborator

@john0isaac it just needs a quick ruff . --fix and you should be good to go.

@john0isaac
Copy link
Contributor Author

@moonbox3 Done ✅
Thank you so much!

@moonbox3
Copy link
Collaborator

We should file an issue to update the other notebooks from using the bool to determine which service to use to this new service enum you've added.

@moonbox3 moonbox3 added this pull request to the merge queue Jan 10, 2024
Merged via the queue into microsoft:main with commit d1e8120 Jan 10, 2024
@john0isaac john0isaac deleted the fix-python-notebooks branch January 10, 2024 17:09
Bryan-Roe pushed a commit to Bryan-Roe-ai/semantic-kernel that referenced this pull request Oct 6, 2024
### Motivation and Context

fix: microsoft#3514, I didn't know which integration tests @markwallace-microsoft
is referring to but I fixed both notebooks by introducing a check before
running the code that users have to define at the beginning of the
notebook.

### Description

Whichever service the user chooses (OpenAI - Azure OpenAI - Huggine
Face) the code adjusts accordingly without the need to change anything
later other than the .env file (obviously) and the Service name at the
second cell of the two notebooks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Fix broken notebooks and update integration tests

4 participants