How to fix the error "TypeError: Cannot use 'in' operator to search for 'reject' in undefined" for my multi-question recipe?

I have been trying to use the following recipe .py file to set up a multi-question annotation task. Although I don't face an error on terminal and the local host address is generated, when I open my localhost I keep seeing the error in the attached image. Does anyone know how to resolve this error "TypeError: Cannot use 'in' operator to search for 'reject' in undefined"? Thank you so much

Here is the recipe.py file:

import prodigy
from prodigy.components.loaders import JSONL

@prodigy.recipe(
    "multi_question",
    dataset=("The dataset to save annotations", "positional", None, str),
    file_path=("Path to the JSONL data", "positional", None, str),
)
def multi_question(dataset, file_path):
    # Load the data from the JSONL file
    stream = JSONL(file_path)
    
    return {
        "dataset": dataset,  # The dataset to save annotations
        "view_id": "blocks",  # Use "blocks" to combine multiple interfaces
        "stream": stream,  # Stream the data from the JSONL file
        "config": {
            "blocks": [
                {
                    "view_id": "text",  # Show the text first
                    "text_field": "text"
                },
                {
                    "view_id": "choice",  # The first question is a multiple choice
                    "question": "What is the sentiment of this text?",
                    "choices": [
                        {"id": "positive", "label": "Positive"},
                        {"id": "neutral", "label": "Neutral"},
                        {"id": "negative", "label": "Negative"}
                    ]
                },
                {
                    "view_id": "choice",  # The second question, also multiple choice
                    "question": "Is this a question or a statement?",
                    "choices": [
                        {"id": "question", "label": "Question"},
                        {"id": "statement", "label": "Statement"}
                    ]
                },
                {
                    "view_id": "text_input",  # Third question for free-form text input
                    "question": "Any additional comments?",
                    "field_rows": 3  # Number of rows for the input field
                }
            ]
        }
    }

Here is the error I see:

Welcome to the forum @arya75 :wave:

I went ahead and formatted your recipe.py as a code snippet - I'm pretty sure you'll agree it helps readability :slight_smile:

The problem is that that your defnition blocks contains arbitrary keys such as question or choices. For Prodigy to be able to render correctly the UI, the blocks defnition must use pre-defined keys. You can find all these keys documented in "Annotation interfaces" section of out docs:

Here's the fixed version of your script:

import prodigy
from prodigy.components.loaders import JSONL

@prodigy.recipe(
    "multi_question",
    dataset=("The dataset to save annotations", "positional", None, str),
    file_path=("Path to the JSONL data", "positional", None, str),
)
def multi_question(dataset, file_path):
    # Load the data from the JSONL file
    stream = JSONL(file_path)
    
    return {
        "dataset": dataset,  # The dataset to save annotations
        "view_id": "blocks",  # Use "blocks" to combine multiple interfaces
        "stream": stream,  # Stream the data from the JSONL file
        "config": {
            "blocks": [
                {
                    "view_id": "text",
                    "text_field": "text"
                },
                {
                    "view_id": "choice",
                    "text": "What is the sentiment of this text?", # changed the key question -> text
                    "options": [ # changed the key choices -> options
                        {"id": "positive", "text": "Positive"}, # changed the key label -> text 
                        {"id": "neutral", "text": "Neutral"},
                        {"id": "negative", "text": "Negative"}
                    ]
                },
                {
                    "view_id": "choice",  # The second question, also multiple choice
                    "text": "Is this a question or a statement?",
                    "options": [
                        {"id": "question", "text": "Question"},
                        {"id": "statement", "text": "Statement"}
                    ]
                },
                {
                    "view_id": "text_input",  # Third question for free-form text input
                    "question": "Any additional comments?",
                    "field_rows": 3  # Number of rows for the input field
                }
            ]
        }
    }

That said, I admit that the error message is not helpful at all. As a matter of fact, we are currently implementing a better data validation procedures and errors that you can expect to be available in our next release.