[Python] Got "PydanticUserError" when import ChatGroq

Discussão em 'Python' iniciado por Stack, Abril 18, 2025.

  1. Stack

    Stack Membro Participativo

    I have following packages installed

    langchain_core==0.2.39
    langchain==0.2.16
    langchain-community==0.2.16
    langchain_groq==0.1.10
    langchain_openai==0.1.24
    fastapi==0.114.2
    redis
    pyyaml


    However, when I try to

    from langchain_groq import ChatGroq


    I got error

    PydanticUserError Traceback (most recent call last)
    Cell In[20], line 70
    64 #print(pm)
    65
    66
    68 import os
    ---> 70 from langchain_groq import ChatGroq

    File /opt/anaconda3/envs/my_env/lib/python3.12/site-packages/langchain_groq/__init__.py:1
    ----> 1 from langchain_groq.chat_models import ChatGroq
    3 __all__ = ["ChatGroq"]

    File /opt/anaconda3/envs/my_env/lib/python3.12/site-packages/langchain_groq/chat_models.py:87
    80 from langchain_core.utils.function_calling import (
    81 convert_to_openai_function,
    82 convert_to_openai_tool,
    83 )
    84 from langchain_core.utils.pydantic import is_basemodel_subclass
    ---> 87 class ChatGroq(BaseChatModel):
    88 """`Groq` Chat large language models API.
    89
    90 To use, you should have the
    (...)
    296 'logprobs': None}
    ...
    2454 if hasattr(tp, '__origin__') and not is_annotated(tp):

    PydanticUserError: The `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` instead in class `SecretStr`.

    For further information visit https://errors.pydantic.dev/2.9/u/custom-json-schema


    Please advise.

    Continue reading...

Compartilhe esta Página