Problems posting model results via the /predict endpoint from a flask based model in interactive mode

I would be really appreciative of any help how to format my models output data.
I get the following output from label studios instance: [ml.models::_get_predictions_from_ml_backend::300] [ERROR] ML backend returns an incorrect response, it must be a dict: {‘model_version’: ‘v1.0’, ‘predictions’: [{‘result’: [{‘from_name’: ‘Was war der ursprüngliche Auftrag?’, ‘id’: ‘75aa891b-cc29-4d30-aafe-45b02c413077’, ‘origin’: ‘prediction’, ‘to_name’: ‘text’, ‘type’: ‘labels’, ‘value’: {‘end’: ‘/p[1]/text()[1]’, ‘endOffset’: 337, ‘labels’: [‘Ursprungsprojekt’], ‘start’: ‘/p[1]/text()[1]’, ‘startOffset’: 331, ‘text’: ‘A21-39’}}], ‘score’: 1.0, ‘task’: 3879}]}

I can upload predictions via the gui and that creates this kind of task source: “predictions”: [
{
“id”: 11,
“result”: [
{
“id”: “PgON9_6f9900”,
“type”: “labels”,
“value”: {
“text”: “A21-39”,
“labels”: [
“Ursprungsprojekt”
],
“endOffset”: 30,
“startOffset”: 24,
“globalOffsets”: {
“end”: 30,
“start”: 24
}
},
“origin”: “prediction”,
“to_name”: “text”,
“from_name”: “Was war der ursprüngliche Auftrag?”
}
]
I just do not get how to adjust my model’s output accordingly.

The full task source is:
{
“id”: 3880,
“data”: {
“html”: “

Addendum zum Auftrag A21-39 is part of the project documentation.


},
“annotations”: ,
“predictions”: [
{
“id”: 11,
“result”: [
{
“id”: “PgON9_6f9900”,
“type”: “labels”,
“value”: {
“text”: “A21-39”,
“labels”: [
“Ursprungsprojekt”
],
“endOffset”: 30,
“startOffset”: 24,
“globalOffsets”: {
“end”: 30,
“start”: 24
}
},
“origin”: “prediction”,
“to_name”: “text”,
“from_name”: “Was war der ursprüngliche Auftrag?”
}
],
“model_version”: “v1.0”,
“created_ago”: “47 minutes”,
“score”: null,
“cluster”: null,
“neighbors”: null,
“mislabeling”: 0,
“created_at”: “2025-01-14T19:27:39.001665Z”,
“updated_at”: “2025-01-14T19:27:39.001671Z”,
“model”: null,
“model_run”: null,
“task”: 3880,
“project”: 1
}
]
}

okay I understood from the repository that this checked:
if not (isinstance(ml_api_result.response, dict) and ‘results’ in ml_api_result.response):
logger.info(f’ML backend returns an incorrect response, it must be a dict: {ml_api_result.response}')
result[‘errors’] = [
'Incorrect response from ML service: ’ ‘ML backend returns an incorrect response, it must be a dict.’
]
return result

So I was puzzled because my data was indeed a dictionary…the code found out that it did not include “results”, so it returned that it wasn’t a dictionary even though it was. I did not find a hint in the documentation that “results” was needed. It would be great to have an example in the documentation (if there is none and I did not just miss it)