Spaces:
Sleeping
Sleeping
| 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)} | |