prithivMLmods commited on
Commit
a48362a
β€’
1 Parent(s): ad773e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -23
app.py CHANGED
@@ -85,31 +85,37 @@ def convert_and_download(history, conversion_type):
85
  file_path = save_as_file(input_text, output_text, conversion_type)
86
  return file_path
87
 
88
- demo = gr.ChatInterface(
89
- respond,
90
- additional_inputs=[
91
- gr.Textbox(value="", label="System message"),
92
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
93
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
94
- gr.Slider(
95
- minimum=0.1,
96
- maximum=1.0,
97
- value=0.95,
98
- step=0.05,
99
- label="Top-P",
100
- ),
101
- gr.Dropdown(choices=["PDF", "DOCX", "TXT"], label="Conversion Type"),
102
- gr.Button("Convert and Download"),
103
- ],
104
- css=css,
105
- theme="allenai/gradio-theme",
106
- )
107
-
108
- def on_convert_and_download(history, conversion_type):
109
  file_path = convert_and_download(history, conversion_type)
110
- return file_path
111
 
112
- demo.launch(on_event={"Convert and Download": on_convert_and_download})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  if __name__ == "__main__":
115
  demo.launch()
 
85
  file_path = save_as_file(input_text, output_text, conversion_type)
86
  return file_path
87
 
88
+ def handle_conversion(history, conversion_type):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  file_path = convert_and_download(history, conversion_type)
90
+ return gr.File(file_path)
91
 
92
+ demo = gr.Blocks(css=css)
93
+
94
+ with demo:
95
+ with gr.Row():
96
+ system_message = gr.Textbox(value="", label="System message")
97
+ max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
98
+ temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
99
+ top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-P")
100
+
101
+ history = gr.State(value=[])
102
+
103
+ chatbot = gr.ChatInterface(
104
+ fn=respond,
105
+ additional_inputs=[system_message, max_tokens, temperature, top_p],
106
+ )
107
+
108
+ with gr.Row():
109
+ conversion_type = gr.Dropdown(choices=["PDF", "DOCX", "TXT"], label="Conversion Type")
110
+ download_button = gr.Button("Convert and Download")
111
+
112
+ file_output = gr.File()
113
+
114
+ download_button.click(
115
+ handle_conversion,
116
+ inputs=[history, conversion_type],
117
+ outputs=file_output
118
+ )
119
 
120
  if __name__ == "__main__":
121
  demo.launch()