Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -85,6 +85,10 @@ def save_conversation(history, file_format):
|
|
85 |
file_name = save_to_file(history, file_format)
|
86 |
return file_name
|
87 |
|
|
|
|
|
|
|
|
|
88 |
demo = gr.ChatInterface(
|
89 |
respond,
|
90 |
additional_inputs=[
|
@@ -94,10 +98,29 @@ demo = gr.ChatInterface(
|
|
94 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-P"),
|
95 |
gr.Radio(["PDF", "DOCX", "TXT"], label="Save As"),
|
96 |
],
|
97 |
-
button_fn=save_conversation,
|
98 |
css=css,
|
99 |
theme="allenai/gradio-theme",
|
100 |
)
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
if __name__ == "__main__":
|
103 |
demo.launch()
|
|
|
85 |
file_name = save_to_file(history, file_format)
|
86 |
return file_name
|
87 |
|
88 |
+
def save_and_download(history, file_format):
|
89 |
+
file_name = save_conversation(history, file_format)
|
90 |
+
return file_name
|
91 |
+
|
92 |
demo = gr.ChatInterface(
|
93 |
respond,
|
94 |
additional_inputs=[
|
|
|
98 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-P"),
|
99 |
gr.Radio(["PDF", "DOCX", "TXT"], label="Save As"),
|
100 |
],
|
|
|
101 |
css=css,
|
102 |
theme="allenai/gradio-theme",
|
103 |
)
|
104 |
|
105 |
+
save_button = gr.Button("Save Conversation")
|
106 |
+
output_file = gr.File(label="Download File")
|
107 |
+
|
108 |
+
def handle_save(history, save_format):
|
109 |
+
return save_conversation(history, save_format)
|
110 |
+
|
111 |
+
save_button.click(
|
112 |
+
handle_save,
|
113 |
+
inputs=[demo.history, demo.inputs[-1]], # Passing history and format
|
114 |
+
outputs=output_file
|
115 |
+
)
|
116 |
+
|
117 |
+
demo = gr.Blocks()
|
118 |
+
|
119 |
+
with demo:
|
120 |
+
with gr.Column():
|
121 |
+
demo.render()
|
122 |
+
save_button.render()
|
123 |
+
output_file.render()
|
124 |
+
|
125 |
if __name__ == "__main__":
|
126 |
demo.launch()
|