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

cannot import name 'AzureOpenAI' from 'langchain.llms' #9453

Closed
3 of 14 tasks
ozkank opened this issue Aug 18, 2023 · 5 comments
Closed
3 of 14 tasks

cannot import name 'AzureOpenAI' from 'langchain.llms' #9453

ozkank opened this issue Aug 18, 2023 · 5 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: embeddings Related to text embedding models module Ɑ: models Related to LLMs or chat model modules

Comments

@ozkank
Copy link

ozkank commented Aug 18, 2023

System Info

I got this error from on my office laptop
OS: Win 10

I checked AzureAI key, url, deployment and model names. No problem about that.
This guy having same issue with me : https://stackoverflow.com/questions/76750207/azureopenai-not-available-in-langchain

I deleted "import openai" part but no change.

Could somebody pls help me?

from dotenv import load_dotenv
from langchain.llms import AzureOpenAI
from langchain.embeddings import OpenAIEmbeddings
import openai
import os


# Load environment variables
load_dotenv()

# Configure Azure OpenAI Service API
openai.api_type = "azure"
openai.api_version = "2022-12-01"
openai.api_base = os.getenv('OPENAI_API_BASE')
openai.api_key = os.getenv("OPENAI_API_KEY")

# Create a completion
llm = AzureOpenAI(deployment_name="text-davinci-003", model_name="text-davinci-003")
joke = llm("Tell me a dad joke")
print(joke)

Who can help?

No response

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

from dotenv import load_dotenv
from langchain.llms import AzureOpenAI
from langchain.embeddings import OpenAIEmbeddings
import openai
import os

Load environment variables

load_dotenv()

Configure Azure OpenAI Service API

openai.api_type = "azure"
openai.api_version = "2022-12-01"
openai.api_base = os.getenv('OPENAI_API_BASE')
openai.api_key = os.getenv("OPENAI_API_KEY")

Expected behavior

from dotenv import load_dotenv
from langchain.llms import AzureOpenAI
from langchain.embeddings import OpenAIEmbeddings
import openai
import os

@dosubot dosubot bot added Ɑ: embeddings Related to text embedding models module Ɑ: models Related to LLMs or chat model modules 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Aug 18, 2023
@dosubot
Copy link

dosubot bot commented Aug 18, 2023

🤖

Hello,

Based on the context provided, it seems like there might be a misunderstanding about the location of the 'AzureOpenAI' class. In the current version of LangChain, 'AzureOpenAI' is not a part of the 'langchain.llms' module. Instead, there is a class named 'AzureChatOpenAI' which is located in 'langchain.chat_models.azure_openai'.

So, the correct import statement should be:

from langchain.chat_models.azure_openai import AzureChatOpenAI

Please replace 'AzureOpenAI' with 'AzureChatOpenAI' in your code and try again. If you're still facing issues, it might be due to a problem with your Python environment or a bug in the LangChain framework.

Also, ensure that the 'openai' Python package is installed and the environment variables 'OPENAI_API_TYPE', 'OPENAI_API_KEY', 'OPENAI_API_BASE', 'OPENAI_API_VERSION', and 'OPENAI_PROXY' are set with your API key.

I hope this helps! If you have any other questions or need further clarification, feel free to ask.

Best,
Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@ozkank
Copy link
Author

ozkank commented Aug 18, 2023

from langchain.chat_models.azure_openai import AzureChatOpenAI

ModuleNotFoundError: No module named 'langchain.chat_models'

It is same.

@sssssshf
Copy link

from langchain.chat_models.azure_openai import AzureChatOpenAI

ModuleNotFoundError: No module named 'langchain.chat_models'

It is same.

do you selvo this prpblem?

@nikhil7601
Copy link

from langchain.chat_models.azure_openai import AzureChatOpenAI

ModuleNotFoundError: No module named 'langchain.chat_models'

It is same.

Try this, it should work:
from langchain.chat_models import AzureChatOpenAI

Copy link

dosubot bot commented Feb 6, 2024

Hi, @ozkank! I'm Dosu and I'm helping the LangChain team manage their backlog. I'm marking this issue as stale.

It seems like you're encountering an error when trying to import 'AzureOpenAI' from 'langchain.llms'. There have been suggestions from "dosubot" and "nikhil7601" regarding the correct import statement, but it appears that the issue remains unresolved.

Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 6, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: embeddings Related to text embedding models module Ɑ: models Related to LLMs or chat model modules
Projects
None yet
Development

No branches or pull requests

3 participants