Azure/aistudio-copilot-sample

ImportError: cannot import name 'AsyncAzureOpenAI' from 'openai'

vykhand opened this issue · 2 comments

Hi Folks,

I did a clean build and I am having the issue running semantic kernel and promptflow. The rest of the stuff works.
I had troubles installing the requirements with the latest pip resolver, because it was running too long, perhaps that could be the culprit. Or, some problem with versions? Anyway, here is the issue after running pytest (and anything else that involves promptflow and semantic kerlnel):

================================================================ short test summary info ================================================================
FAILED src/tests/test_aisdk_copilot.py::test_gpt_groundedness_atleast4 - TypeError: 'EvaluationResult' object is not subscriptable
FAILED src/tests/test_aisdk_copilot.py::test_gpt_relevance_atleast4 - TypeError: 'EvaluationResult' object is not subscriptable
FAILED src/tests/test_aisdk_copilot.py::test_gpt_coherence_atleast4 - TypeError: 'EvaluationResult' object is not subscriptable
ERROR src/tests/test_promptflow_copilot.py::test_gpt_groundedness_atleast4 - Exception: Connection 'AzureAISearch' required for flow 'copilot_promptflow' is not found.
ERROR src/tests/test_promptflow_copilot.py::test_gpt_relevance_atleast4 - Exception: Connection 'AzureAISearch' required for flow 'copilot_promptflow' is not found.
ERROR src/tests/test_promptflow_copilot.py::test_gpt_coherence_atleast4 - Exception: Connection 'AzureAISearch' required for flow 'copilot_promptflow' is not found.
ERROR src/tests/test_semantickernel_copilot.py::test_gpt_groundedness_atleast4 - ImportError: cannot import name 'AsyncAzureOpenAI' from 'openai' (/Users/..../DEV/aistudio-copilot-sample/.venv/lib/python3.9/site-packages/opena...
ERROR src/tests/test_semantickernel_copilot.py::test_gpt_relevance_atleast4 - ImportError: cannot import name 'AsyncAzureOpenAI' from 'openai' (/Users/.../DEV/aistudio-copilot-sample/.venv/lib/python3.9/site-packages/opena...
ERROR src/tests/test_semantickernel_copilot.py::test_gpt_coherence_atleast4 - ImportError: cannot import name 'AsyncAzureOpenAI' from 'openai' (/Users/.../DEV/aistudio-copilot-sample/.venv/lib/python3.9/site-packages/opena...
======================================================= 3 failed, 16 warnings

I have also found same issue: Traceback (most recent call last):
File "src/run.py", line 239, in
from copilot_semantickernel.chat import chat_completion
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/vshringari1/code/aistudio-copilot-sample/src/copilot_semantickernel/chat.py", line 9, in
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/vshringari1/code/.venv/lib/python3.8/site-packages/semantic_kernel/connectors/ai/open_ai/init.py", line 11, in
from semantic_kernel.connectors.ai.open_ai.services.azure_chat_completion import (
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/vshringari1/code/.venv/lib/python3.8/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_chat_completion.py", line 17, in
from openai import AsyncAzureOpenAI
ImportError: cannot import name 'AsyncAzureOpenAI' from 'openai' (/mnt/batch/tasks/shared/LS_root/mounts/clusters/vshringari1/code/.venv/lib/python3.8/site-packages/openai/init.py)

luigiw commented

@Vshringari , this is fixed on main branch now that the sample repo supports openai 1.x.