Hi I’m just starting out with the inference API examples. While I can get other examples to work using the same formatting , I get this error
{“error”:“d argument needs to be of type (SquadExample, dict)”}
When using the example for deepset/roberta-base-squad2 · Hugging Face
import json
import requests
API_URL = "https://api-inference.huggingface.co/models/deepset/roberta-base-squad2"
headers = {"Authorization": "Bearer api_xxx"}
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": {
"question": "What's my name?",
"context": "My name is Clara and I live in Berkeley.",
}
}
)
I’d love know how else to format the query, or what else I should double check.
Thanks for reading.