Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,18 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Function to interact with the Hugging Face Space API
|
8 |
def interact_with_space(system_prompt, user_prompt, assistant_response, model="gpt-4o"):
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
from gradio_client import Client
|
4 |
|
5 |
+
# Access the Hugging Face token from environment variables
|
6 |
+
hf_token = os.getenv("HF_TOKEN")
|
7 |
+
|
8 |
+
# Check if the token is set (optional for debugging)
|
9 |
+
if hf_token is None:
|
10 |
+
print("Hugging Face token not found. Please set the HF_TOKEN environment variable.")
|
11 |
+
else:
|
12 |
+
print("Hugging Face token successfully retrieved.")
|
13 |
+
|
14 |
+
# Initialize the Client for the Hugging Face Space with the token
|
15 |
+
client = Client("segestic/token-cost-calculator", token=hf_token)
|
16 |
|
17 |
# Function to interact with the Hugging Face Space API
|
18 |
def interact_with_space(system_prompt, user_prompt, assistant_response, model="gpt-4o"):
|