alexkueck commited on
Commit
8bd6126
·
1 Parent(s): 193883f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -265,16 +265,16 @@ def generate_prompt_with_history_openai(prompt, history):
265
  ##############################################
266
  #History - die Frage oder das File eintragen...
267
  ##############################################
268
- def add_text(history, text):
269
- history = history + [(text, None)]
270
- return history, "" #gr.Textbox(value="", interactive=False)
271
 
272
  def add_file(history, file, prompt):
273
  if (prompt == ""):
274
  history = history + [((file.name,), None)]
275
  else:
276
  history = history + [((file.name,), None), (prompt, None)]
277
- return history, ""
278
 
279
  def transfer_input(inputs):
280
  textbox = reset_textbox()
@@ -402,9 +402,10 @@ evaluator = load_evaluator("criteria", criteria="conciseness", llm=evaluation_ll
402
  print ("Start GUI")
403
  with open("custom.css", "r", encoding="utf-8") as f:
404
  customCSS = f.read()
405
-
406
  with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
407
  history = gr.State([])
 
408
  with gr.Row():
409
  gr.HTML("LI Chatot")
410
  status_display = gr.Markdown("Success", elem_id="status_display")
@@ -497,11 +498,16 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
497
  )
498
 
499
  # Chatbot
500
- transfer_input_args = dict(fn=add_text, inputs=[chatbot, user_input], outputs=[chatbot, user_input], show_progress=True)
 
 
 
 
 
501
 
502
- predict_event1 = user_input.submit(fn=add_text, inputs=[chatbot, user_input], outputs=[chatbot], queue=False,).then(**predict_args)
503
- predict_event3 = btn.upload(add_file, [chatbot, btn, user_input], [chatbot],queue=False,).then(**predict_args)
504
- predict_event2 = submitBtn.click(fn=add_text, inputs=[chatbot, user_input], outputs=[chatbot], queue=False,).then(**predict_args)
505
 
506
  cancelBtn.click(
507
  cancel_outputing, [], [status_display],
 
265
  ##############################################
266
  #History - die Frage oder das File eintragen...
267
  ##############################################
268
+ def add_text(history, prompt):
269
+ history = history + [(prompt, None)]
270
+ return history, prompt, "" #gr.Textbox(value="", interactive=False)
271
 
272
  def add_file(history, file, prompt):
273
  if (prompt == ""):
274
  history = history + [((file.name,), None)]
275
  else:
276
  history = history + [((file.name,), None), (prompt, None)]
277
+ return history, prompt, ""
278
 
279
  def transfer_input(inputs):
280
  textbox = reset_textbox()
 
402
  print ("Start GUI")
403
  with open("custom.css", "r", encoding="utf-8") as f:
404
  customCSS = f.read()
405
+
406
  with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
407
  history = gr.State([])
408
+ user_question = gr.State("")
409
  with gr.Row():
410
  gr.HTML("LI Chatot")
411
  status_display = gr.Markdown("Success", elem_id="status_display")
 
498
  )
499
 
500
  # Chatbot
501
+ transfer_input_args_text = dict(
502
+ fn=add_text, inputs=[chatbot, user_input], outputs=[chatbot, user_question, user_input], show_progress=True
503
+ )
504
+ transfer_input_args_file = dict(
505
+ fn=add_file, inputs=[chatbot, btn, user_input], outputs=[chatbot, user_question, user_input], show_progress=True
506
+ )
507
 
508
+ predict_event1 = user_input.submit(**transfer_input_args_text, queue=False,).then(**predict_args)
509
+ predict_event3 = btn.upload(**transfer_input_args_file,queue=False,).then(**predict_args)
510
+ predict_event2 = submitBtn.click(**transfer_input_args_text, queue=False,).then(**predict_args)
511
 
512
  cancelBtn.click(
513
  cancel_outputing, [], [status_display],