Spaces:
Running
Running
import os | |
from dotenv import load_dotenv | |
from supabase import create_client | |
# Load environment variables from .env file | |
load_dotenv() | |
# Supabase API Config | |
SUPABASE_URL = "https://lmpazoxzucnlqqxjoihi.supabase.co" | |
SUPABASE_KEY = os.getenv("SUPABASE_API_KEY") | |
if not SUPABASE_KEY: | |
raise ValueError("SUPABASE_KEY is not set in the environment variables.") | |
supabase = create_client(SUPABASE_URL, SUPABASE_KEY) | |
# Hugging Face API Config | |
HF_API_URL = "https://router.huggingface.co/hf-inference/models/google/gemma-7b" | |
HF_API_TOKEN = os.getenv("HF_API_TOKEN") | |
HF_HEADERS = {"Authorization": f"Bearer HF_API_TOKEN"} | |
def query(payload): | |
"""Sends request to Hugging Face inference API.""" | |
import requests | |
response = requests.post(HF_API_URL, headers=HF_HEADERS, json=payload) | |
if response.status_code != 200: | |
print(f"Error: {response.status_code}, {response.text}") # Debugging | |
return None | |
return response.json() |