Spaces:
Running
Running
File size: 1,836 Bytes
e460bb5 c1548d4 e460bb5 c1548d4 83e0b34 71ad11e e460bb5 71ad11e e460bb5 a91e5a1 71ad11e 83e0b34 3ccb353 5f28fdf c1548d4 7747bcb 24f170e 0d2d23e 24f170e 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 49 50 51 52 53 54 55 56 57 58 59 60 61 |
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()
|