paloma99 commited on
Commit
972c635
1 Parent(s): eb09c16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -1,4 +1,3 @@
1
- # Combined Interface
2
  import gradio as gr
3
  from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
4
  import torch
@@ -30,15 +29,17 @@ def predict_chatbot(input, history=[]):
30
  response_tuples = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)]
31
  return response_tuples, history
32
 
33
- chatbot_gradio_app = gr.Interface(
34
- fn=predict_chatbot,
35
- inputs=[gr.Textbox(show_label=False, placeholder="Enter text and press enter"), gr.State()],
36
- outputs=[gr.Chatbot(), gr.State()],
37
- live=True
38
- )
39
-
40
- # Display both interfaces vertically
41
- gr.Interface(
42
- columns=2,
43
- children=[image_gradio_app, chatbot_gradio_app]
44
- ).launch()
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
3
  import torch
 
29
  response_tuples = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)]
30
  return response_tuples, history
31
 
32
+ chatbot_gradio_app = gr.Blocks()
33
+ with chatbot_gradio_app as demo:
34
+ chatbot = gr.Chatbot()
35
+ state = gr.State([])
36
+ with gr.Row():
37
+ txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter")
38
+ txt.submit(predict_chatbot, [txt, state], [chatbot, state])
39
+
40
+ # Launch both interfaces
41
+ if __name__ == "__main__":
42
+ gr.Interface(
43
+ columns=2,
44
+ children=[image_gradio_app, chatbot_gradio_app]
45
+ ).launch()