cs1-team20 / inference_api.py
github-actions
Sync from GitHub 2025-09-07T23:27:22Z
04a81d2
raw
history blame contribute delete
463 Bytes
import os
from huggingface_hub import InferenceClient
# Pin the full model repo ID (owner/name)
MODEL_ID = os.getenv(
"HF_API_MODEL_ID",
"distilbert/distilbert-base-uncased-finetuned-sst-2-english"
)
HF_TOKEN = os.getenv("runtime_inference")
_client = InferenceClient(model=MODEL_ID, token=HF_TOKEN)
def run_inference_api(text: str):
try:
return _client.text_classification(text)
except Exception as e:
return {"error": str(e)}