Spaces:
Running
Running
Reality123b
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,12 @@ from huggingface_hub import InferenceClient
|
|
4 |
import firebase_admin
|
5 |
from firebase_admin import credentials, firestore, auth
|
6 |
import uuid
|
|
|
|
|
7 |
|
8 |
class XylariaChat:
|
9 |
def __init__(self):
|
10 |
-
# Securely load HuggingFace and Firebase tokens from
|
11 |
self.hf_token = os.environ.get("HF_TOKEN")
|
12 |
firebase_cred_json = os.environ.get("FIREBASE_SERVICE_ACCOUNT")
|
13 |
|
@@ -17,9 +19,6 @@ class XylariaChat:
|
|
17 |
# Initialize Firebase
|
18 |
try:
|
19 |
# Convert the JSON string to a temporary credentials file
|
20 |
-
import tempfile
|
21 |
-
import json
|
22 |
-
|
23 |
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.json') as temp_cred_file:
|
24 |
json.dump(json.loads(firebase_cred_json), temp_cred_file)
|
25 |
temp_cred_file.close()
|
@@ -241,8 +240,7 @@ class XylariaChat:
|
|
241 |
chatbot = gr.Chatbot(
|
242 |
label="Xylaria 1.4 Senoa",
|
243 |
height=500,
|
244 |
-
show_copy_button=True
|
245 |
-
likeable=True
|
246 |
)
|
247 |
|
248 |
# Input row with minimalist design
|
@@ -283,25 +281,10 @@ class XylariaChat:
|
|
283 |
inputs=[txt, chatbot],
|
284 |
outputs=[txt, chatbot]
|
285 |
)
|
286 |
-
|
287 |
-
# Clear conversation history
|
288 |
-
clear.click(
|
289 |
-
fn=lambda: None,
|
290 |
-
inputs=None,
|
291 |
-
outputs=[chatbot],
|
292 |
-
queue=False
|
293 |
-
)
|
294 |
-
|
295 |
-
return demo
|
296 |
|
297 |
-
|
298 |
-
def main():
|
299 |
-
chat = XylariaChat()
|
300 |
-
interface = chat.create_interface()
|
301 |
-
interface.launch(
|
302 |
-
share=True, # Optional: create a public link
|
303 |
-
debug=True # Show detailed errors
|
304 |
-
)
|
305 |
|
306 |
-
|
307 |
-
|
|
|
|
4 |
import firebase_admin
|
5 |
from firebase_admin import credentials, firestore, auth
|
6 |
import uuid
|
7 |
+
import tempfile
|
8 |
+
import json
|
9 |
|
10 |
class XylariaChat:
|
11 |
def __init__(self):
|
12 |
+
# Securely load HuggingFace and Firebase tokens from environment variables
|
13 |
self.hf_token = os.environ.get("HF_TOKEN")
|
14 |
firebase_cred_json = os.environ.get("FIREBASE_SERVICE_ACCOUNT")
|
15 |
|
|
|
19 |
# Initialize Firebase
|
20 |
try:
|
21 |
# Convert the JSON string to a temporary credentials file
|
|
|
|
|
|
|
22 |
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.json') as temp_cred_file:
|
23 |
json.dump(json.loads(firebase_cred_json), temp_cred_file)
|
24 |
temp_cred_file.close()
|
|
|
240 |
chatbot = gr.Chatbot(
|
241 |
label="Xylaria 1.4 Senoa",
|
242 |
height=500,
|
243 |
+
show_copy_button=True
|
|
|
244 |
)
|
245 |
|
246 |
# Input row with minimalist design
|
|
|
281 |
inputs=[txt, chatbot],
|
282 |
outputs=[txt, chatbot]
|
283 |
)
|
284 |
+
clear.click(lambda: None, None, chatbot)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
+
return demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
+
# Initialize the chat system and launch interface
|
289 |
+
xylaria_chat = XylariaChat()
|
290 |
+
xylaria_chat.create_interface().launch(share=True)
|