Open sevenChrisK opened 1 year ago
Hi, Did you try the eval()
method on response?
Hi the eval()
method should normally work but sometimes the output string starts with a whitespace character that throws an exception.
Maybe the return should involve a step to strip whitespace?
We are working on a verifier step to check the response type.
@sevenChrisK thanks for reporting this. I encountered the same problem. A quick fix that worked for me was using strip()
.
import ast
response = nlp_prompter.fit('ner.jinja',
domain = 'medical',
text_input = text,
labels = None)
print(ast.literal_eval(response['text'].strip()))
The response for the NER template is a string representation of a list of dictionaries.
Currently this means the user first needs to parse and convert into list of dicts to use the output effectively.