Spaces:
Runtime error
Runtime error
this
Browse files
app.py
CHANGED
|
@@ -12,9 +12,7 @@ palm.configure(api_key=os.environ["PALM_KEY"])
|
|
| 12 |
|
| 13 |
def responsenew(data):
|
| 14 |
print(data)
|
| 15 |
-
|
| 16 |
-
intent = palm.chat(
|
| 17 |
-
messages=f"""Act as a friendly personal assistant named Cosmo. ".
|
| 18 |
You help users manage their daily tasks by providing them with a variety of features.
|
| 19 |
Below are the list of features you have: \n
|
| 20 |
- You can create goals\n
|
|
@@ -42,14 +40,12 @@ def responsenew(data):
|
|
| 42 |
- You can view your shared todo lists\n
|
| 43 |
- You can view your shared notes\n
|
| 44 |
- You can start a timer or a stopwatch\n
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
Args:\n
|
| 50 |
-
text_data: {data}.\n\n
|
| 51 |
|
| 52 |
-
Return the intent as one-word string representing the user's intent, one of:
|
| 53 |
* if intent = purchasing coins return = "purchase_coins"
|
| 54 |
* if intent = viewing friends return = "view_friends"
|
| 55 |
* if intent = viewing groups joined return = "view_groups"
|
|
@@ -79,10 +75,9 @@ Return the intent as one-word string representing the user's intent, one of:
|
|
| 79 |
* if intent = sharing a note return = "share_note"
|
| 80 |
* if intent = knowing your name or who you are or what is your name return = "cosmo_name"
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
)
|
| 86 |
print(intent)
|
| 87 |
# respo = {
|
| 88 |
# "message": intent.last,
|
|
@@ -90,52 +85,60 @@ Return the intent as one-word string representing the user's intent, one of:
|
|
| 90 |
# "function": "nothing"
|
| 91 |
# }
|
| 92 |
if intent.last is not None:
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
else:
|
| 138 |
-
respo = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
return json.dumps(respo)
|
| 140 |
|
| 141 |
|
|
|
|
| 12 |
|
| 13 |
def responsenew(data):
|
| 14 |
print(data)
|
| 15 |
+
contxxt = f"""Act as a friendly personal assistant named Cosmo. ".
|
|
|
|
|
|
|
| 16 |
You help users manage their daily tasks by providing them with a variety of features.
|
| 17 |
Below are the list of features you have: \n
|
| 18 |
- You can create goals\n
|
|
|
|
| 40 |
- You can view your shared todo lists\n
|
| 41 |
- You can view your shared notes\n
|
| 42 |
- You can start a timer or a stopwatch\n
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
"""
|
| 46 |
+
exmpl = """Identify the user's intent from user's input message.\n
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
Return the intent as one-word string representing the user's intent, one of:
|
| 49 |
* if intent = purchasing coins return = "purchase_coins"
|
| 50 |
* if intent = viewing friends return = "view_friends"
|
| 51 |
* if intent = viewing groups joined return = "view_groups"
|
|
|
|
| 75 |
* if intent = sharing a note return = "share_note"
|
| 76 |
* if intent = knowing your name or who you are or what is your name return = "cosmo_name"
|
| 77 |
|
| 78 |
+
"""
|
| 79 |
+
response = palm.chat(context = contxxt, example = exmpl, messages=data)
|
| 80 |
+
intent = palm.chat(messages="")
|
|
|
|
| 81 |
print(intent)
|
| 82 |
# respo = {
|
| 83 |
# "message": intent.last,
|
|
|
|
| 85 |
# "function": "nothing"
|
| 86 |
# }
|
| 87 |
if intent.last is not None:
|
| 88 |
+
if "purchase_coins" in intent.last:
|
| 89 |
+
respo = {
|
| 90 |
+
"message": "Click the button below to view Premium Services and Coin Recharge options: ",
|
| 91 |
+
"action": "payment",
|
| 92 |
+
"function": "nothing",
|
| 93 |
+
}
|
| 94 |
+
elif "view_friends" in intent.last:
|
| 95 |
+
respo = {
|
| 96 |
+
"message": "Here's the list of your friends: ",
|
| 97 |
+
"action": "show_friends",
|
| 98 |
+
"function": "nothing",
|
| 99 |
+
}
|
| 100 |
+
elif "view_groups" in intent.last:
|
| 101 |
+
respo = {
|
| 102 |
+
"message": "You are member of following groups: ",
|
| 103 |
+
"action": "show_mygroups",
|
| 104 |
+
"function": "nothing",
|
| 105 |
+
}
|
| 106 |
+
elif "view_communities" in intent.last:
|
| 107 |
+
respo = {
|
| 108 |
+
"message": "You are part of following communities🫶: ",
|
| 109 |
+
"action": "show_mycommunities",
|
| 110 |
+
"function": "nothing",
|
| 111 |
+
}
|
| 112 |
+
elif "shared_reminders" in intent.last:
|
| 113 |
+
respo = {
|
| 114 |
+
"message": "Here's the list of your shared reminders: ",
|
| 115 |
+
"action": "shared_reminders",
|
| 116 |
+
"function": "nothing",
|
| 117 |
+
}
|
| 118 |
+
elif "my_routines" in intent.last:
|
| 119 |
+
respo = {
|
| 120 |
+
"message": "Here's the list of your routines: ",
|
| 121 |
+
"action": "myroutines",
|
| 122 |
+
"function": "nothing",
|
| 123 |
+
}
|
| 124 |
+
elif "cosmo_name" in intent.last:
|
| 125 |
+
respo = {
|
| 126 |
+
"message": "My name is Cosmo. I am your friendly personal assistant.",
|
| 127 |
+
"action": "nothing",
|
| 128 |
+
"function": "nothing",
|
| 129 |
+
}
|
| 130 |
+
else:
|
| 131 |
+
respo = {
|
| 132 |
+
"message": response.last,
|
| 133 |
+
"action": "nothing",
|
| 134 |
+
"function": "nothing",
|
| 135 |
+
}
|
| 136 |
else:
|
| 137 |
+
respo = {
|
| 138 |
+
"message": "Unable to understand.",
|
| 139 |
+
"action": "nothing",
|
| 140 |
+
"function": "nothing",
|
| 141 |
+
}
|
| 142 |
return json.dumps(respo)
|
| 143 |
|
| 144 |
|