Update src/interface.py
Browse files- src/interface.py +17 -1
src/interface.py
CHANGED
@@ -1,6 +1,22 @@
|
|
1 |
import csv
|
2 |
import gradio as gr
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Gradio application setup
|
6 |
def create_demo():
|
|
|
1 |
import csv
|
2 |
import gradio as gr
|
3 |
+
|
4 |
+
# Define a function to export conversations to CSV
|
5 |
+
def export_conversations(conversations):
|
6 |
+
# Create a CSV writer
|
7 |
+
csvfile = "conversations.csv"
|
8 |
+
with open(csvfile, "w", newline="") as f:
|
9 |
+
writer = csv.writer(f)
|
10 |
+
|
11 |
+
# Write the header row
|
12 |
+
writer.writerow(["User Input", "Model Response"])
|
13 |
+
|
14 |
+
# Iterate over the conversations and write each row
|
15 |
+
for conversation in conversations:
|
16 |
+
for i, (user_input, model_response) in enumerate(conversation):
|
17 |
+
writer.writerow([user_input, model_response])
|
18 |
+
|
19 |
+
return csvfile
|
20 |
|
21 |
# Gradio application setup
|
22 |
def create_demo():
|