langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
95.7k stars 15.54k forks source link

ImportError: cannot import name 'LangSmithParams' from 'langchain_core.language_models.chat_models'(import langchain_google_genai) in collab environment #24533

Closed AkashBais closed 4 months ago

AkashBais commented 4 months ago

Checked other resources

Example Code

import langchain_google_genai raise ImportError

Error Message and Stack Trace (if applicable)

ImportError Traceback (most recent call last) in <cell line: 6>() 4 # !pip install --upgrade langchain 5 # from langchain_google_genai import GoogleGenerativeAI ----> 6 import langchain_google_genai# import GoogleGenerativeAI 7 8 # llm = ChatGoogleGenerativeAI(model="gemini-pro")

1 frames /usr/local/lib/python3.10/dist-packages/langchain_google_genai/init.py in 57 58 from langchain_google_genai._enums import HarmBlockThreshold, HarmCategory ---> 59 from langchain_google_genai.chat_models import ChatGoogleGenerativeAI 60 from langchain_google_genai.embeddings import GoogleGenerativeAIEmbeddings 61 from langchain_google_genai.genai_aqa import (

/usr/local/lib/python3.10/dist-packages/langchain_google_genai/chat_models.py in 54 ) 55 from langchain_core.language_models import LanguageModelInput ---> 56 from langchain_core.language_models.chat_models import BaseChatModel, LangSmithParams 57 from langchain_core.messages import ( 58 AIMessage,

ImportError: cannot import name 'LangSmithParams' from 'langchain_core.language_models.chat_models' (/usr/local/lib/python3.10/dist-packages/langchain_core/language_models/chat_models.py)

Description

I am am trying to use the GoogleGenerativeAI wrapper for a project of mine.

System Info

System Information

OS: Linux OS Version: #1 SMP PREEMPT_DYNAMIC Thu Jun 27 21:05:47 UTC 2024 Python Version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]

Package Information

langchain_core: 0.2.22 langchain: 0.2.10 langchain_community: 0.0.38 langsmith: 0.1.93 langchain_google_genai: 1.0.8 langchain_openai: 0.1.7 langchain_text_splitters: 0.2.2

eyurtsev commented 4 months ago

cc @ccurme

ccurme commented 4 months ago

Can you confirm the kernel that is raising the error has langchain-core==0.2.22, as you specify in your package information?

I cannot reproduce this error in a fresh environment:

pip install --upgrade langchain_google_genai -i https://pypi.org/simple
pip freeze | grep langchain
langchain-core==0.2.22
langchain-google-genai==1.0.8
MohamedLahmeri01 commented 4 months ago

restart kernel

AkashBais commented 4 months ago

The issue was due to version conflicts within environments. Thanks for your responces

matheusft commented 4 months ago

The issue was due to version conflicts within environments. Thanks for your responses

Can you specify what was the conflict?

Mustafa-Shoukat1 commented 4 months ago

ImportError: cannot import name 'LangSmithParams' from 'langchain_core.language_models.chat_models' (/usr/local/lib/python3.10/dist-packages/langchain_core/language_models/chat_models.py)

pepoo20 commented 3 months ago

This happened to me when I tried: pip install ragatouille Then fixed it with: pip install --upgrade langchain langchain-community langchain-core

RamziRebai commented 2 months ago

When the driver connects to “mongodb+srv://” connection strings it must perform SRV and TXT lookups via DNS. If those lookups consistently time out that indicates a DNS misconfiguration in the network; perhaps there’s some throttling going on or these DNS queries are being dropped/blocked.

One option that’s always available to workaround these issues is to switch to using the old-style “mongodb://” connection string. You can find this in the Atlas cluster UI, https://www.mongodb.com/docs/guides/atlas/connection-string/ 144, going to “connect your application” and then choosing the oldest driver version (choosing the newer driver version will give you a “mongodb+srv://” connection string).

Go to my Mongodb >> Clusters >> Connect >> Drivers >> Then choose : "python.3.4" and update your Atlas_connection_string with the new one (same old username and password)