Spaces:
Runtime error
Runtime error
import gradio as gr | |
import os | |
import time | |
import google.generativeai as palm | |
palm.configure(api_key=os.environ.get("palm_key")) | |
defaults = { | |
'model': 'models/chat-bison-001', | |
'temperature': 0.25, | |
'candidate_count': 1, | |
'top_k': 40, | |
'top_p': 0.95, | |
} | |
context = "You're a computer failure assistant" | |
examples = [ | |
[ | |
"Hey my computer is broken", | |
"Hey, what is the issue with your computer?" | |
] | |
] | |
user_input = [] | |
import gradio as gr | |
import random | |
import time | |
with gr.Blocks() as demo: | |
chatbot = gr.Chatbot() | |
msg = gr.Textbox() | |
clear = gr.ClearButton([msg, chatbot]) | |
def respond(messages): | |
global user_input | |
user_input.append(messages[0]) | |
bot_message = palm.chat( | |
**defaults, | |
context=context, | |
examples=examples, | |
messages=user_input | |
) | |
time.sleep(2) | |
return messages | |
msg.submit(respond, [msg, chatbot]) | |
demo.launch() | |