Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Bug: Installing semantic version in a fresh environment installs an old openai version which doesn't have this import yet from openai.lib._parsing._completions import type_to_response_format_param #10025

Open
john0isaac opened this issue Dec 22, 2024 · 0 comments
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code python Pull requests for the Python Semantic Kernel triage

Comments

@john0isaac
Copy link
Contributor

Describe the bug
I created a new virtual environment and installed the semantic kernel, when I tried to use this line

from semantic_kernel.connectors.ai.open_ai import (
    AzureChatCompletion,
    AzureTextEmbedding,
)

It gave me this error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[7], [line 1](vscode-notebook-cell:?execution_count=7&line=1)
----> [1](vscode-notebook-cell:?execution_count=7&line=1) from semantic_kernel.connectors.ai.open_ai import (
      [2](vscode-notebook-cell:?execution_count=7&line=2)     AzureChatCompletion,
      [3](vscode-notebook-cell:?execution_count=7&line=3)     AzureTextEmbedding,
      [4](vscode-notebook-cell:?execution_count=7&line=4) )

File ~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:31
     [25](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:25) from semantic_kernel.connectors.ai.open_ai.prompt_execution_settings.open_ai_text_to_audio_execution_settings import (
     [26](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:26)     OpenAITextToAudioExecutionSettings,
     [27](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:27) )
     [28](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:28) from semantic_kernel.connectors.ai.open_ai.prompt_execution_settings.open_ai_text_to_image_execution_settings import (
     [29](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:29)     OpenAITextToImageExecutionSettings,
     [30](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:30) )
---> [31](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:31) from semantic_kernel.connectors.ai.open_ai.services.azure_audio_to_text import AzureAudioToText
     [32](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:32) from semantic_kernel.connectors.ai.open_ai.services.azure_chat_completion import AzureChatCompletion
     [33](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/__init__.py:33) from semantic_kernel.connectors.ai.open_ai.services.azure_text_completion import AzureTextCompletion

File ~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_audio_to_text.py:10
      [7](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_audio_to_text.py:7) from openai.lib.azure import AsyncAzureADTokenProvider
      [8](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_audio_to_text.py:8) from pydantic import ValidationError
---> [10](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_audio_to_text.py:10) from semantic_kernel.connectors.ai.open_ai.services.azure_config_base import AzureOpenAIConfigBase
     [11](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_audio_to_text.py:11) from semantic_kernel.connectors.ai.open_ai.services.open_ai_audio_to_text_base import OpenAIAudioToTextBase
     [12](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_audio_to_text.py:12) from semantic_kernel.connectors.ai.open_ai.services.open_ai_model_types import OpenAIModelTypes

File ~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_config_base.py:11
      [8](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_config_base.py:8) from pydantic import ConfigDict, validate_call
     [10](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_config_base.py:10) from semantic_kernel.connectors.ai.open_ai.const import DEFAULT_AZURE_API_VERSION
---> [11](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_config_base.py:11) from semantic_kernel.connectors.ai.open_ai.services.open_ai_handler import OpenAIHandler, OpenAIModelTypes
     [12](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_config_base.py:12) from semantic_kernel.const import USER_AGENT
     [13](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_config_base.py:13) from semantic_kernel.exceptions import ServiceInitializationError

File ~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py:8
      [5](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py:5) from typing import Any, Union
      [7](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py:7) from openai import AsyncOpenAI, AsyncStream, BadRequestError, _legacy_response
----> [8](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py:8) from openai.lib._parsing._completions import type_to_response_format_param
      [9](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py:9) from openai.types import Completion, CreateEmbeddingResponse
     [10](https://file+.vscode-resource.vscode-cdn.net/Users/john0isaac/Developer/rag-semantic-kernel-mongodb-vcore/~/Developer/rag-semantic-kernel-mongodb-vcore/.venv/lib/python3.10/site-packages/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py:10) from openai.types.audio import Transcription

ModuleNotFoundError: No module named 'openai.lib._parsing'

I looked into the openai library and it seems to has this module in a later version of openai not the version that was automatically resolved by pip when i attempted to install the semantic kernel.

To Reproduce
Steps to reproduce the behavior:

  1. Install the semantic kernel in a fresh env
  2. Import the lines of code above

Expected behavior
The import to work

Platform

  • OS: Mac
  • IDE: Visual Studio
  • Language: Python 3.10
  • Source: python-1.17.1

Proposed solution

Use a dependency marker that requires a higher version for openai in the semantic kernel config

@john0isaac john0isaac added the bug Something isn't working label Dec 22, 2024
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code python Pull requests for the Python Semantic Kernel triage labels Dec 22, 2024
@github-actions github-actions bot changed the title Bug: Installing semantic version in a fresh environment installs an old openai version which doesn't have this import yet from openai.lib._parsing._completions import type_to_response_format_param Python: Bug: Installing semantic version in a fresh environment installs an old openai version which doesn't have this import yet from openai.lib._parsing._completions import type_to_response_format_param Dec 22, 2024
@github-actions github-actions bot changed the title Python: Bug: Installing semantic version in a fresh environment installs an old openai version which doesn't have this import yet from openai.lib._parsing._completions import type_to_response_format_param .Net: Bug: Installing semantic version in a fresh environment installs an old openai version which doesn't have this import yet from openai.lib._parsing._completions import type_to_response_format_param Dec 22, 2024
@john0isaac john0isaac changed the title .Net: Bug: Installing semantic version in a fresh environment installs an old openai version which doesn't have this import yet from openai.lib._parsing._completions import type_to_response_format_param Python: Bug: Installing semantic version in a fresh environment installs an old openai version which doesn't have this import yet from openai.lib._parsing._completions import type_to_response_format_param Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code python Pull requests for the Python Semantic Kernel triage
Projects
None yet
Development

No branches or pull requests

2 participants