Repository: explodinggradients/ragas
Issue: Ragas & Tonic Validate: Field required Error
Root cause: External Dependency Breakage

**Your Question**
I am just asking if Ragas integration is still working with Tonic Validate since the code provided in their documentation is not working: https://validate.tonic.ai/

 Below is a code that is supposed to calculate the score on a benchmark composed of one question.

**Code Examples**
```python
from ragas import evaluate
import json
from datasets import Dataset
from tonic_ragas_logger import RagasValidateApi

#Case of no restriction
data_samples = {"question": [], "answer": [], "contexts": [], "ground_truth": []}

with open("reponse_rag_testset_one_question.json", "r", encoding="utf-8") as file:
    reponse_data = json.load(file)

for item in reponse_data:
    data_samples["answer"].append(item["answer"][0])
    data_samples["question"].append(item["question"])
    data_samples["contexts"].append(item["context"])
    data_samples["ground_truth"].append(item["ground_truth"])

dataset = Dataset.from_dict(data_samples)
scores = evaluate(
        dataset, metrics=metrics, llm=azure_model, embeddings=azure_embeddings
    )

#send the score to Tonic Validate
validate_api = RagasValidateApi("G6ph3yz5hk47bQIUtRKMqfF7y8GgiJ-uBLrv6-GNmtU")
validate_api.upload_results("f5aa069e-924b-4723-a5b5-ced06f9b8ab7", scores)
```

**Error**
I also provide here the error message when running the code:
```python
Traceback (most recent call last):
  File "c:\Users\adle.bensalem\Downloads\RAG-HES-SO\ragas_evaluate.py", line 90, in <module>
    validate_api.upload_results("f5aa069e-924b-4723-a5b5-ced06f9b8ab7", scores)
  File "C:\Users\adle.bensalem\AppData\Local\Programs\Python\Python312\Lib\site-packages\tonic_ragas_logger\ragas_validate_api.py", line 56, in upload_results
    run = self.__convert_to_run(results)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\adle.bensalem\AppData\Local\Programs\Python\Python312\Lib\site-packages\tonic_ragas_logger\ragas_validate_api.py", line 124, in __convert_to_run
    return Run(
           ^^^^
  File "C:\Users\adle.bensalem\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydantic\_internal\_dataclasses.py", line 141, in __init__
    s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Run
llm_evaluator
  Field required [type=missing, input_value=ArgsKwargs((), {'overall_...onner.'])], 'id': None}), input_type=ArgsKwargs]
  ```




<!-- Answer -->
The error you're encountering indicates that the `llm_evaluator` field is missing when creating a `Run` object in the `tonic_ragas_logger` library. Unfortunately, the specific requirements and structure for the `llm_evaluator` field are not detailed in the provided context.

However, based on the error message and typical usage patterns, it seems that the `llm_evaluator` field is required and must be populated correctly. Here is a general approach to address this issue:

1. **Ensure `llm_evaluator` is Provided**: Make sure that the `llm_evaluator` field is included when creating the `Run` object. This field likely needs to be populated with an evaluator object or relevant information about the language model used.

2. **Check Documentation and Examples**: Refer to the `tonic_ragas_logger` documentation or examples to understand the expected structure and type for the `llm_evaluator` field. If the documentation is not clear, you might need to inspect the source code or any available test cases.

3. **Modify the Code**: Update your code to include the `llm_evaluator` field when creating the `Run` object. Here is a modified version of your code with a placeholder for the `llm_evaluator` field:

    ```python
    from ragas import evaluate
    import json
    from datasets import Dataset
    from tonic_ragas_logger import RagasValidateApi

    # Case of no restriction
    data_samples = {"question": [], "answer": [], "contexts": [], "ground_truth": []}

    with open("reponse_rag_testset_one_question.json", "r", encoding="utf-8") as file:
        reponse_data = json.load(file)

    for item in reponse_data:
        data_samples["answer"].append(item["answer"][0])
        data_samples["question"].append(item["question"])
        data_samples["contexts"].append(item["context"])
        data_samples["ground_truth"].append(item["ground_truth"])

    dataset = Dataset.from_dict(data_samples)
    scores = evaluate(
        dataset, metrics=metrics, llm=azure_model, embeddings=azure_embeddings
    )

    # Send the score to Tonic Validate
    validate_api = RagasValidateApi("G6ph3yz5hk47bQIUtRKMqfF7y8GgiJ-uBLrv6-GNmtU")
    validate_api.upload_results("f5aa069e-924b-4723-a5b5-ced06f9b8ab7", scores, llm_evaluator=your_llm_evaluator)
    ```

Replace `your_llm_evaluator` with the appropriate evaluator object or information required by the `llm_evaluator` field.

If you need more specific guidance on the `llm_evaluator` field, you may need to refer to the `tonic_ragas_logger` library's documentation or source code for detailed information.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*


@Jeerhz we don't actually maintain that integration, the Tonic team does. Could you raise an Issue there?

sorry about this

It seems the issue was answered, closing this now.

@Jeerhz This issue has been addressed. Sorry for the (long) delay here.  Please upgrade to v1.2.3