CosmoAI commited on
Commit
83025cc
·
1 Parent(s): 4419747
Files changed (1) hide show
  1. app.py +62 -59
app.py CHANGED
@@ -12,9 +12,7 @@ palm.configure(api_key=os.environ["PALM_KEY"])
12
 
13
  def responsenew(data):
14
  print(data)
15
- response = palm.chat(messages=data)
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
- Identify the user's intent from the given text data.\n
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
- if "purchase_coins" in intent.last:
94
- respo = {
95
- "message": "Click the button below to view Premium Services and Coin Recharge options: ",
96
- "action": "payment",
97
- "function": "nothing",
98
- }
99
- elif "view_friends" in intent.last:
100
- respo = {
101
- "message": "Here's the list of your friends: ",
102
- "action": "show_friends",
103
- "function": "nothing",
104
- }
105
- elif "view_groups" in intent.last:
106
- respo = {
107
- "message": "You are member of following groups: ",
108
- "action": "show_mygroups",
109
- "function": "nothing",
110
- }
111
- elif "view_communities" in intent.last:
112
- respo = {
113
- "message": "You are part of following communities🫶: ",
114
- "action": "show_mycommunities",
115
- "function": "nothing",
116
- }
117
- elif "shared_reminders" in intent.last:
118
- respo = {
119
- "message": "Here's the list of your shared reminders: ",
120
- "action": "shared_reminders",
121
- "function": "nothing",
122
- }
123
- elif "my_routines" in intent.last:
124
- respo = {
125
- "message": "Here's the list of your routines: ",
126
- "action": "myroutines",
127
- "function": "nothing",
128
- }
129
- elif "cosmo_name" in intent.last:
130
- respo = {
131
- "message": "My name is Cosmo. I am your friendly personal assistant.",
132
- "action": "nothing",
133
- "function": "nothing",
134
- }
135
- else:
136
- respo = {"message": response.last, "action": "nothing", "function": "nothing"}
 
 
 
 
137
  else:
138
- respo = {"message": "Unable to understand.", "action": "nothing", "function": "nothing"}
 
 
 
 
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