Spaces:
Runtime error
Runtime error
Antoine245
commited on
Commit
·
46bef1e
1
Parent(s):
6baf09a
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
import google.generativeai as palm
|
2 |
import os
|
|
|
|
|
|
|
3 |
palm.configure(api_key=os.environ.get("palm_key"))
|
4 |
|
5 |
defaults = {
|
@@ -24,4 +27,23 @@ response = palm.chat(
|
|
24 |
examples=examples,
|
25 |
messages=messages
|
26 |
)
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import google.generativeai as palm
|
2 |
import os
|
3 |
+
import gradio as gr
|
4 |
+
import random
|
5 |
+
import time
|
6 |
palm.configure(api_key=os.environ.get("palm_key"))
|
7 |
|
8 |
defaults = {
|
|
|
27 |
examples=examples,
|
28 |
messages=messages
|
29 |
)
|
30 |
+
|
31 |
+
|
32 |
+
with gr.Blocks() as demo:
|
33 |
+
chatbot = gr.Chatbot()
|
34 |
+
msg = gr.Textbox()
|
35 |
+
clear = gr.ClearButton([msg, chatbot])
|
36 |
+
|
37 |
+
def respond(response, messages):
|
38 |
+
bot_message = palm.chat(
|
39 |
+
**defaults,
|
40 |
+
context=context,
|
41 |
+
examples=examples,
|
42 |
+
messages=messages
|
43 |
+
)
|
44 |
+
time.sleep(2)
|
45 |
+
return "", messages
|
46 |
+
|
47 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
48 |
+
|
49 |
+
demo.launch()
|