Antoine245 commited on
Commit
201c7f5
·
1 Parent(s): 3294241

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -36,22 +36,25 @@ with gr.Blocks() as demo:
36
  return gr.update(value="", interactive=False), history + [[user_message[-1], None]]
37
 
38
  def bot(history):
39
- # chat_history.append(message) # Initialize chat history
40
- bot_message = palm.chat(
41
- context=context,
42
- examples=examples,
43
- messages=history
44
- )
45
- history[-1][1] = ""
46
- for character in bot_message:
47
- history[-1][1] += character
48
- time.sleep(0.05)
49
- yield history
 
 
 
50
 
51
  response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
52
  bot, chatbot, chatbot
53
  )
54
  response.then(lambda: gr.update(interactive=True), None, [msg], queue=False)
55
 
56
- demo.queue()
57
- demo.launch()
 
36
  return gr.update(value="", interactive=False), history + [[user_message[-1], None]]
37
 
38
  def bot(history):
39
+ # Initialize the GenerateMessageRequest object
40
+ request = generate_message_pb2.GenerateMessageRequest()
41
+
42
+ # Set the prompt field
43
+ request.prompt.context = context
44
+ request.prompt.examples = examples
45
+
46
+ # Set the messages field
47
+ request.prompt.messages = history
48
+
49
+ # Generate the message
50
+ response = client.generate_message(request)
51
+
52
+ return response.message
53
 
54
  response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
55
  bot, chatbot, chatbot
56
  )
57
  response.then(lambda: gr.update(interactive=True), None, [msg], queue=False)
58
 
59
+ demo.queue()
60
+ demo.launch()