Implementation:Explodinggradients Ragas Griptape Integration
| Metadata | Value |
|---|---|
| Source | src/ragas/integrations/griptape.py (Lines 13-61)
|
| Domains | Integration, Griptape |
| Last Updated | 2026-02-10 |
Overview
Converts Griptape RAG context objects into a Ragas EvaluationDataset, enabling evaluation of Griptape RAG pipelines with Ragas metrics.
Description
The transform_to_ragas_dataset function takes a list of Griptape RagContext objects and optional reference data, then constructs a Ragas EvaluationDataset suitable for metric evaluation. For each RagContext:
- The user_input is extracted from
RagContext.query. - The retrieved_contexts are built by calling
to_text()on each text chunk inRagContext.text_chunks. - The response is produced by joining the text representations of all outputs in
RagContext.outputswith newlines.
The function validates that all provided non-None lists have the same length, raising a ValueError on length mismatches. Optional parameters (reference_contexts, references, rubrics) are mapped per-sample when provided or set to None otherwise.
Usage
Use this function when you have Griptape RAG pipeline results and want to evaluate them using Ragas metrics such as faithfulness, context precision, or answer correctness. It bridges the gap between Griptape's data structures and Ragas' evaluation API.
Code Reference
Source Location
| Item | Detail |
|---|---|
| File | src/ragas/integrations/griptape.py
|
| Lines | 13-61 |
| Module | ragas.integrations.griptape
|
Signature
def transform_to_ragas_dataset(
grip_tape_rag_contexts: List[RagContext],
reference_contexts: Optional[List[str]] = None,
references: Optional[List[str]] = None,
rubrics: Optional[List[Dict[str, str]]] = None,
) -> EvaluationDataset
Import
from ragas.integrations.griptape import transform_to_ragas_dataset
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
grip_tape_rag_contexts |
List[RagContext] |
Yes | List of Griptape RAG context objects containing queries, text chunks, and outputs |
reference_contexts |
Optional[List[str]] |
No | Ground-truth reference contexts for each sample |
references |
Optional[List[str]] |
No | Ground-truth reference answers for each sample |
rubrics |
Optional[List[Dict[str, str]]] |
No | Evaluation rubrics for each sample |
Outputs
| Name | Type | Description |
|---|---|---|
| (return) | EvaluationDataset |
A Ragas evaluation dataset with samples containing user_input, retrieved_contexts, response, and optional reference fields
|
Exceptions
| Exception | Condition |
|---|---|
ValueError |
When provided lists have inconsistent lengths |
ImportError |
When the griptape package is not installed
|
Usage Examples
Basic Conversion from Griptape RAG Contexts
from ragas.integrations.griptape import transform_to_ragas_dataset
# Assuming you have Griptape RagContext objects from a RAG pipeline
# rag_contexts = [context1, context2, context3]
dataset = transform_to_ragas_dataset(
grip_tape_rag_contexts=rag_contexts,
)
# The dataset can now be evaluated with Ragas metrics
print(len(dataset.samples))
Conversion with Reference Data
from ragas.integrations.griptape import transform_to_ragas_dataset
# With ground-truth references for metrics like answer correctness
dataset = transform_to_ragas_dataset(
grip_tape_rag_contexts=rag_contexts,
references=["Expected answer 1", "Expected answer 2"],
reference_contexts=["Ground truth context 1", "Ground truth context 2"],
)
# Evaluate with Ragas
from ragas import evaluate
from ragas.metrics import faithfulness, answer_correctness
results = evaluate(dataset=dataset, metrics=[faithfulness, answer_correctness])
Related Pages
- R2R Integration - Similar transform function for R2R response objects
- Amazon Bedrock Integration - Another integration that extracts RAG contexts from agent traces
- LlamaIndex Integration - Evaluates LlamaIndex query engines using the same
EvaluationDatasetformat