GoalsAI / app.py
CosmoAI's picture
Update app.py
24f170e
raw
history blame
1.84 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"]
def responsenew(data):
print(data)
response = palm.chat(messages=f"""From the text given as data below by the user, find out what intention or category does the data fall under out of given 5 intents i.e:\n
1. purchasing coins\n
2. viewing friends list\n
3. viewing groups been joined by the user\n
4. viewing pages been joined by the user\n
5. user is saying to view the reminders been shared to the user or by the user\n
data = {data["text"]}""")
respo = {
"message": response.last,
"action": "nothing",
"function": "nothing"
}
# 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()