Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import re
|
| 3 |
from gradio_client import Client
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def escape_special_characters(result):
|
| 6 |
# Convert the result to a string if it's not already
|
|
@@ -10,7 +11,10 @@ def escape_special_characters(result):
|
|
| 10 |
return result_str
|
| 11 |
|
| 12 |
def predict(question):
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
result = client.predict(question, api_name="/predict")
|
| 15 |
escaped_result = escape_special_characters(result)
|
| 16 |
return escaped_result
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from gradio_client import Client
|
| 3 |
+
import re
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
def escape_special_characters(result):
|
| 7 |
# Convert the result to a string if it's not already
|
|
|
|
| 11 |
return result_str
|
| 12 |
|
| 13 |
def predict(question):
|
| 14 |
+
hf_token = os.getenv('HUGGINGFACE_TOKEN')
|
| 15 |
+
if not hf_token:
|
| 16 |
+
raise ValueError("Hugging Face token not found in environment variables")
|
| 17 |
+
client = Client("https://teamtonic-bulbiplantdoctor.hf.space/--replicas/k5mwx/", hf_token=hf_token)
|
| 18 |
result = client.predict(question, api_name="/predict")
|
| 19 |
escaped_result = escape_special_characters(result)
|
| 20 |
return escaped_result
|