CosmoAI commited on
Commit
a544103
·
1 Parent(s): 3abd141

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +97 -8
app.py CHANGED
@@ -2,6 +2,9 @@ import google.generativeai as palm
2
  import gradio as gr
3
  import os
4
  import json
 
 
 
5
 
6
  # Set your API key
7
  palm.configure(api_key=os.environ["PALM_KEY"])
@@ -43,13 +46,99 @@ palm.configure(api_key=os.environ["PALM_KEY"])
43
 
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 "remind me" or "remind me to" in data:
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  if "add coins" in data:
54
  respo = {
55
  "message": "Click the button below to view Premium Services and Coin Recharge options: ",
@@ -86,12 +175,12 @@ def responsenew(data):
86
  "action": "myroutines",
87
  "function": "nothing",
88
  }
89
- # elif "cosmo_name" in intent.last:
90
- # respo = {
91
- # "message": "My name is Cosmo. I am your friendly personal assistant.",
92
- # "action": "nothing",
93
- # "function": "nothing",
94
- # }
95
  elif "notify" in data:
96
  respo = {
97
  "message": "Select your friends to notify",
@@ -112,7 +201,7 @@ def responsenew(data):
112
  }
113
  else:
114
  respo = {
115
- "message": "I am currently experiencing server overload, sorry for inconvenience. Please try again with your query.",
116
  "action": "nothing",
117
  "function": "nothing",
118
  }
 
2
  import gradio as gr
3
  import os
4
  import json
5
+ from getvalues import getValues
6
+ from datetime import datetime
7
+ import uuid
8
 
9
  # Set your API key
10
  palm.configure(api_key=os.environ["PALM_KEY"])
 
46
 
47
 
48
  def responsenew(data):
49
+ idval = uuid.uuid4()
50
  print(data)
51
  data = data.lower()
52
  response = palm.chat( messages=data)
53
  print(response)
54
  if data is not None:
55
+ if "remind me" or "remind me to" in data:
56
 
57
+ values = getValues(data)
58
+ if values[0] is not None:
59
+ msg = values[0]
60
+ else:
61
+ msg = "Reminder Alert"
62
+ if values[1] is not None:
63
+ time = values[1]
64
+ else:
65
+ time1 = datetime.now()
66
+ time2 = time1 + timedelta(hours=1)
67
+ time = time2.strftime("%d-%m-%Y %H:%M:%S.%f")
68
+ if values[2] is not None:
69
+ day = values[2]
70
+ else:
71
+ day = "today"
72
+ if values[3] is not None:
73
+ date = values[3]
74
+ else:
75
+ date = datetime.today()
76
+ if values[4] is not None:
77
+ reps = values[4]
78
+ else:
79
+ reps = "Once"
80
+ respo = {
81
+ 'messages': f"Your reminder for {msg} on {time} for {day} has been created successfully.",
82
+ 'action': "create_reminder",
83
+ 'function': {
84
+ 'id': idval,
85
+ 'sound': 'General',
86
+ 'subTitle': 'Task',
87
+ 'type': 'Note',
88
+ 'title': msg,
89
+ 'description': '',
90
+ 'time': time.upper(),
91
+ 'timestamp' : datetime.now().strftime("%d-%m-%Y %H:%M:%S.%f"),
92
+ 'enable': False,
93
+ 'report': [],
94
+ 'icon': 'https://firebasestorage.googleapis.com/v0/b/cosmo-f5007.appspot.com/o/categories%2FIcons%2Ftaskicon.svg?alt=media&token=56f3fc55-8eda-4463-bceb-7bf3198dff3c',
95
+ 'color': 'FFD700',
96
+ 'sharedToMe': [],
97
+ 'sharedByMe': [],
98
+ 'repeat': reps,
99
+ 'reminders': [{
100
+ 'time': time.upper(),
101
+ 'enable': False,
102
+ 'repeat': reps,
103
+ 'title': msg,
104
+ 'id': idval,
105
+ 'note': '',
106
+ 'dates': [],
107
+ }],
108
+ }
109
+ }
110
+
111
+ if "add todo" or "add to do" in data:
112
+ respo = {
113
+ 'messages': "Todo added!",
114
+ 'action': "create_todo",
115
+ 'function': {
116
+ 'name': 'defaulttodo',
117
+ 'id': idval,
118
+ 'subTasks': [{
119
+ 'task':data.replace("add todo", "add to do"),
120
+ 'done': False
121
+ }],
122
+ 'shared': [],
123
+ 'sharedByMe': [],
124
+ },
125
+ }
126
+ if "note down" in data:
127
+ respo = {
128
+ 'messages': "Got it!",
129
+ 'action': "create_note",
130
+ 'function': {
131
+ 'title': 'defaultnote',
132
+ 'id': idval,
133
+ 'type': 'Note',
134
+ 'description': data.replace("note down"),
135
+ 'time': datetime.now().strftime("%d/%m/%Y"),
136
+ 'mainTime': datetime.now().strftime("%I:%M %p"),
137
+ 'complete': False,
138
+ 'shared': [],
139
+ 'sharedByMe': [],
140
+ }
141
+ }
142
  if "add coins" in data:
143
  respo = {
144
  "message": "Click the button below to view Premium Services and Coin Recharge options: ",
 
175
  "action": "myroutines",
176
  "function": "nothing",
177
  }
178
+ elif "what is your name" or "what's your name" or "who are you" in data:
179
+ respo = {
180
+ "message": "My name is Cosmo. I am your friendly personal assistant.",
181
+ "action": "nothing",
182
+ "function": "nothing",
183
+ }
184
  elif "notify" in data:
185
  respo = {
186
  "message": "Select your friends to notify",
 
201
  }
202
  else:
203
  respo = {
204
+ "message": "Whoops, seems like we're a bit overloaded! Don't worry, your request is in the queue and we'll get back to you as soon as possible.",
205
  "action": "nothing",
206
  "function": "nothing",
207
  }