hoshingakag commited on
Commit
ac94949
·
1 Parent(s): a1a0b64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -46,7 +46,11 @@ with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
46
  with gr.Tab('Just Text'):
47
  chatbot = gr.Chatbot(height=600)
48
  msg = gr.Textbox()
49
- store = []
 
 
 
 
50
 
51
  def user(user_message, history):
52
  store = store + [[user_message, None]]
@@ -60,16 +64,17 @@ with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
60
  store[-1][1] = history[-1][1]
61
  time.sleep(0.01)
62
  yield history
63
-
 
 
64
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
65
  bot, chatbot, chatbot
66
  )
67
 
68
- # lambda: None, None, chatbot, queue=False
69
 
70
- with gr.Accordion("Generation History"):
71
- for generation in store:
72
- gr.Markdown(f"Query: {generation[0]}\nAnswer: {generation[1]}")
73
 
74
  with gr.Tab('Just Chat'):
75
  chatbot = gr.Chatbot(height=600)
 
46
  with gr.Tab('Just Text'):
47
  chatbot = gr.Chatbot(height=600)
48
  msg = gr.Textbox()
49
+ clear = gr.Button("Clear")
50
+ accordion = gr.Accordion("Generation History")
51
+
52
+ def record(history):
53
+ return history
54
 
55
  def user(user_message, history):
56
  store = store + [[user_message, None]]
 
64
  store[-1][1] = history[-1][1]
65
  time.sleep(0.01)
66
  yield history
67
+
68
+ msg.submit(record, accordion, accordion)
69
+
70
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
71
  bot, chatbot, chatbot
72
  )
73
 
74
+ clear.click(lambda: None, None, chatbot, queue=False)
75
 
76
+ # for generation in store:
77
+ # gr.Markdown(f"Query: {generation[0]}\nAnswer: {generation[1]}")
 
78
 
79
  with gr.Tab('Just Chat'):
80
  chatbot = gr.Chatbot(height=600)