Repository: confident-ai/deepeval
Issue: [Task]NodeOutput should escape value strings to avoid accidentally interpreting them as data and failing pydantic validation
Root cause: Validation Gap

**Describe the bug**
In using DAG evals, if the output of a TaskNode can be parsed as JSON, it will be. The pydantic model managing the TaskNode's result expects a string and will raise a validation error if the output contains valid JSON (thanks to the recursive parsing nature of `json.loads(jsonStr)`)

**To Reproduce**
Create task nodes that are extracting specific pieces of text that "looks like" json. e.g.
```txt
ACTUAL_OUTPUT
"{'what': ['Accident Count'], 'when': ['2017', '2014', '2020', '2016', '2018', '2022', '2015', '2019', '2021', '2023'], 'where': ['Orlando', 'Orange County', 'Florida']}"

EXPECTED_OUTPUT:
"{'what': ['Accident Count'], 'when': ['2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023'], 'where': ['Florida', 'Orange County, FL', 'Orlando, FL']}"
```

Here the task nodes are being asked to focus on a specific part of the list.
```python
    # 1b) extract golden labels
    extract_goldens_node = dag.TaskNode(
        instructions=f"Extract the list of `what` labels from EXPECTED_OUTPUT",
        evaluation_params=[evals_test_case.LLMTestCaseParams.EXPECTED_OUTPUT],
        output_label=GOLDEN_LABELS_NAME,
        children=[coverage_node, purity_node, specificity_node],
    )

    # 1a) extract actual labels
    extract_actuals_node = dag.TaskNode(
        instructions=f"Extract the list of `what` labels from ACTUAL_OUTPUT",
        evaluation_params=[evals_test_case.LLMTestCaseParams.ACTUAL_OUTPUT],
        output_label=ACTUAL_LABELS_NAME,
        children=[coverage_node, purity_node, specificity_node],
    )

    graph = dag.DeepAcyclicGraph(root_nodes=[extract_actuals_node, extract_goldens_node])
    metric = metrics.DAGMetric(name=f"Correctness of {dim} labels", dag=graph)
```
Note the error:
```   with get_openai_callback() as cb:
            res = await chat_model.ainvoke(prompt)
            if schema:
                json_output = trim_and_load_json(res.content)
>               return schema.model_validate(json_output), cb.total_cost
E               pydantic_core._pydantic_core.ValidationError: 1 validation error for TaskNodeOutput
E               output
E                 Input should be a valid string [type=string_type, input_value=['Accident Count'], input_type=list]
E                   For further information visit https://errors.pydantic.dev/2.11/v/string_type
```

A simpler reproduction would be to call GPTModel.generate/a_generate with the parameters:
```python
prompt='Given the following instructions, generate an output.\n\nExtract the list of `what` labels from ACTUAL_OUTPUT\n\nActual Output:\n{\'what\': [\'Accident Count\'], \'when\': [\'2017\', \'2014\', \'2020\', \'2016\', \'2018\', \'2022\', \'2015\', \'2019\', \'2021\', \'2023\'], \'where\': [\'Orlando\', \'Orange County\', \'Florida\']}\n\n\n===END OF INSTRUCTIONS===\n\n**\nIMPORTANT: Please make sure to only return in JSON format, with the \'output\' key as the output from the instructions.\nExample JSON:\n{\n    "output": "your output goes here"\n}\n**\n\nJSON:\n',
schema=deepeval.metrics.dag.schema.TaskNodeOutput
```

which will result in `json_output == {"output": ["Accident Count"]}` (which fails schema validation)

**Expected behavior**
Escape output, stop decoding json and leave the value of output as a string, or allow any valid json decoded types as the value of output and handle encoding them into subsequent requests smartly.


@marr75 changed this in latest PR, will ping you once its out in ~12 hours!

Great!

I think product teams should be going nuts over DAG evaluation. PM/BA describes how they wish the AI worked, you decompose that a little into a graph, boom, ~objective (enough) ~deterministic (enough) LLM as judge evals!

Hey @marr75 its released! Can you lmk if it solves the problem? :)