You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code
I tried to use evaluate with a LangchainLLMWrapper, however for some it still requires an OpenAI key, here is the code:
from ragrank import evaluate
from ragrank.evaluation import EvalResult
from ragrank.integrations.langchain import LangchainLLMWrapper
from ragrank.dataset import from_dataframe
from ragrank.metric import (
context_relevancy,
response_relevancy
)
from langchain_community.chat_models import ChatOllama
rr_dataset = from_dataframe(df)
ollama_llm = ChatOllama(model='gemma:2b')
ragrank_llm = LangchainLLMWrapper(llm=ollama_llm)
result: EvalResult = evaluate(
dataset=rr_dataset,
llm=ragrank_llm,
metrics=[
response_relevancy,
context_relevancy,
],
)
PS: I do not usally work with Langchain so there is a chance I done something wrong with it, however by the error raised, even if this is the case, it is unclear if that's a bug in the library
Problem
By further inspecting the problem I found that it is happening here:
At that point I don't know what I can try going deeper in the source code (i.e I can't propose a solution), so I point out that problem in hope that you can improve the library. (or tell me what I am doing wrong)
*PS: 'ValueError: OPENAI_API_KEY not found in the environmen.' has a typo, it misses the 't'; *
The text was updated successfully, but these errors were encountered:
Thanks for pointing this out @antoninoLorenzo. I appreciate that you tried to solve it on your own. It is actually a bug in the langchain integration part. it will be resolved in the next release (0.0.8).
I assume that the first problem arose because, in the file evaluation/base.py, there is an import default_llm. it needs to change. and also we are accessing the token_usage property which is only available for a few llms in langchain. Needed to remove the token_usage attribute in langchain integration.
Code
I tried to use
evaluate
with aLangchainLLMWrapper
, however for some it still requires an OpenAI key, here is the code:PS: I do not usally work with Langchain so there is a chance I done something wrong with it, however by the error raised, even if this is the case, it is unclear if that's a bug in the library
Problem
By further inspecting the problem I found that it is happening here:
Solution Attempt
I read trough the source code and tried to find a work around, this was my attempt:
However it yielded another error
KeyError: 'token_usage'
:At that point I don't know what I can try going deeper in the source code (i.e I can't propose a solution), so I point out that problem in hope that you can improve the library. (or tell me what I am doing wrong)
*PS: 'ValueError: OPENAI_API_KEY not found in the environmen.' has a typo, it misses the 't'; *
The text was updated successfully, but these errors were encountered: