MCPcopy Create free account
hub / github.com/CarperAI/autocrit / HuggingfaceAPI

Function HuggingfaceAPI

toolformer/tools.py:234–248  ·  view source on GitHub ↗
(input_query: str)

Source from the content-addressed store, hash-verified

232
233
234def HuggingfaceAPI(input_query: str):
235 model_id = "gpt-neox-20b"
236 API_TOKEN = "YOUR_API_TOKEN"
237 API_URL = "https://api-inference.huggingface.co/models/{model_id}".format(
238 model_id=model_id
239 )
240 headers = {"Authorization": f"Bearer {API_TOKEN}".format(API_TOKEN=API_TOKEN)}
241
242 def query(payload):
243 data = json.dumps(payload)
244 response = requests.request("POST", API_URL, headers=headers, data=data)
245 return json.loads(response.content.decode("utf-8"))
246
247 data = query(input_query)
248 return data[0]["generated_text"]
249
250
251"""

Callers 1

tools.pyFile · 0.85

Calls 1

queryFunction · 0.85

Tested by

no test coverage detected