I get the following error when I try to run the recipe below:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.[missing argument]
The intention of this code is to ask a series of questions, one after the other, about a single response to a single query, then move on to asking the same questions about another response to a different query.
My assumption was that the task text and options would automatically be applied to the choice block. I might be mistaken.
I have created an Excel file that should work with this program without containing propriety information (the code has also been modified to remove anything proprietary), but I'm not able to actually upload this Excel file as an attachment, so I'm linking a Google sheet with the same content:
import pandas as pd
import prodigy
from prodigy.core import recipe
from prodigy.components.stream import get_stream
from pathlib import Path
import json
df = pd.read_excel('./data/feedback_mwe.xlsx')
texts = []
responses = []
metas = []
for i, row in df.iterrows():
meta = {}
meta['SME'] = row['SME']
meta['id'] = row['Query ID']
text = row['Query']
response = row['Query Response']
meta['url'] = row['Response URL']
texts.append(text)
responses.append(response)
metas.append(meta)
label_cols = ['Comprehension',
'Correctness',
'Completeness',
'Clinical Harmfulness',
'Clinical Harmfulness Level',
'Overall Answer']
labels = {'Comprehension': ['Option 0',
'Option 1',
'Option 2'],
'Correctness': ['Option 0',
'Option 1',
'Option 2',
'Option 3',
'Option 4'],
'Completeness': ['Option 0',
'Option 1',
'Option 2'],
'Clinical Harmfulness': ['Option 0', 'Option 1'],
'Clinical Harmfulness Level': ['Option 0',
'Option 1',
'Option 2',
'Option 3',
'Option 4'],
'Overall Answer': ['🙁', '😐', '😀']}
def compose_json(texts, responses, metas, label_cols):
json_ = []
for text, response, meta in zip(texts, responses, metas):
for labelcol in label_cols:
dict_ = {}
dict_['meta'] = meta.copy()
dict_['text'] = ['Query: %s\n\n\nResponse: %s' % (text, response)]
dict_['meta']['labelcol'] = labelcol
json_.append(dict_)
with open('data/feedback_Vaccine_guidelines.json', 'w') as f:
json.dump(json_, f)
compose_json(texts, responses, metas, label_cols)
@prodigy.recipe("vaccine-guidelines")
def annotate():
file_path = Path('./data/feedback_Vaccine_guidelines.json')
dataset = './data/dataset.json'
stream = get_stream(file_path)
stream = add_options(stream)
blocks = [{'view_id': 'html', 'html_template': '<p>{{meta.labelcol}}</p>'},
{'view_id': 'choice'},
{'view_id': 'text_input', 'field_id': 'notes',
'field_label': 'Notes'}]
return {'dataset': dataset,
'view_id': 'blocks',
'stream': stream,
'config': {'labels': ['LABEL'],
'blocks': blocks,
'choice_style': 'single'}}
def add_options(stream):
for task in stream:
task['options'] = labels[task['meta']['labelcol']]
yield task
I'm looking for one of two things: 1) how to fix or work around the error I'm experiencing or 2) how to debug the error myself. I don't see how to use the "non-minified" developer interface mentioned by React, and without that, I can't see the full content of the error message and warnings, so I don't see how to debug anything.