Spaces:
Running
Running
File size: 2,414 Bytes
e460bb5 c1548d4 e460bb5 c1548d4 71ad11e e460bb5 71ad11e e460bb5 a91e5a1 71ad11e 83e0b34 3ccb353 5f28fdf c1548d4 7747bcb e646f95 a07fe07 47c93b4 a07fe07 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
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):
print(data)
response = palm.chat(messages=data)
intent = palm.chat(messages=f"""Identifies the user's intent from the given text data.
Args:
text_data: {data}.\n\n
Returns:
A one-word string representing the user's intent, one of:
* purchase_coins
* view_friends
* view_groups
* view_communities
* shared_reminders
* my_routines
""")
print(intent)
respo = {
"message": intent.last,
"action": "nothing",
"function": "nothing"
}
# if "recoin" in intent.last:
# respo = {
# "message": "Click the button below to view Premium Services and Coin Recharge options: ",
# "action": "payment",
# "function": "nothing"
# }
# elif "view_friends" in intent.last:
# respo = {
# "message": "Here's the list of your friends: ",
# "action": "show_friends",
# "function": "nothing"
# }
# elif "view_groups" in intent.last:
# respo = {
# "message": "You are member of following groups: ",
# "action": "show_mygroups",
# "function": "nothing"
# }
# elif "view_pages" in intent.last:
# respo = {
# "message": "You are part of following communities🫶: ",
# "action": "show_mycommunities",
# "function": "nothing"
# }
# elif "sharedrem" in intent.last:
# respo = {
# "message": "Here's the list of your shared reminders: ",
# "action": "shared_reminders",
# "function": "nothing"
# }
# elif "myroutines" in intent.last:
# respo = {
# "message": "Here's the list of your routines: ",
# "action": "myroutines",
# "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()
|