Custom recipe with Text_input block

Hi there,

I am trying to create a simple 2-block interface including plain text for NER annotation and a comment box for translation. I've tailored the relevant documentation to suit my project:

import prodigy

@prodigy.recipe("custom_recipe")

def custom_recipe(ner_test_data,lang="en"):

        blocks = [
                {"view_id": "ner_manual"},
                {"view_id": "text_input","field_rows": 3, "field_label": "Explain your decision"},
        ]

        return { 
            "dataset": ner_test_data,
            "view_id":"blocks",
            "config": {
                "blocks": blocks
            }
        }

The code runs successfully , however the web interface does not render a text_input box so I am clearly missing something!

i am running the following command:

$ prodigy ner.manual ner_test_data blank:en ~/Desktop/Test/test.jsonl --label ABSOLUTE,EMPHATIC,NSTRUCT -F ~/Desktop/Test/custom_recipe.py

Hi! The problem here is that you're running the built-in ner.manual command, not your custom recipe, which is called custom_recipe. So to run that recipe from the file, you want to start with prodigy custom_recipe.

Your custom recipe should also include the required arguments that you want to pass in – at the moment, it's only taking a name of a dataset and a positional argument lang, and it's not actually returning a "stream" of examples to annotate. Instead, you probably want to model your recipe after the existing ner.manual and include all the required CLI options, as well as tokenization within the recipe, loading the stream etc:

1 Like

Ah, it just clicked! Got it working now, thanks Ines :slight_smile: I assume there's currently no way to customise the font size of this text_input/comment box? It just seems to default to the same size as in the main text (which I've configured via custom_theme in prodigy.json).

That's the default, yes! If you want to, you can always provide custom CSS overrides for pretty much anything in the UI via the "global_css" config setting in your prodigy.json. So you could do something like this:

"global_css": "input[type='text'], textarea { font-size: 20px; }"
1 Like

Perfect, thanks Ines!