I am trying to run Tapas for Question Answering using the Inference API and can’t figure out the problem in the parsing as I followed the example on inference and built the JSON in the same format as required and still getting this error.
Here is the code
dataToPass["query"] = "What is Akshat ID Number"
dataToPass["table"] = ast.literal_eval(str(dict))
jsonFinal = {}
jsonFinal["inputs"] = dataToPass
test_string = str(jsonFinal)
answer = getAnswer(test_string)
print(answer)
I am getting the output for jsonFinal as the following
{"inputs": {"query": "What is Akshat ID Number", "table": {"id": [1, 2, 3, 4, 5, 6, 7], "gender": ["", "MALE", "MALE", "MALE", "MALE", "MALE", "MALE"], "name": ["", "Akshat", "Rishabh Sahu", "Ashu", "Ashu", "Ashu", "Ashu"], "dob": ["", "1999", "1999", "1999", "1999", "1999", "1999"], "id_number": ["", "808", "1011", "100", "100", "100", "102"]}}}
I have tried passing in jsonFinal
and test_string
and a couple of other combination but I am not sure why this error persists
Just FYI I am using a custom dictionary class hence converting the above way to a dictionary and
getAnswer
is where I call the inference API.
And I am building the dict by iterating over a django model queryset -
here is the code to that
def dataToJSON(coloumName, jsonData):
jsonBar = []
for i in jsonData:
jsonBar.append(i)
dict.add(coloumName, jsonBar)
return ""