Repository: explodinggradients/ragas
Issue: TypeError: 'float' object is not subscriptable when using answer_correctness metric in evaluate()
Root cause: Validation Gap

[x] I have checked the [documentation](https://docs.ragas.io/) and related resources and couldn't resolve my bug.

When evaluating RAG metrics with answer_correctness, getting "'float' object is not subscriptable" error. This occurs when trying to parse the evaluation results.
Ragas version: 0.2.8
Python version: 3.10.14


```py
from ragas.metrics import (
    faithfulness,
    answer_relevancy,
    answer_correctness,
    context_recall,
    context_precision,
)
from ragas import evaluate
from ragas.run_config import RunConfig
from langchain_openai import AzureChatOpenAI
from langchain.callbacks import StreamingStdOutCallbackHandler
from langchain.callbacks.manager import CallbackManager

llm_eval = AzureChatOpenAI(
    openai_api_version="2024-02-15-preview",
    azure_deployment="your_deployment",
    temperature=0,
    streaming=False,
    callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]),
    verbose=False,
    max_tokens=3000
)

from ragas.embeddings.base import LangchainEmbeddingsWrapper
my_run_config = RunConfig(max_workers=1, timeout=300)
embedding_wrapper = LangchainEmbeddingsWrapper(embeddings2, my_run_config)

metrics = [
    answer_correctness,
]

naive_results = evaluate(
    response_dataset, 
    metrics, 
    raise_exceptions=True,
    llm=llm_eval, 
    embeddings=embedding_wrapper, 
    run_config=my_run_config
)
```


TypeError: 'float' object is not subscriptable

The evaluation should complete successfully and return metrics scores for the answer_correctness measurement without throwing a float subscripting error.

The error occurs specifically with the answer_correctness metric
Other metrics like answer_relevancy seem to work fine
The error suggests that somewhere in the evaluation pipeline, the code is trying to treat a float value as an array/list
Using Azure OpenAI as the LLM provider




Hello,
I have the same error with the following code and metrics :

```from ragas import evaluate
from ragas.metrics import NonLLMContextRecall, NonLLMContextPrecisionWithReference
from ragas import SingleTurnSample, EvaluationDataset

sample = SingleTurnSample(
    retrieved_contexts=["Paris is the capital of France."], 
    reference_contexts=["Paris is the capital of France.", "The Eiffel Tower is one of the most famous landmarks in Paris."]
)
dataset = EvaluationDataset(samples=[sample])

metrics = [
    NonLLMContextRecall(),
    NonLLMContextPrecisionWithReference(),
]

result = evaluate(
    dataset,
    metrics=metrics,
)
```

-> **TypeError: 'float' object is not subscriptable**
The evaluation seems to go all the way and causes an error just before returning the result.

I solved the problem by **downgrading the ragas version from 0.2.8 to 0.2.7** (while waiting for a patch)

Lib\site-packages\ragas\callbacks.py
这个路径下的文件
![image](https://github.com/user-attachments/assets/45413687-9a59-4988-bc1f-1309af256562)
把[0]去掉

Hi @LouisMlr @seroetr,

We’ve made updates to address the issue. Please try the latest version of Ragas, and give it another go. You can refer to the code below as refrence:

```py
from ragas.metrics import NonLLMContextRecall, NonLLMContextPrecisionWithReference
from ragas import SingleTurnSample, EvaluationDataset
from ragas import evaluate
from ragas.llms import LangchainLLMWrapper
from langchain_openai.embeddings import OpenAIEmbeddings
from langchain_openai import ChatOpenAI

evaluator_llm = LangchainLLMWrapper(ChatOpenAI(model="gpt-4o-mini"))
embeddings = OpenAIEmbeddings(model="text-embedding-3-small")

sample = SingleTurnSample(
    retrieved_contexts=["Paris is the capital of France."],
    reference_contexts=[
        "Paris is the capital of France.",
        "The Eiffel Tower is one of the most famous landmarks in Paris.",
    ],
)
dataset = EvaluationDataset(samples=[sample])

metrics = [
    NonLLMContextRecall(),
    NonLLMContextPrecisionWithReference(),
]

result = evaluate(
    dataset,
    metrics=metrics,
)
```
Output
```
{'non_llm_context_recall': 0.5000, 'non_llm_context_precision_with_reference': 1.0000}
```

@Serious-Hao 非常感谢你的帮助

It seems the issue was answered, closing this now.