CosmoAI commited on
Commit
afbc0cf
·
1 Parent(s): 9598c37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +114 -47
app.py CHANGED
@@ -44,76 +44,41 @@ palm.configure(api_key=os.environ["PALM_KEY"])
44
 
45
  def responsenew(data):
46
  print(data)
47
- # contxxt = f"""
48
-
49
- # """
50
-
51
  response = palm.chat( messages=data)
52
- intent = palm.chat(
53
- messages=f"""
54
-
55
- Identify the user's intent from text_data below:\n
56
- Arguments: text_data = {data}\n\n
57
- Return the intent as one-word string representing the user's intent, as mentioned below:
58
- * if intent = viewing user's routine return = "my_routines"
59
- * if intent = viewing user's notes return = "view_notes"
60
- * if intent = viewing user's posts return = "view_posts"
61
- * if intent = viewing user's shared notes return = "view_shared_notes"
62
- * if intent = viewing user's todo lists return = "view_todo_lists"
63
- * if intent = viewing user's shared todo lists return = "view_shared_todo_lists"
64
- * if intent = viewing user's shared routines return = "view_shared_routines"
65
- * if intent = creating a goal return = "create_goal"
66
- * if intent = creating a reminder return = "create_reminder"
67
- * if intent = creating a routine return = "create_routine"
68
- * if intent = creating a group return = "create_group"
69
- * if intent = creating a community return = "create_community"
70
- * if intent = creating a note return = "create_note"
71
- * if intent = creating a post return = "create_post"
72
- * if intent = creating a todo list return = "create_todo_list"
73
- * if intent = sharing a reminder return = "share_reminder"
74
- * if intent = sharing a routine return = "share_routine"
75
- * if intent = sharing a group return = "share_group"
76
- * if intent = sharing a todo list return = "share_todo_list"
77
- * if intent = sharing a note return = "share_note"
78
- * if intent = notify then return = "send_notify"
79
- * if intent = show actions then return = "show_actions"
80
-
81
- """,
82
- )
83
- print(intent)
84
- # respo = {"message": intent.last, "action": "nothing", "function": "nothing"}
85
- if intent.last is not None:
86
- if "purchase_coins" in intent.last:
87
  respo = {
88
  "message": "Click the button below to view Premium Services and Coin Recharge options: ",
89
  "action": "payment",
90
  "function": "nothing",
91
  }
92
- elif "view_friends" in intent.last:
93
  respo = {
94
  "message": "Here's the list of your friends: ",
95
  "action": "show_friends",
96
  "function": "nothing",
97
  }
98
- elif "view_groups" in intent.last:
99
  respo = {
100
  "message": "You are member of following groups: ",
101
  "action": "show_mygroups",
102
  "function": "nothing",
103
  }
104
- elif "view_communities" in intent.last:
105
  respo = {
106
  "message": "You are part of following communities🫶: ",
107
  "action": "show_mycommunities",
108
  "function": "nothing",
109
  }
110
- elif "shared_reminders" in intent.last:
111
  respo = {
112
  "message": "Here's the list of your shared reminders: ",
113
  "action": "shared_reminders",
114
  "function": "nothing",
115
  }
116
- elif "my_routines" in intent.last:
117
  respo = {
118
  "message": "Here's the list of your routines: ",
119
  "action": "myroutines",
@@ -125,13 +90,13 @@ def responsenew(data):
125
  # "action": "nothing",
126
  # "function": "nothing",
127
  # }
128
- elif "send_notify" in intent.last:
129
  respo = {
130
  "message": "Select your friends to notify",
131
  "action": "send_notify",
132
  "function": "nothing",
133
  }
134
- elif "show_actions" in intent.last:
135
  respo = {
136
  "message": "Here is list of actions you can use:",
137
  "action": "show_actions",
@@ -145,11 +110,113 @@ def responsenew(data):
145
  }
146
  else:
147
  respo = {
148
- "message": response.last,
149
  "action": "nothing",
150
  "function": "nothing",
151
  }
152
  return json.dumps(respo)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
 
155
  gradio_interface = gr.Interface(fn=responsenew, inputs="text", outputs="text")
 
44
 
45
  def responsenew(data):
46
  print(data)
47
+ data = data.lower()
 
 
 
48
  response = palm.chat( messages=data)
49
+ print(response)
50
+ if data is not None:
51
+ if "add coins" in data:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  respo = {
53
  "message": "Click the button below to view Premium Services and Coin Recharge options: ",
54
  "action": "payment",
55
  "function": "nothing",
56
  }
57
+ elif "show my friends" in data:
58
  respo = {
59
  "message": "Here's the list of your friends: ",
60
  "action": "show_friends",
61
  "function": "nothing",
62
  }
63
+ elif "show my groups" in data:
64
  respo = {
65
  "message": "You are member of following groups: ",
66
  "action": "show_mygroups",
67
  "function": "nothing",
68
  }
69
+ elif "show my communities" in data:
70
  respo = {
71
  "message": "You are part of following communities🫶: ",
72
  "action": "show_mycommunities",
73
  "function": "nothing",
74
  }
75
+ elif " show shared reminders" in data:
76
  respo = {
77
  "message": "Here's the list of your shared reminders: ",
78
  "action": "shared_reminders",
79
  "function": "nothing",
80
  }
81
+ elif "show my routines" in data:
82
  respo = {
83
  "message": "Here's the list of your routines: ",
84
  "action": "myroutines",
 
90
  # "action": "nothing",
91
  # "function": "nothing",
92
  # }
93
+ elif "notify" in data:
94
  respo = {
95
  "message": "Select your friends to notify",
96
  "action": "send_notify",
97
  "function": "nothing",
98
  }
99
+ elif "show actions" in data:
100
  respo = {
101
  "message": "Here is list of actions you can use:",
102
  "action": "show_actions",
 
110
  }
111
  else:
112
  respo = {
113
+ "message": "I am currently experiencing server overload, sorry for inconvenience. Please try again with your query.",
114
  "action": "nothing",
115
  "function": "nothing",
116
  }
117
  return json.dumps(respo)
118
+
119
+ # intent = palm.chat(
120
+ # messages=f"""
121
+
122
+ # Identify the user's intent from text_data below:\n
123
+ # Arguments: text_data = {data}\n\n
124
+ # Return the intent as one-word string representing the user's intent, as mentioned below:
125
+ # * if intent = viewing user's routine return = "my_routines"
126
+ # * if intent = viewing user's notes return = "view_notes"
127
+ # * if intent = viewing user's posts return = "view_posts"
128
+ # * if intent = viewing user's shared notes return = "view_shared_notes"
129
+ # * if intent = viewing user's todo lists return = "view_todo_lists"
130
+ # * if intent = viewing user's shared todo lists return = "view_shared_todo_lists"
131
+ # * if intent = viewing user's shared routines return = "view_shared_routines"
132
+ # * if intent = creating a goal return = "create_goal"
133
+ # * if intent = creating a reminder return = "create_reminder"
134
+ # * if intent = creating a routine return = "create_routine"
135
+ # * if intent = creating a group return = "create_group"
136
+ # * if intent = creating a community return = "create_community"
137
+ # * if intent = creating a note return = "create_note"
138
+ # * if intent = creating a post return = "create_post"
139
+ # * if intent = creating a todo list return = "create_todo_list"
140
+ # * if intent = sharing a reminder return = "share_reminder"
141
+ # * if intent = sharing a routine return = "share_routine"
142
+ # * if intent = sharing a group return = "share_group"
143
+ # * if intent = sharing a todo list return = "share_todo_list"
144
+ # * if intent = sharing a note return = "share_note"
145
+ # * if intent = notify then return = "send_notify"
146
+ # * if intent = show actions then return = "show_actions"
147
+
148
+ # """,
149
+ # )
150
+
151
+ # respo = {"message": intent.last, "action": "nothing", "function": "nothing"}
152
+ # if intent.last is not None:
153
+ # if "purchase_coins" in intent.last:
154
+ # respo = {
155
+ # "message": "Click the button below to view Premium Services and Coin Recharge options: ",
156
+ # "action": "payment",
157
+ # "function": "nothing",
158
+ # }
159
+ # elif "view_friends" in intent.last:
160
+ # respo = {
161
+ # "message": "Here's the list of your friends: ",
162
+ # "action": "show_friends",
163
+ # "function": "nothing",
164
+ # }
165
+ # elif "view_groups" in intent.last:
166
+ # respo = {
167
+ # "message": "You are member of following groups: ",
168
+ # "action": "show_mygroups",
169
+ # "function": "nothing",
170
+ # }
171
+ # elif "view_communities" in intent.last:
172
+ # respo = {
173
+ # "message": "You are part of following communities🫶: ",
174
+ # "action": "show_mycommunities",
175
+ # "function": "nothing",
176
+ # }
177
+ # elif "shared_reminders" in intent.last:
178
+ # respo = {
179
+ # "message": "Here's the list of your shared reminders: ",
180
+ # "action": "shared_reminders",
181
+ # "function": "nothing",
182
+ # }
183
+ # elif "my_routines" in intent.last:
184
+ # respo = {
185
+ # "message": "Here's the list of your routines: ",
186
+ # "action": "myroutines",
187
+ # "function": "nothing",
188
+ # }
189
+ # # elif "cosmo_name" in intent.last:
190
+ # # respo = {
191
+ # # "message": "My name is Cosmo. I am your friendly personal assistant.",
192
+ # # "action": "nothing",
193
+ # # "function": "nothing",
194
+ # # }
195
+ # elif "send_notify" in intent.last:
196
+ # respo = {
197
+ # "message": "Select your friends to notify",
198
+ # "action": "send_notify",
199
+ # "function": "nothing",
200
+ # }
201
+ # elif "show_actions" in intent.last:
202
+ # respo = {
203
+ # "message": "Here is list of actions you can use:",
204
+ # "action": "show_actions",
205
+ # "function": "nothing",
206
+ # }
207
+ # else:
208
+ # respo = {
209
+ # "message": response.last,
210
+ # "action": "nothing",
211
+ # "function": "nothing",
212
+ # }
213
+ # else:
214
+ # respo = {
215
+ # "message": response.last,
216
+ # "action": "nothing",
217
+ # "function": "nothing",
218
+ # }
219
+ # return json.dumps(respo)
220
 
221
 
222
  gradio_interface = gr.Interface(fn=responsenew, inputs="text", outputs="text")