vilarin commited on
Commit
6718266
·
verified ·
1 Parent(s): 366c3b0

Update app/webui/app.py

Browse files
Files changed (1) hide show
  1. app/webui/app.py +17 -18
app/webui/app.py CHANGED
@@ -93,9 +93,9 @@ def read_doc(file):
93
 
94
  def enable_sec(choice):
95
  if choice:
96
- return gr.update(visible = True), gr.update(visible = True), gr.update(visible = True)
97
  else:
98
- return gr.update(visible = False), gr.update(visible = False), gr.update(visible = False)
99
 
100
  def update_menu(visible):
101
  return not visible, gr.update(visible=not visible)
@@ -116,7 +116,7 @@ def switch(source_lang,source_text,target_lang,output_final):
116
 
117
  def closeBtnShow():
118
  return gr.update(visible=False), gr.update(visible=True)
119
-
120
  def closeBtnHide(output_final):
121
  if output_final:
122
  return gr.update(visible=True), gr.update(visible=False)
@@ -198,17 +198,17 @@ with gr.Blocks(theme="soft", css=CSS, fill_height=True) as demo:
198
  choices=["Groq","OpenAI","Cohere","TogetherAI","Ollama","Huggingface"],
199
  value="Huggingface",
200
  )
201
- choice = gr.Checkbox(label="Second Endpoint", info="Add second endpoint for reflection")
202
- model = gr.Textbox(label="Model", value="mistralai/Mistral-7B-Instruct-v0.3",)
203
  api_key = gr.Textbox(label="API_KEY", type="password", )
204
- endpoint2 = gr.Dropdown(
205
- label="Endpoint 2",
206
- choices=["Groq","OpenAI","Cohere","TogetherAI","Ollama","Huggingface"],
207
- value="Groq",
208
- visible=False,
209
- )
210
- model2 = gr.Textbox(label="Model 2", value="llama3-70b-8192", visible=False,)
211
- api_key2 = gr.Textbox(label="API_KEY 2", type="password", visible=False,)
212
  with gr.Row():
213
  source_lang = gr.Textbox(
214
  label="Source Lang",
@@ -279,17 +279,16 @@ with gr.Blocks(theme="soft", css=CSS, fill_height=True) as demo:
279
  menuBtn.click(fn=update_menu, inputs=visible, outputs=[visible, menubar], js=JS)
280
  endpoint.change(fn=update_model, inputs=[endpoint], outputs=[model])
281
 
282
- choice.select(fn=enable_sec, inputs=[choice], outputs=[endpoint2, model2, api_key2])
283
  endpoint2.change(fn=update_model, inputs=[endpoint2], outputs=[model2])
284
-
285
  start_ta = submit.click(fn=huanik, inputs=[endpoint, model, api_key, choice, endpoint2, model2, api_key2, source_lang, target_lang, source_text, country, max_tokens, context_window, num_output, rpm], outputs=[output_init, output_reflect, output_final, output_diff])
286
-
287
  upload.upload(fn=read_doc, inputs = upload, outputs = source_text)
288
  output_final.change(fn=export_txt, inputs=output_final, outputs=[export])
289
-
290
  submit.click(fn=closeBtnShow, outputs=[clear, close])
291
  output_final.change(fn=closeBtnHide, inputs=output_final, outputs=[clear, close])
292
  close.click(fn=None, cancels=start_ta)
293
-
294
  if __name__ == "__main__":
295
  demo.queue(api_open=False).launch(show_api=False, share=False)
 
93
 
94
  def enable_sec(choice):
95
  if choice:
96
+ return gr.update(visible = True)
97
  else:
98
+ return gr.update(visible = False)
99
 
100
  def update_menu(visible):
101
  return not visible, gr.update(visible=not visible)
 
116
 
117
  def closeBtnShow():
118
  return gr.update(visible=False), gr.update(visible=True)
119
+
120
  def closeBtnHide(output_final):
121
  if output_final:
122
  return gr.update(visible=True), gr.update(visible=False)
 
198
  choices=["Groq","OpenAI","Cohere","TogetherAI","Ollama","Huggingface"],
199
  value="Huggingface",
200
  )
201
+ choice = gr.Checkbox(label="Additional Endpoint", info="Additional endpoint for reflection")
202
+ model = gr.Textbox(label="Model", value="mistralai/Mistral-7B-Instruct-v0.3", )
203
  api_key = gr.Textbox(label="API_KEY", type="password", )
204
+ with gr.Column(visible=False) as AddEndpoint:
205
+ endpoint2 = gr.Dropdown(
206
+ label="Additional Endpoint",
207
+ choices=["Groq","OpenAI","Cohere","TogetherAI","Ollama","Huggingface"],
208
+ value="Groq",
209
+ )
210
+ model2 = gr.Textbox(label="Model", value="llama3-70b-8192", )
211
+ api_key2 = gr.Textbox(label="API_KEY", type="password", )
212
  with gr.Row():
213
  source_lang = gr.Textbox(
214
  label="Source Lang",
 
279
  menuBtn.click(fn=update_menu, inputs=visible, outputs=[visible, menubar], js=JS)
280
  endpoint.change(fn=update_model, inputs=[endpoint], outputs=[model])
281
 
282
+ choice.select(fn=enable_sec, inputs=[choice], outputs=[AddEndpoint])
283
  endpoint2.change(fn=update_model, inputs=[endpoint2], outputs=[model2])
284
+
285
  start_ta = submit.click(fn=huanik, inputs=[endpoint, model, api_key, choice, endpoint2, model2, api_key2, source_lang, target_lang, source_text, country, max_tokens, context_window, num_output, rpm], outputs=[output_init, output_reflect, output_final, output_diff])
 
286
  upload.upload(fn=read_doc, inputs = upload, outputs = source_text)
287
  output_final.change(fn=export_txt, inputs=output_final, outputs=[export])
288
+
289
  submit.click(fn=closeBtnShow, outputs=[clear, close])
290
  output_final.change(fn=closeBtnHide, inputs=output_final, outputs=[clear, close])
291
  close.click(fn=None, cancels=start_ta)
292
+
293
  if __name__ == "__main__":
294
  demo.queue(api_open=False).launch(show_api=False, share=False)