GoalsAI / app.py
CosmoAI's picture
Update app.py
83e0b34
raw
history blame
1.27 kB
import google.generativeai as palm
import gradio as gr
import os
import json
from transformers import pipeline
# Set your API key
palm.configure(api_key=os.environ['PALM_KEY'])
# Select the PaLM 2 model
# model = 'models/text-bison-001'
# candlab= ["recharge coins or get subscription", "show list of my friends"]
print(data["message"])
def responsenew(data):
response = palm.chat(messages=data)
# user_intent = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
if "payment" in response.last:
respo = {
"message": "Click the button below to view Premium Services and Coin Recharge options: ",
"action": "payment",
"function": "nothing"
}
elif "friends" in response.last:
respo = {
"message": "Slide left or right profiles or tap on 'My Friends' 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()