arif670 commited on
Commit
f907b1c
·
verified ·
1 Parent(s): 06c1e1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -1,18 +1,17 @@
1
  import os
2
- import firebase_admin
3
- from firebase_admin import credentials, db
4
- from transformers import pipeline
5
- import gradio as gr
6
 
7
- # ----------------------------------
8
- # Initialize Firebase
9
- # ----------------------------------
10
- # Replace with your Firebase credentials
11
- firebase_cred_path = "path/to/your-serviceAccountKey.json" # Upload to your Hugging Face space
12
- firebase_db_url = "https://your-database-name.firebaseio.com/" # Replace with your Realtime Database URL
13
 
14
- cred = credentials.Certificate(firebase_cred_path)
15
- firebase_admin.initialize_app(cred, {"databaseURL": firebase_db_url})
 
16
 
17
  # ----------------------------------
18
  # Initialize Hugging Face RAG Model
 
1
  import os
2
+ import json
3
+ from firebase_admin import credentials
 
 
4
 
5
+ # Fetch the Firebase credentials from the Hugging Face secret
6
+ firebase_credential = os.getenv("FIREBASE_CREDENTIALS")
7
+
8
+ # Save the credentials to a temporary file
9
+ with open("serviceAccountKey.json", "w") as f:
10
+ f.write(firebase_credential)
11
 
12
+ # Initialize Firebase Admin SDK
13
+ cred = credentials.Certificate("serviceAccountKey.json")
14
+ firebase_admin.initialize_app(cred, {"databaseURL": "https://your-database-name.firebaseio.com/"})
15
 
16
  # ----------------------------------
17
  # Initialize Hugging Face RAG Model