Hello,
How can i resolve this error :
headers = {“Authorization”: f"Bearer {api_token}"}
NameError: name ‘api_token’ is not defined
Here the code :
import json
import requests
API_URL = “https://api-inference.huggingface.co/models/sentence-transformers/all-MiniLM-L6-v2”
headers = {“Authorization”: f"Bearer {api_token}"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
data = query(
{
“inputs”: {
“source_sentence”: “I’m very happy”,
“sentences”:[“I’m filled with happiness”, “I’m happy”]
}
})
Thank you