microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
22.04k stars 3.29k forks source link

Python: OpenAIChatCompletion fails in a Fabric Notebook #3416

Closed rvermeire closed 11 months ago

rvermeire commented 1 year ago

Describe the bug OpenAI service fails to complete chat in a Fabric Notebook. AzureChatCompletion does work for the exact same example

Error: (<ErrorCodes.ServiceError: 6>, 'OpenAI service failed to complete the chat', InvalidRequestError(message="Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.chat_completion.ChatCompletion'>", param='engine', code=None, http_status=None, request_id=None))

To Reproduce

  1. Create a Microsoft Fabric notebook
  2. Upload a skill to the Lakehouse files section (For example Funskill
  3. Copy one of the example notebooks (for example python/notebooks/00-getting-started.ipynb)

Expected behavior OpenAIChatCompletion should work like AzureOpenAIChatCompletion

Screenshots

Platform

Additional context I first had this issue when following this blog post. https://blog.fabric.microsoft.com/en-us/blog/chat-your-data-in-microsoft-fabric-with-semantic-kernel?ft=All I just changed from AzureOpenAIChatCompletion to OpenAIChatCompletion because I don't have access to GPT-4 on Azure.

eavanvalkenburg commented 11 months ago

Hi @rvermeir thanks for checking and creating an issue, we just released a new version with the new openai package, could you test with that?

rvermeire commented 11 months ago

Hi Eduard, I think there is a breaking change. I get an unrelated error when importing. So no possibility to test this now.

import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, AzureChatCompletion

cannot import name 'UrlConstraints' from 'pydantic' (/home/trusted-service-user/cluster-env/trident_env/lib/python3.10/site-packages/pydantic/__init__.cpython-310-x86_64-linux-gnu.so)

eavanvalkenburg commented 11 months ago

this is interesting, you are using 0.4.1b right, that is the latest and should not lead not this kind of error, if installed correctly. Could you also check which version of pydantic you have installed?

rvermeire commented 11 months ago

Although I do not see a "b" in the package name, I think we are talking about the same version.

Collecting semantic-kernel
  Downloading semantic_kernel-0.4.1.dev0-py3-none-any.whl (209 kB)
Collecting pydantic>2 (from semantic-kernel)
  Downloading pydantic-2.5.2-py3-none-any.whl (381 kB)
moonbox3 commented 11 months ago

@rvermeire Are you installing SK via pip or Poetry? If you're installing via pip, I'd recommend moving over to Poetry per the following guidance. If you're not using a virtual env, there could be some weird things happening with dependencies.

rvermeire commented 11 months ago

@moonbox3 would that work from a Fabric notebook?

moonbox3 commented 11 months ago

@rvermeire Apologies as I overlooked you were using a Fabric notebook. If managing packages via pip you should still be able to create a virtual environment so that there are no dependency issues.

The package versions you showed above are latest.

rvermeire commented 11 months ago

I do not know what changed, but it imports correctly now. Maybe something on the fabric side...Thanks for your support.