Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions src/ragas/embeddings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,18 @@ class LangchainEmbeddingsWrapper(BaseRagasEmbeddings):
"""
Wrapper for any embeddings from langchain.

.. deprecated::
LangchainEmbeddingsWrapper is deprecated and will be removed in a future version.
Use the modern embedding providers directly with embedding_factory() instead:

# Instead of:
# embedder = LangchainEmbeddingsWrapper(langchain_embeddings)

# Use:
# embedder = embedding_factory("openai", model="text-embedding-3-small", client=openai_client)
# embedder = embedding_factory("huggingface", model="sentence-transformers/all-MiniLM-L6-v2")
# embedder = embedding_factory("google", client=vertex_client)
# TODO: Revisit deprecation warning
# .. deprecated::
# LangchainEmbeddingsWrapper is deprecated and will be removed in a future version.
# Use the modern embedding providers directly with embedding_factory() instead:
#
# # Instead of:
# # embedder = LangchainEmbeddingsWrapper(langchain_embeddings)
#
# # Use:
# # embedder = embedding_factory("openai", model="text-embedding-3-small", client=openai_client)
# # embedder = embedding_factory("huggingface", model="sentence-transformers/all-MiniLM-L6-v2")
# # embedder = embedding_factory("google", client=vertex_client)
"""

def __init__(
Expand All @@ -266,16 +267,15 @@ def __init__(
run_config: t.Optional[RunConfig] = None,
cache: t.Optional[CacheInterface] = None,
):
import warnings

warnings.warn(
"LangchainEmbeddingsWrapper is deprecated and will be removed in a future version. "
"Use the modern embedding providers instead: "
"embedding_factory('openai', model='text-embedding-3-small', client=openai_client) "
"or from ragas.embeddings import OpenAIEmbeddings, GoogleEmbeddings, HuggingFaceEmbeddings",
DeprecationWarning,
stacklevel=2,
)
# TODO: Revisit deprecation warning
# warnings.warn(
# "LangchainEmbeddingsWrapper is deprecated and will be removed in a future version. "
# "Use the modern embedding providers instead: "
# "embedding_factory('openai', model='text-embedding-3-small', client=openai_client) "
# "or from ragas.embeddings import OpenAIEmbeddings, GoogleEmbeddings, HuggingFaceEmbeddings",
# DeprecationWarning,
# stacklevel=2,
# )
super().__init__(cache=cache)
self.embeddings = embeddings
if run_config is None:
Expand Down Expand Up @@ -513,17 +513,18 @@ class LlamaIndexEmbeddingsWrapper(BaseRagasEmbeddings):
"""
Wrapper for any embeddings from llama-index.

.. deprecated::
LlamaIndexEmbeddingsWrapper is deprecated and will be removed in a future version.
Use the modern embedding providers directly with embedding_factory() instead:

# Instead of:
# embedder = LlamaIndexEmbeddingsWrapper(llama_index_embeddings)

# Use:
# embedder = embedding_factory("openai", model="text-embedding-3-small", client=openai_client)
# embedder = embedding_factory("huggingface", model="sentence-transformers/all-MiniLM-L6-v2")
# embedder = embedding_factory("google", client=vertex_client)
# TODO: Revisit deprecation warning
# .. deprecated::
# LlamaIndexEmbeddingsWrapper is deprecated and will be removed in a future version.
# Use the modern embedding providers directly with embedding_factory() instead:
#
# # Instead of:
# # embedder = LlamaIndexEmbeddingsWrapper(llama_index_embeddings)
#
# # Use:
# # embedder = embedding_factory("openai", model="text-embedding-3-small", client=openai_client)
# # embedder = embedding_factory("huggingface", model="sentence-transformers/all-MiniLM-L6-v2")
# # embedder = embedding_factory("google", client=vertex_client)

This class provides a wrapper for llama-index embeddings, allowing them to be used
within the Ragas framework. It supports both synchronous and asynchronous embedding
Expand Down Expand Up @@ -557,16 +558,15 @@ def __init__(
run_config: t.Optional[RunConfig] = None,
cache: t.Optional[CacheInterface] = None,
):
import warnings

warnings.warn(
"LlamaIndexEmbeddingsWrapper is deprecated and will be removed in a future version. "
"Use the modern embedding providers instead: "
"embedding_factory('openai', model='text-embedding-3-small', client=openai_client) "
"or from ragas.embeddings import OpenAIEmbeddings, GoogleEmbeddings, HuggingFaceEmbeddings",
DeprecationWarning,
stacklevel=2,
)
# TODO: Revisit deprecation warning
# warnings.warn(
# "LlamaIndexEmbeddingsWrapper is deprecated and will be removed in a future version. "
# "Use the modern embedding providers instead: "
# "embedding_factory('openai', model='text-embedding-3-small', client=openai_client) "
# "or from ragas.embeddings import OpenAIEmbeddings, GoogleEmbeddings, HuggingFaceEmbeddings",
# DeprecationWarning,
# stacklevel=2,
# )
super().__init__(cache=cache)
self.embeddings = embeddings
if run_config is None:
Expand Down
30 changes: 16 additions & 14 deletions src/ragas/llms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ class LangchainLLMWrapper(BaseRagasLLM):
- generate_text: for generating text from a given PromptValue
- agenerate_text: for generating text from a given PromptValue asynchronously

.. deprecated::
LangchainLLMWrapper is deprecated and will be removed in a future version.
Use llm_factory instead:
from openai import OpenAI
from ragas.llms import llm_factory
client = OpenAI(api_key="...")
llm = llm_factory("gpt-4o-mini", client=client)
# TODO: Revisit deprecation warning
# .. deprecated::
# LangchainLLMWrapper is deprecated and will be removed in a future version.
# Use llm_factory instead:
# from openai import OpenAI
# from ragas.llms import llm_factory
# client = OpenAI(api_key="...")
# llm = llm_factory("gpt-4o-mini", client=client)
"""

def __init__(
Expand Down Expand Up @@ -342,13 +343,14 @@ class LlamaIndexLLMWrapper(BaseRagasLLM):
"""
A Adaptor for LlamaIndex LLMs

.. deprecated::
LlamaIndexLLMWrapper is deprecated and will be removed in a future version.
Use llm_factory instead:
from openai import OpenAI
from ragas.llms import llm_factory
client = OpenAI(api_key="...")
llm = llm_factory("gpt-4o-mini", client=client)
# TODO: Revisit deprecation warning
# .. deprecated::
# LlamaIndexLLMWrapper is deprecated and will be removed in a future version.
# Use llm_factory instead:
# from openai import OpenAI
# from ragas.llms import llm_factory
# client = OpenAI(api_key="...")
# llm = llm_factory("gpt-4o-mini", client=client)
"""

def __init__(
Expand Down
Loading