Spaces:
Runtime error
Runtime error
Commit
·
201c7f5
1
Parent(s):
3294241
Update app.py
Browse files
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 |
-
#
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
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()
|