You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
'''HuggingFace APIUses HuggingFace's API to generate text.input_query - A string, the input query (e.g. "what is a dog?")output - A string, the generated textAPI_TOKEN - your HuggingFace API token'''defHuggingfaceAPI(input_query: str):
model_id="gpt-neox-20b"API_TOKEN="YOUR_API_TOKEN"API_URL="https://api-inference.huggingface.co/models/{model_id}".format(model_id=model_id)
headers= {"Authorization": f"Bearer {API_TOKEN}".format(API_TOKEN=API_TOKEN)}
defquery(payload):
data=json.dumps(payload)
response=requests.request("POST", API_URL, headers=headers, data=data)
returnjson.loads(response.content.decode("utf-8"))
data=query(input_query)
returndata[0]["generated_text"]
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: