Repository: explodinggradients/ragas
Issue: AttributeError("'list' object has no attribute 'get'") when calculating metrics score
Root cause: Validation Gap

**Describe the bug**
item in response should be an obj but exception throws for "'list' object has no attribute 'get'" when _calculate_score() at _answer_relevance class.

Ragas version: from main branch
Python version: 3.11

**Code to Reproduce**
dataset = Dataset.from_dict(data)


from ragas.metrics import (
    answer_relevancy,
    faithfulness,
    context_recall,
    context_precision,
    context_relevancy,
)
from ragas.metrics.critique import harmfulness

metrics = [
    faithfulness,
    answer_relevancy,
    context_recall,
    context_precision,
    harmfulness,
    context_relevancy
]

answer_relevancy.embeddings = azure_embeddings

from ragas import evaluate

result = evaluate(
    llm=azure_model,
    dataset=dataset, # selecting only 3
    metrics=[
        context_precision,
        faithfulness,
        answer_relevancy,
        context_recall,
        context_relevancy
    ],
)
**Error trace**
[chain/error] [122:chain:row 120 > 125:chain:answer_relevancy] [6.01s] Chain run errored with error:
"AttributeError("'list' object has no attribute 'get'")Traceback (most recent call last):\n\n\n  File "C:\Users\allenpan\Anaconda\envs\rag_experiment\Lib\site-packages\ragas\metrics\base.py", line 71, in score\n    score = self._score(row=row, callbacks=group_cm)\n            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File "C:\Users\allenpan\Anaconda\envs\rag_experiment\Lib\site-packages\ragas\metrics\_answer_relevance.py", line 128, in _score\n    return self._calculate_score(response, row)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File "C:\Users\allenpan\Anaconda\envs\rag_experiment\Lib\site-packages\ragas\metrics\_answer_relevance.py", line 104, in _calculate_score\n    gen_questions = [item.get("question", "") for item in response]\n                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File "C:\Users\allenpan\Anaconda\envs\rag_experiment\Lib\site-packages\ragas\metrics\_answer_relevance.py", line 104, in <listcomp>\n    gen_questions = [item.get("question", "") for item in response]\n                     ^^^^^^^^\n\n\nAttributeError: 'list' object has no attribute 'get'"

**Expected behavior**
the item should be an object which has the "question" field

**Additional context**
Add any other context about the problem here.


Hi @HuskyDanny ,thanks for reporting this issue. Does this occur everytime you try to use the metric?

Hi @shahules786, from my experience, it depends on the dataset length. If I have only 5 rows, it succeeds without the error. But if I inject 100 other synthetic rows, there would be an error for some rows which would cause the exception.

I see, so there seems to be an unhandled edge case. I'll raise a fix soon. @HuskyDanny 

Hi, same problem here! can you provide a solution?

I have the same issue for context precision still:

```
'list' object has no attribute 'get'

ragas\metrics\_context_precision.py", line 98, in <listcomp>
    if resp.get("verdict")
       ^^^^^^^^
```


same error with answer_correctness