Spaces:
Runtime error
Runtime error
Commit
·
130d8b3
1
Parent(s):
0c8a437
Update
Browse files
app.py
CHANGED
|
@@ -1,30 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
#
|
| 14 |
-
with
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
run_button.click(fn=save_image, inputs=[user_query, user_image], outputs=chatbot_output)
|
| 26 |
-
|
| 27 |
-
# Launch the Gradio app
|
| 28 |
demo.launch()
|
| 29 |
|
| 30 |
# import os
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import datetime
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# Ensure logs directory exists
|
| 6 |
+
os.makedirs("logs", exist_ok=True)
|
| 7 |
+
|
| 8 |
+
def log_user_data(inputs, outputs):
|
| 9 |
+
# Create a log entry
|
| 10 |
+
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 11 |
+
log_entry = f"{timestamp} | Input: {inputs} | Output: {outputs}\n"
|
| 12 |
+
|
| 13 |
+
# Write to a log file
|
| 14 |
+
with open("logs/user_data.log", "a") as log_file:
|
| 15 |
+
log_file.write(log_entry)
|
| 16 |
+
|
| 17 |
+
return outputs
|
| 18 |
+
|
| 19 |
+
def process_input(user_input):
|
| 20 |
+
response = f"Hello, {user_input}!"
|
| 21 |
+
log_user_data(user_input, response)
|
| 22 |
+
return response
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(fn=process_input, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
| 25 |
demo.launch()
|
| 26 |
|
| 27 |
# import os
|