Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ def transcribe(audio):
|
|
23 |
text = model.stt_file(audio)[0]
|
24 |
return text
|
25 |
|
26 |
-
HF_TOKEN = os.environ.get("
|
27 |
|
28 |
def client_fn(model):
|
29 |
if "Mixtral" in model:
|
@@ -52,7 +52,7 @@ Respond in a manner that reflects your expertise and wisdom.
|
|
52 |
"""
|
53 |
|
54 |
# Initialize an empty DataFrame to store the history
|
55 |
-
history_df = pd.DataFrame(columns=['Timestamp', 'Request', 'Response', '
|
56 |
|
57 |
def save_history():
|
58 |
history_df_copy = history_df.copy()
|
@@ -65,7 +65,7 @@ def load_history():
|
|
65 |
history_df = pd.read_json('chat_history.json', orient='records')
|
66 |
history_df['Timestamp'] = pd.to_datetime(history_df['Timestamp'])
|
67 |
else:
|
68 |
-
history_df = pd.DataFrame(columns=['Timestamp', 'Request', 'Response', '
|
69 |
return history_df
|
70 |
|
71 |
def models(text, model="Meta-Llama-3.1-8B-Instruct", seed=42):
|
@@ -91,9 +91,11 @@ def models(text, model="Meta-Llama-3.1-8B-Instruct", seed=42):
|
|
91 |
# Add the current interaction to the history DataFrame
|
92 |
new_row = pd.DataFrame({
|
93 |
'Timestamp': [datetime.now()],
|
|
|
94 |
'Request': [text],
|
95 |
'Response': [output],
|
96 |
-
'
|
|
|
97 |
})
|
98 |
history_df = pd.concat([history_df, new_row], ignore_index=True)
|
99 |
save_history()
|
@@ -155,8 +157,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
155 |
request_md = gr.Markdown(label="User Request")
|
156 |
response_md = gr.Markdown(label="Dr. Nova Quantum Response")
|
157 |
|
158 |
-
# Update the DataFrame to display the history with the new
|
159 |
-
history_display = gr.DataFrame(label="Conversation History", headers=["Timestamp", "Request", "Response", "
|
160 |
|
161 |
# Add a download button for the history
|
162 |
download_button = gr.Button("Download Conversation History")
|
|
|
23 |
text = model.stt_file(audio)[0]
|
24 |
return text
|
25 |
|
26 |
+
HF_TOKEN = os.environ.get("NOVA_TOKEN", None)
|
27 |
|
28 |
def client_fn(model):
|
29 |
if "Mixtral" in model:
|
|
|
52 |
"""
|
53 |
|
54 |
# Initialize an empty DataFrame to store the history
|
55 |
+
history_df = pd.DataFrame(columns=['Timestamp', 'Model', 'Request', 'Response', 'Input Size', 'Output Size'])
|
56 |
|
57 |
def save_history():
|
58 |
history_df_copy = history_df.copy()
|
|
|
65 |
history_df = pd.read_json('chat_history.json', orient='records')
|
66 |
history_df['Timestamp'] = pd.to_datetime(history_df['Timestamp'])
|
67 |
else:
|
68 |
+
history_df = pd.DataFrame(columns=['Timestamp', 'Model', 'Request', 'Response', 'Input Size', 'Output Size'])
|
69 |
return history_df
|
70 |
|
71 |
def models(text, model="Meta-Llama-3.1-8B-Instruct", seed=42):
|
|
|
91 |
# Add the current interaction to the history DataFrame
|
92 |
new_row = pd.DataFrame({
|
93 |
'Timestamp': [datetime.now()],
|
94 |
+
'Model': [model],
|
95 |
'Request': [text],
|
96 |
'Response': [output],
|
97 |
+
'Input Size': [len(text)],
|
98 |
+
'Output Size': [len(output)]
|
99 |
})
|
100 |
history_df = pd.concat([history_df, new_row], ignore_index=True)
|
101 |
save_history()
|
|
|
157 |
request_md = gr.Markdown(label="User Request")
|
158 |
response_md = gr.Markdown(label="Dr. Nova Quantum Response")
|
159 |
|
160 |
+
# Update the DataFrame to display the history with the new order and additional columns
|
161 |
+
history_display = gr.DataFrame(label="Conversation History", headers=["Timestamp", "Model", "Request", "Response", "Input Size", "Output Size"])
|
162 |
|
163 |
# Add a download button for the history
|
164 |
download_button = gr.Button("Download Conversation History")
|