GoalsAI / app.py
CosmoAI's picture
Update app.py
85d713e
raw
history blame
1.01 kB
import google.generativeai as palm
import gradio as gr
import os
import json
# Set your API key
palm.configure(api_key=os.environ['PALM_KEY'])
# Select the PaLM 2 model
# model = 'models/text-bison-001'
def responsenew(data):
response = palm.chat(messages=data)
if "payment" in response.last:
respo = {
"message": "Click the button below to view premium services and recharge options: ",
"action": "payment",
"function": "nothing"
}
elif "friends" in response.last:
respo = {
"message": "Click the option below to view list of your friends: ",
"action": "show_friends",
"function": "nothing"
}
else:
respo = {
"message": response.last,
"action": "nothing",
"function": "nothing"
}
return json.dumps(respo)
gradio_interface = gr.Interface(
fn = responsenew,
inputs = "text",
outputs = "text"
)
gradio_interface.launch()