Antoine245 commited on
Commit
d014661
·
1 Parent(s): e288c9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import os
3
  import time
4
- import google.generativeai as palm
5
 
6
  palm.configure(api_key=os.environ.get("palm_key"))
7
 
@@ -25,10 +25,6 @@ examples = [
25
  user_input = []
26
 
27
 
28
- import gradio as gr
29
- import random
30
- import time
31
-
32
  with gr.Blocks() as demo:
33
  chatbot = gr.Chatbot()
34
  msg = gr.Textbox()
@@ -36,7 +32,7 @@ with gr.Blocks() as demo:
36
 
37
  def respond(messages):
38
  global user_input
39
- user_input.append(messages[0])
40
  bot_message = palm.chat(
41
  **defaults,
42
  context=context,
@@ -44,8 +40,8 @@ with gr.Blocks() as demo:
44
  messages=user_input
45
  )
46
  time.sleep(2)
47
- return messages
48
 
49
- msg.submit(respond, msg,chatbot)
50
 
51
  demo.launch()
 
1
  import gradio as gr
2
  import os
3
  import time
4
+ from google.generativeai import palm
5
 
6
  palm.configure(api_key=os.environ.get("palm_key"))
7
 
 
25
  user_input = []
26
 
27
 
 
 
 
 
28
  with gr.Blocks() as demo:
29
  chatbot = gr.Chatbot()
30
  msg = gr.Textbox()
 
32
 
33
  def respond(messages):
34
  global user_input
35
+ user_input.append([messages[0]]) # Wrap user input in a list
36
  bot_message = palm.chat(
37
  **defaults,
38
  context=context,
 
40
  messages=user_input
41
  )
42
  time.sleep(2)
43
+ return bot_message['message']
44
 
45
+ msg.submit(respond, [msg, chatbot])
46
 
47
  demo.launch()