Skip to content

How to use ChatAnthropicVertex without replying on LangchainLLMWrapper #2388

@dcaled

Description

@dcaled

[x] I checked the documentation and related resources and couldn't find an answer to my question.

Your Question
I'm struggling with LangchainLLMWrapper deprecation warning.
The current version of my faithfullness metric was implemented like this:

from ragas.metrics import Faithfulness
from ragas import SingleTurnSample
from langchain_google_vertexai.model_garden import ChatAnthropicVertex

llm = ChatAnthropicVertex(
    credentials=my_credentials,
    project=my_project,
    location="us-east5",
    model="claude-3-5-sonnet-v2@20241022",
    temperature=0.0,
    top_p=0.0,
)

ragas_llm = LangchainLLMWrapper(llm)

scorer = Faithfulness(llm=ragas_llm)
sample = SingleTurnSample(
    user_input="qual a capital do brasil?",
    response="a capital do brasil é sao paulo",
    retrieved_contexts=["sao paulo é a capital do brasil", "brasilia é a capital do brasil"],
)

score = await scorer.single_turn_ascore(sample)
print(score)

And it's working, but I keep getting this deprecating warning message:

DeprecationWarning: LangchainLLMWrapper is deprecated and will be removed in a future version. Use the modern LLM providers instead: from ragas.llms.base import llm_factory; llm = llm_factory('gpt-4o-mini') or from ragas.llms.base import instructor_llm_factory; llm = instructor_llm_factory('openai', client=openai_client)

The thing is: I cannot/don't know how to fix it. I tried using llm_factory and instructor_llm_factorywithout success. Can you help me by providing an example of how to use ChatAnthropicVertex correctly? I checked the documentation and could not find it.

Ragas version: 0.3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    answered🤖 The question has been answered. Will be closed automatically if no new commentsquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions