edge selcuk
edge selcuk

Reputation: 179

ImportError when trying to list available Language Models (LLMs) and Chat Models using langchain

I'm currently working on a project that involves Language Models (LLMs) and Chat Models, and I'm using the langchain library in Python to list available models. However, I'm encountering an ImportError when running the code.

Here's the code snippet I'm using:

from langchain.chat_models import list_available_models
model_names = list_available_models()
print(model_names)

The error message I receive is as follows:

ImportError: cannot import name 'list_available_models' from 'langchain.chat_models' (c:\Users\Edge\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\chat_models\__init__.py)

I've double-checked the library and the code, but I can't seem to find a solution to this issue. Could someone please help me understand what might be causing this ImportError and how I can resolve it?


Upvotes: 0

Views: 501

Answers (1)

ChenChao
ChenChao

Reputation: 104

As I know, the package langchain.chat_models doesn't have this function list_available_models. If you want to see the available models, you can go to this file c:\Users\Edge\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\chat_models\__init__.py and you can see all the available models like this:

__all__ = [
    "ChatOpenAI",
    "BedrockChat",
    "AzureChatOpenAI",
    "FakeListChatModel",
    "PromptLayerChatOpenAI",
    "ChatDatabricks",
    "ChatEverlyAI",
    "ChatAnthropic",
    "ChatCohere",
    "ChatGooglePalm",
    "ChatMlflow",
    "ChatMLflowAIGateway",
    "ChatOllama",
    "ChatVertexAI",
    "JinaChat",
    "HumanInputChatModel",
    "MiniMaxChat",
    "ChatAnyscale",
    "ChatLiteLLM",
    "ErnieBotChat",
    "ChatJavelinAIGateway",
    "ChatKonko",
    "PaiEasChatEndpoint",
    "QianfanChatEndpoint",
    "ChatFireworks",
    "ChatYandexGPT",
    "ChatBaichuan",
    "ChatHunyuan",
    "GigaChat",
    "VolcEngineMaasChat",
]

If you want to use ChatOpenai, you can use:

from langchain.chat_models import ChatOpenAI

llm = ChatOpenAI(openai_api_key="...")

Upvotes: 0

Related Questions