Spaces:
Running
Running
File size: 1,266 Bytes
e460bb5 c1548d4 e460bb5 c1548d4 83e0b34 71ad11e e460bb5 71ad11e e460bb5 a91e5a1 71ad11e 83e0b34 3ccb353 5f28fdf c1548d4 404a131 c1548d4 83e0b34 68add6e 86c27ed 83e0b34 86c27ed 518063c 86c27ed 83e0b34 86c27ed 0d2d23e c1548d4 4238098 c1548d4 4238098 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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"]
def responsenew(data):
print(data[0])
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()
|