-
-
Notifications
You must be signed in to change notification settings - Fork 381
Closed
Description
Issue Type
Bug
Source
source
Giskard Library Version
2.17.0
OS Platform and Distribution
Ubuntu
Python version
3.12
Installed python packages
"docling>=2.36.1",
"giskard[llm]>=2.17.0",
"ipykernel>=6.29.5",
"jupyter>=1.1.1",
"llama-index>=0.12.41",
"llama-index-embeddings-azure-openai>=0.3.8",
"llama-index-embeddings-ollama>=0.6.0",
"llama-index-llms-azure-openai>=0.3.4",
"llama-index-node-parser-docling>=0.3.2",
"llama-index-readers-docling>=0.3.2",
"python-dotenv>=1.1.0",
"ragas>=0.2.15",Current Behaviour?
Here's the code from Giskard's RAGET article:
def answer_fn(
question: str,
history: list[dict] = None,
) -> AgentAnswer:
if history:
answer = chat_engine.chat(
question,
chat_history=[
ChatMessage(**chat_history_dict) for chat_history_dict in history
],
)
else:
answer = chat_engine.chat(question, chat_history=[])
return AgentAnswer(
message = str(answer),
documents=[source.content for source in answer.sources]
)
report = evaluate(
answer_fn, testset=testset,
knowledge_base=knowledge_base,
metrics=[ragas_context_recall, ragas_context_precision],
)
I expected this to generate a comprehensive report evaluating the RAG applicationStandalone code OR list down the steps to reproduce the issue
...
File ~/bug-free-octo-pancake/.venv/lib/python3.12/site-packages/giskard/rag/metrics/ragas_metrics.py:98, in RagasMetric.__call__(self, question_sample, answer)
96 self.ragas_llm = RagasLLMWrapper(llm_client, self.context_window_length)
97 if self.ragas_embeddings is None:
---> 98 self.ragas_embeddings = RagasEmbeddingsWrapper(embedding_model)
100 run_config = RunConfig()
102 if hasattr(self.metric, "llm"):
TypeError: Can't instantiate abstract class RagasEmbeddingsWrapper without an implementation for abstract methods 'aembed_documents', 'aembed_query'
This is because the `RagasEmbeddingsWrapper` class in giskard > rag > metrics > ragas_metrics.py does not implement the abstract methods from the `BaseRagasEmbeddings` class:
class RagasEmbeddingsWrapper(BaseRagasEmbeddings):
def __init__(self, embedding_model):
self.embedding_model = embedding_model
def embed_query(self, text: str) -> Sequence[float]:
return self.embedding_model.embed([text])[0]
def embed_documents(self, texts: Sequence[str]) -> Sequence[Sequence[float]]:
return self.embedding_model.embed(texts)Can I just implement it like this?
class RagasEmbeddingsWrapper(BaseRagasEmbeddings):
def __init__(self, embedding_model):
self.embedding_model = embedding_model
def embed_query(self, text: str) -> Sequence[float]:
return self.embedding_model.embed([text])[0]
def embed_documents(self, texts: Sequence[str]) -> Sequence[Sequence[float]]:
return self.embedding_model.embed(texts)
async def aembed_query(self, text: str) -> Sequence[float]:
return await self.embedding_model.aembed([text])[0]
async def aembed_documents(self, texts: Sequence[str]) -> Sequence[Sequence[float]]:
return await self.embedding_model.aembed(texts)
Metadata
Metadata
Assignees
Labels
No labels