Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,72 +15,69 @@ palm.configure(api_key=os.environ['PALM_KEY'])
|
|
| 15 |
def responsenew(data):
|
| 16 |
print(data)
|
| 17 |
response = palm.chat(messages=data)
|
| 18 |
-
intent = palm.chat(messages=f"""
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
5. sharedrem\n
|
| 33 |
-
6. myroutines\n\n
|
| 34 |
-
Your answer must be of one word only out of these above given words.""")
|
| 35 |
print(intent)
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# "message": response.last,
|
| 38 |
# "action": "nothing",
|
| 39 |
# "function": "nothing"
|
| 40 |
# }
|
| 41 |
-
|
| 42 |
-
if "recoin" in intent.last:
|
| 43 |
-
respo = {
|
| 44 |
-
"message": "Click the button below to view Premium Services and Coin Recharge options: ",
|
| 45 |
-
"action": "payment",
|
| 46 |
-
"function": "nothing"
|
| 47 |
-
}
|
| 48 |
-
elif "view_friends" in intent.last:
|
| 49 |
-
respo = {
|
| 50 |
-
"message": "Here's the list of your friends: ",
|
| 51 |
-
"action": "show_friends",
|
| 52 |
-
"function": "nothing"
|
| 53 |
-
}
|
| 54 |
-
elif "view_groups" in intent.last:
|
| 55 |
-
respo = {
|
| 56 |
-
"message": "You are member of following groups: ",
|
| 57 |
-
"action": "show_mygroups",
|
| 58 |
-
"function": "nothing"
|
| 59 |
-
}
|
| 60 |
-
elif "view_pages" in intent.last:
|
| 61 |
-
respo = {
|
| 62 |
-
"message": "You are part of following communities🫶: ",
|
| 63 |
-
"action": "show_mycommunities",
|
| 64 |
-
"function": "nothing"
|
| 65 |
-
}
|
| 66 |
-
elif "sharedrem" in intent.last:
|
| 67 |
-
respo = {
|
| 68 |
-
"message": "Here's the list of your shared reminders: ",
|
| 69 |
-
"action": "shared_reminders",
|
| 70 |
-
"function": "nothing"
|
| 71 |
-
}
|
| 72 |
-
elif "myroutines" in intent.last:
|
| 73 |
-
respo = {
|
| 74 |
-
"message": "Here's the list of your routines: ",
|
| 75 |
-
"action": "myroutines",
|
| 76 |
-
"function": "nothing"
|
| 77 |
-
}
|
| 78 |
-
else:
|
| 79 |
-
respo = {
|
| 80 |
-
"message": response.last,
|
| 81 |
-
"action": "nothing",
|
| 82 |
-
"function": "nothing"
|
| 83 |
-
}
|
| 84 |
return json.dumps(respo)
|
| 85 |
|
| 86 |
gradio_interface = gr.Interface(
|
|
|
|
| 15 |
def responsenew(data):
|
| 16 |
print(data)
|
| 17 |
response = palm.chat(messages=data)
|
| 18 |
+
intent = palm.chat(messages=f"""Identifies the user's intent from the given text data.
|
| 19 |
+
|
| 20 |
+
Args:
|
| 21 |
+
text_data: {data}.\n\n
|
| 22 |
+
|
| 23 |
+
Returns:
|
| 24 |
+
A one-word string representing the user's intent, one of:
|
| 25 |
+
* purchase_coins
|
| 26 |
+
* view_friends
|
| 27 |
+
* view_groups
|
| 28 |
+
* view_communities
|
| 29 |
+
* shared_reminders
|
| 30 |
+
* my_routines
|
| 31 |
+
""")
|
|
|
|
|
|
|
|
|
|
| 32 |
print(intent)
|
| 33 |
+
respo = {
|
| 34 |
+
"message": intent.last,
|
| 35 |
+
"action": "nothing",
|
| 36 |
+
"function": "nothing"
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
# if "recoin" in intent.last:
|
| 40 |
+
# respo = {
|
| 41 |
+
# "message": "Click the button below to view Premium Services and Coin Recharge options: ",
|
| 42 |
+
# "action": "payment",
|
| 43 |
+
# "function": "nothing"
|
| 44 |
+
# }
|
| 45 |
+
# elif "view_friends" in intent.last:
|
| 46 |
+
# respo = {
|
| 47 |
+
# "message": "Here's the list of your friends: ",
|
| 48 |
+
# "action": "show_friends",
|
| 49 |
+
# "function": "nothing"
|
| 50 |
+
# }
|
| 51 |
+
# elif "view_groups" in intent.last:
|
| 52 |
+
# respo = {
|
| 53 |
+
# "message": "You are member of following groups: ",
|
| 54 |
+
# "action": "show_mygroups",
|
| 55 |
+
# "function": "nothing"
|
| 56 |
+
# }
|
| 57 |
+
# elif "view_pages" in intent.last:
|
| 58 |
+
# respo = {
|
| 59 |
+
# "message": "You are part of following communities🫶: ",
|
| 60 |
+
# "action": "show_mycommunities",
|
| 61 |
+
# "function": "nothing"
|
| 62 |
+
# }
|
| 63 |
+
# elif "sharedrem" in intent.last:
|
| 64 |
+
# respo = {
|
| 65 |
+
# "message": "Here's the list of your shared reminders: ",
|
| 66 |
+
# "action": "shared_reminders",
|
| 67 |
+
# "function": "nothing"
|
| 68 |
+
# }
|
| 69 |
+
# elif "myroutines" in intent.last:
|
| 70 |
+
# respo = {
|
| 71 |
+
# "message": "Here's the list of your routines: ",
|
| 72 |
+
# "action": "myroutines",
|
| 73 |
+
# "function": "nothing"
|
| 74 |
+
# }
|
| 75 |
+
# else:
|
| 76 |
+
# respo = {
|
| 77 |
# "message": response.last,
|
| 78 |
# "action": "nothing",
|
| 79 |
# "function": "nothing"
|
| 80 |
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
return json.dumps(respo)
|
| 82 |
|
| 83 |
gradio_interface = gr.Interface(
|