Repository: explodinggradients/ragas
Issue: cannot import name 'version_short' from 'pydantic.version'
Root cause: External Dependency Breakage

[ ] I checked the [documentation](https://docs.ragas.io/) and related resources and couldn't find an answer to my question.

**Your Question**
not able to cross "from ragas import evaluate" and getting pydantic error for version.  using aws sagemaker 

**Code Examples**
import os
from datasets import Dataset
import pandas as pd
from ragas import evaluate
from langchain.chat_models.azure_openai import AzureChatOpenAI
from ragas.metrics import (
    faithfulness,
    answer_relevancy,
    context_precision,
    context_recall,
    context_entity_recall,
    answer_similarity,
    answer_correctness,
    # harmfulness,
)
from ragas.metrics.critique import harmfulness
from creds import settings


metrics = [
    faithfulness,
    answer_relevancy,
    context_recall,
    context_precision,
    harmfulness,
]
    

**error**

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[7], line 4
      2 from datasets import Dataset
      3 import pandas as pd
----> 4 from ragas import evaluate
      5 from langchain.chat_models.azure_openai import AzureChatOpenAI
      6 from ragas.metrics import (
      7     faithfulness,
      8     answer_relevancy,
   (...)
     14     # harmfulness,
     15 )

File [/opt/conda/lib/python3.10/site-packages/ragas/__init__.py:1](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/ragas/__init__.py#line=0)
----> 1 from ragas.adaptation import adapt
      2 from ragas.evaluation import evaluate
      3 from ragas.run_config import RunConfig

File [/opt/conda/lib/python3.10/site-packages/ragas/adaptation.py:5](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/ragas/adaptation.py#line=4)
      1 import typing as t
      3 from langchain_core.language_models import BaseLanguageModel
----> 5 from ragas.llms import llm_factory
      6 from ragas.llms.base import BaseRagasLLM, LangchainLLMWrapper
      7 from ragas.metrics.base import MetricWithLLM

File [/opt/conda/lib/python3.10/site-packages/ragas/llms/__init__.py:1](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/ragas/llms/__init__.py#line=0)
----> 1 from ragas.llms.base import BaseRagasLLM, LangchainLLMWrapper, llm_factory
      3 __all__ = [
      4     "BaseRagasLLM",
      5     "LangchainLLMWrapper",
      6     "llm_factory",
      7 ]

File [/opt/conda/lib/python3.10/site-packages/ragas/llms/base.py:14](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/ragas/llms/base.py#line=13)
     12 from langchain_core.language_models import BaseLanguageModel
     13 from langchain_core.outputs import LLMResult
---> 14 from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI
     15 from langchain_openai.llms import AzureOpenAI, OpenAI
     16 from langchain_openai.llms.base import BaseOpenAI

File [/opt/conda/lib/python3.10/site-packages/langchain_openai/__init__.py:1](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/langchain_openai/__init__.py#line=0)
----> 1 from langchain_openai.chat_models import (
      2     AzureChatOpenAI,
      3     ChatOpenAI,
      4 )
      5 from langchain_openai.embeddings import (
      6     AzureOpenAIEmbeddings,
      7     OpenAIEmbeddings,
      8 )
      9 from langchain_openai.llms import AzureOpenAI, OpenAI

File [/opt/conda/lib/python3.10/site-packages/langchain_openai/chat_models/__init__.py:1](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/langchain_openai/chat_models/__init__.py#line=0)
----> 1 from langchain_openai.chat_models.azure import AzureChatOpenAI
      2 from langchain_openai.chat_models.base import ChatOpenAI
      4 __all__ = [
      5     "ChatOpenAI",
      6     "AzureChatOpenAI",
      7 ]

File [/opt/conda/lib/python3.10/site-packages/langchain_openai/chat_models/azure.py:8](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/langchain_openai/chat_models/azure.py#line=7)
      5 import os
      6 from typing import Any, Callable, Dict, List, Optional, Union
----> 8 import openai
      9 from langchain_core.outputs import ChatResult
     10 from langchain_core.pydantic_v1 import Field, SecretStr, root_validator

File [/opt/conda/lib/python3.10/site-packages/openai/__init__.py:8](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/openai/__init__.py#line=7)
      5 import os as _os
      6 from typing_extensions import override
----> 8 from . import types
      9 from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
     10 from ._utils import file_from_path

File [/opt/conda/lib/python3.10/site-packages/openai/types/__init__.py:5](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/openai/types/__init__.py#line=4)
      1 # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
      3 from __future__ import annotations
----> 5 from .image import Image as Image
      6 from .model import Model as Model
      7 from .shared import (
      8     ErrorObject as ErrorObject,
      9     FunctionDefinition as FunctionDefinition,
     10     FunctionParameters as FunctionParameters,
     11 )

File [/opt/conda/lib/python3.10/site-packages/openai/types/image.py:5](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/openai/types/image.py#line=4)
      1 # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
      3 from typing import Optional
----> 5 from .._models import BaseModel
      7 __all__ = ["Image"]
     10 class Image(BaseModel):

File [/opt/conda/lib/python3.10/site-packages/openai/_models.py:22](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/openai/_models.py#line=21)
      8 from typing_extensions import (
      9     Unpack,
     10     Literal,
   (...)
     18     runtime_checkable,
     19 )
     21 import pydantic
---> 22 import pydantic.generics
     23 from pydantic.fields import FieldInfo
     25 from ._types import (
     26     Body,
     27     IncEx,
   (...)
     34     HttpxRequestFiles,
     35 )

File [/opt/conda/lib/python3.10/site-packages/pydantic/generics.py:2](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/pydantic/generics.py#line=1)
      1 """The `generics` module is a backport module from V1."""
----> 2 from ._migration import getattr_migration
      4 __getattr__ = getattr_migration(__name__)

File [/opt/conda/lib/python3.10/site-packages/pydantic/_migration.py:4](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/pydantic/_migration.py#line=3)
      1 import sys
      2 from typing import Any, Callable, Dict
----> 4 from .version import version_short
      6 MOVED_IN_V2 = {
      7     'pydantic.utils:version_info': 'pydantic.version:version_info',
      8     'pydantic.error_wrappers:ValidationError': 'pydantic:ValidationError',
   (...)
     13     'pydantic.generics:GenericModel': 'pydantic.BaseModel',
     14 }
     16 DEPRECATED_MOVED_IN_V2 = {
     17     'pydantic.tools:schema_of': 'pydantic.deprecated.tools:schema_of',
     18     'pydantic.tools:parse_obj_as': 'pydantic.deprecated.tools:parse_obj_as',
   (...)
     28     'pydantic.config:Extra': 'pydantic.deprecated.config:Extra',
     29 }

ImportError: cannot import name 'version_short' from 'pydantic.version' ([/opt/conda/lib/python3.10/site-packages/pydantic/version.cpython-310-x86_64-linux-gnu.so](https://pef4jrua22w19cq.studio.us-east-1.sagemaker.aws/opt/conda/lib/python3.10/site-packages/pydantic/version.cpython-310-x86_64-linux-gnu.so))


I had the same problem as you, these `requirements` worked for me: 

```
openai==1.17.0
ragas==0.1.7
langchain-core==0.1.40 
```

(On Amazon SageMaker Studio) upgrading `pydantic` from 1.10.14 to 2.6.1 just solved this for me - although that conflicts with some other packages that are installed but I'm not using in my case.

https://github.com/langchain-ai/langchain/discussions/16985