Repository: explodinggradients/ragas
Issue: cannot import name 'AsyncAzureOpenAI' from 'openai'
Root cause: External Dependency Breakage

I‘m tring to do "Synthetic test data generation"
**my code：**
from ragas.testset import TestsetGenerator
testsetgenerator = TestsetGenerator.from_default()
test_size = 12
testset = testsetgenerator.generate(documents_0, test_size=test_size)

**error message：**
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[/Users/wukaiyan/wky_wp/python/ylz/test_ragas.ipynb](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/test_ragas.ipynb) 单元格 7 line 1
----> [1](vscode-notebook-cell:/Users/wukaiyan/wky_wp/python/ylz/test_ragas.ipynb#W3sZmlsZQ%3D%3D?line=0) from ragas.testset import TestsetGenerator
      [3](vscode-notebook-cell:/Users/wukaiyan/wky_wp/python/ylz/test_ragas.ipynb#W3sZmlsZQ%3D%3D?line=2) testsetgenerator = TestsetGenerator.from_default()
      [4](vscode-notebook-cell:/Users/wukaiyan/wky_wp/python/ylz/test_ragas.ipynb#W3sZmlsZQ%3D%3D?line=3) test_size = 12

File [~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/__init__.py:1](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/__init__.py:1)
----> [1](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/__init__.py:1) from ragas.testset.testset_generator import TestsetGenerator
      [3](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/__init__.py:3) __all__ = ["TestsetGenerator"]

File [~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/testset_generator.py:16](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/testset_generator.py:16)
     [14](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/testset_generator.py:14) from langchain.prompts import ChatPromptTemplate
     [15](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/testset_generator.py:15) from langchain.schema.document import Document as LangchainDocument
---> [16](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/testset_generator.py:16) from llama_index.indices.query.embedding_utils import get_top_k_embeddings
     [17](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/testset_generator.py:17) from llama_index.node_parser.simple import SimpleNodeParser
     [18](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/ragas/testset/testset_generator.py:18) from llama_index.readers.schema import Document as LlamaindexDocument

File [~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/__init__.py:17](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/__init__.py:17)
     [14](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/__init__.py:14) from llama_index.data_structs.struct_type import IndexStructType
     [16](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/__init__.py:16) # embeddings
---> [17](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/__init__.py:17) from llama_index.embeddings.langchain import LangchainEmbedding
     [18](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/__init__.py:18) from llama_index.embeddings.openai import OpenAIEmbedding
     [20](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/__init__.py:20) # structured
...
----> [3](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/embeddings/azure_openai.py:3) from openai import AsyncAzureOpenAI, AzureOpenAI
      [5](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/embeddings/azure_openai.py:5) from llama_index.bridge.pydantic import Field, PrivateAttr, root_validator
      [6](https://file+.vscode-resource.vscode-cdn.net/Users/wukaiyan/wky_wp/python/ylz/~/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/llama_index/embeddings/azure_openai.py:6) from llama_index.callbacks.base import CallbackManager

ImportError: cannot import name 'AsyncAzureOpenAI' from 'openai' (/Users/wukaiyan/opt/anaconda3/envs/py31011_langchain/lib/python3.11/site-packages/openai/__init__.py)
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?bcbae2d9-52d3-49af-b536-1ea8d24f3757) or open in a [text editor](command:workbench.action.openLargeOutput?bcbae2d9-52d3-49af-b536-1ea8d24f3757). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...

I want to know how to solve this.
I would like to know the version of ragas and openai each.

Hey @Gaia-Wu , were you able to fix the issue? 

Hi @Gaia-Wu / @shahules786 
 
I am getting the same error : `ImportError: cannot import name 'AsyncAzureOpenAI' from 'openai'` while importing ragas.

```
llama-index = 0.9.21
ragas = 0.0.22
openai = 1.6.1
```

I tried this - https://github.com/explodinggradients/ragas/issues/287#issuecomment-1813801958 and this - https://github.com/nlmatics/llmsherpa/issues/26#issuecomment-1804821654

Were you able to fix this issue?


Same issue here. I'm not using LlamaIndex - only LangChain. 
The worst is: I don't even want to use openai! How can I prevent this from being imported?