File size: 954 Bytes
f3f0a69
 
56325dc
f3f0a69
 
 
 
56325dc
 
 
 
 
 
 
 
19ea0c5
56325dc
19ea0c5
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()