Spaces:
Running
Running
Commit
·
170358b
1
Parent(s):
72e90db
add firebase sdk
Browse files
app.py
CHANGED
|
@@ -336,7 +336,6 @@ class TranscriptProcessor:
|
|
| 336 |
"""Return the raw transcript data."""
|
| 337 |
return self.transcript_data
|
| 338 |
|
| 339 |
-
|
| 340 |
def setup_openai_key() -> None:
|
| 341 |
"""Set up OpenAI API key from file."""
|
| 342 |
try:
|
|
@@ -907,12 +906,85 @@ def create_chat_interface():
|
|
| 907 |
return 'Iframe handler initialized';
|
| 908 |
}
|
| 909 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 910 |
|
| 911 |
with gr.Blocks(
|
| 912 |
fill_height=True,
|
| 913 |
fill_width=True,
|
| 914 |
css=css,
|
| 915 |
-
|
| 916 |
theme=gr.themes.Default(
|
| 917 |
font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"]
|
| 918 |
),
|
|
|
|
| 336 |
"""Return the raw transcript data."""
|
| 337 |
return self.transcript_data
|
| 338 |
|
|
|
|
| 339 |
def setup_openai_key() -> None:
|
| 340 |
"""Set up OpenAI API key from file."""
|
| 341 |
try:
|
|
|
|
| 906 |
return 'Iframe handler initialized';
|
| 907 |
}
|
| 908 |
"""
|
| 909 |
+
head = f"""
|
| 910 |
+
<script defer src="https://www.gstatic.com/firebasejs/11.1.0/firebase-firestore.js"></script>
|
| 911 |
+
<script type="module">
|
| 912 |
+
// Import the functions you need from the SDKs you need
|
| 913 |
+
import {{ initializeApp }} from "https://www.gstatic.com/firebasejs/11.1.0/firebase-app.js";
|
| 914 |
+
import {{ getDatabase, ref, set }} from "https://www.gstatic.com/firebasejs/11.1.0/firebase-database.js";
|
| 915 |
+
// TODO: Add SDKs for Firebase products that you want to use
|
| 916 |
+
// https://firebase.google.com/docs/web/setup#available-libraries
|
| 917 |
+
|
| 918 |
+
// Your web app's Firebase configuration
|
| 919 |
+
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
|
| 920 |
+
const firebaseConfig = {{
|
| 921 |
+
apiKey: "{os.getenv('FIREBASE_API_KEY')}",
|
| 922 |
+
authDomain: "{os.getenv('FIREBASE_AUTH_DOMAIN')}",
|
| 923 |
+
databaseURL: "{os.getenv('FIREBASE_DATABASE_URL')}",
|
| 924 |
+
projectId: "{os.getenv('FIREBASE_PROJECT_ID')}",
|
| 925 |
+
storageBucket: "{os.getenv('FIREBASE_STORAGE_BUCKET')}",
|
| 926 |
+
messagingSenderId: "{os.getenv('FIREBASE_MESSAGING_SENDER_ID')}",
|
| 927 |
+
appId: "{os.getenv('FIREBASE_APP_ID')}",
|
| 928 |
+
measurementId: "{os.getenv('FIREBASE_MEASUREMENT_ID')}"
|
| 929 |
+
}};
|
| 930 |
+
|
| 931 |
+
// Initialize Firebase
|
| 932 |
+
const app = initializeApp(firebaseConfig);
|
| 933 |
+
const realtimeDB = getDatabase(app);
|
| 934 |
+
const rollAccount = "roll-dev-account";
|
| 935 |
+
const COLLECTIONS = {{
|
| 936 |
+
COLLAB_EDIT_LINK: "collab_link_handler",
|
| 937 |
+
}};
|
| 938 |
+
|
| 939 |
+
// Event listener for click
|
| 940 |
+
document.addEventListener('click', function (event) {{
|
| 941 |
+
var link = event.target.closest('a');
|
| 942 |
+
if (link && link.href) {{
|
| 943 |
+
|
| 944 |
+
// Parse the URL to extract 'st' and 'et'
|
| 945 |
+
const url = new URL(link.href);
|
| 946 |
+
const startTime = url.searchParams.get('st');
|
| 947 |
+
const endTime = url.searchParams.get('et');
|
| 948 |
+
const userId = url.searchParams.get('uid') || "";
|
| 949 |
+
|
| 950 |
+
if (startTime || endTime) {{
|
| 951 |
+
let components = url.pathname.split("/");
|
| 952 |
+
let callId = components[2];
|
| 953 |
+
let recordingSessionId = components[3];
|
| 954 |
+
|
| 955 |
+
let data = {{
|
| 956 |
+
startTime: parseInt(startTime, 10),
|
| 957 |
+
endTime: parseInt(endTime, 10),
|
| 958 |
+
}};
|
| 959 |
+
|
| 960 |
+
console.log("Data to save:", data);
|
| 961 |
+
|
| 962 |
+
// Firebase reference
|
| 963 |
+
let reference = ref(
|
| 964 |
+
realtimeDB,
|
| 965 |
+
`${{rollAccount}}/${{COLLECTIONS.COLLAB_EDIT_LINK}}/${{userId}}/${{callId}}/${{recordingSessionId}}`
|
| 966 |
+
);
|
| 967 |
+
|
| 968 |
+
set(reference, data)
|
| 969 |
+
.then(() => {{
|
| 970 |
+
console.log("Data saved successfully:", data);
|
| 971 |
+
}})
|
| 972 |
+
.catch((error) => {{
|
| 973 |
+
console.error("Error saving data:", error);
|
| 974 |
+
}});
|
| 975 |
+
}}
|
| 976 |
+
|
| 977 |
+
event.preventDefault(); // Prevent default behavior
|
| 978 |
+
}}
|
| 979 |
+
}});
|
| 980 |
+
</script>
|
| 981 |
+
"""
|
| 982 |
|
| 983 |
with gr.Blocks(
|
| 984 |
fill_height=True,
|
| 985 |
fill_width=True,
|
| 986 |
css=css,
|
| 987 |
+
head=head,
|
| 988 |
theme=gr.themes.Default(
|
| 989 |
font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"]
|
| 990 |
),
|