Just setup a conversational bot (microsoft/DialoGPT-medium), and I’m trying to access it through the api url in some custom python code. My issue is that it tells me I need to include the content type if I give it the most basic of headers e.g.
headers = {“Authorization”: f"Bearer {API_TOKEN}"}
so that works. But when I add in the content type, I get {‘error’: ‘string indices must be integers’}
this baffles me, it’s such a simple request, and everything I’ve researched tells me I’m making the request correctly. I know I’m just being dumb, but dagum I cannot find out why. Here is my code
headers = {“Authorization”: f"Bearer {API_TOKEN}", “Content-Type”: “application/json”}
def query(payload):
data = json.dumps(payload)
response = requests.request(“POST”, API_URL, headers=headers, data=data)
return json.loads(response.content.decode(“utf-8”))
data = query({“inputs”: “The answer to the universe is [MASK].”})
print(data)