CosmoAI commited on
Commit
5cf9740
·
verified ·
1 Parent(s): 01bef6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -3
app.py CHANGED
@@ -89,17 +89,89 @@ model = genai.GenerativeModel(
89
 
90
  def responsenew(data):
91
 
92
- prompt = data
93
 
94
  respo = model.generate_content(
95
- prompt,
96
  generation_config={
97
  'temperature': 0,
98
  'max_output_tokens': 100
99
  }
100
  )
101
 
102
- return json.dumps(respo.text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
 
105
  gradio_interface = gr.Interface(
 
89
 
90
  def responsenew(data):
91
 
92
+ query = data
93
 
94
  respo = model.generate_content(
95
+ query,
96
  generation_config={
97
  'temperature': 0,
98
  'max_output_tokens': 100
99
  }
100
  )
101
 
102
+ idval = random.randint(1, 1000000000)
103
+ print(f"\n\n{data}")
104
+ newdata = data.replace("'", '"')
105
+ items = json.loads(newdata)
106
+ query = items['text']
107
+ query = query.lower()
108
+ # try:
109
+ # items = json.loads(newdata)
110
+ # query = items['text']
111
+ # query = query.lower()
112
+ # print(query)
113
+ # except json.JSONDecodeError as e:
114
+ # print("Invalid JSON:", e)
115
+ response = model.generate_content(query)
116
+ print(f"\n{response.text}")
117
+ if query is not None:
118
+ if "remind me" in query:
119
+ values = getValues(query)
120
+ if values[0] is not None:
121
+ msg = values[0]
122
+ else:
123
+ msg = "Reminder Alert"
124
+ if values[1] is not None:
125
+ time = values[1]
126
+ else:
127
+ time = "5:00 PM"
128
+ # time = time1 + timedelta(hours=1)
129
+ # time = time2.strftime("%d-%m-%Y %H:%M:%S.%f")
130
+ if values[2] is not None:
131
+ day = values[2]
132
+ else:
133
+ day = "today"
134
+ if values[3] is not None:
135
+ date = values[3]
136
+ else:
137
+ date = datetime.today()
138
+ if values[4] is not None:
139
+ reps = values[4]
140
+ else:
141
+ reps = "Once"
142
+ respo = {
143
+ 'message': f"Message: {msg} \nTime: {time} \nDay: {day} \nCreated Successfully.",
144
+ 'action': "create_reminder",
145
+ 'function': {
146
+ 'id': idval,
147
+ 'sound': 'General',
148
+ 'subTitle': 'Task',
149
+ 'type': 'Note',
150
+ 'title': msg,
151
+ 'description': '',
152
+ 'time': time.upper(),
153
+ 'timestamp' : datetime.now().strftime("%d-%m-%Y %H:%M:%S.%f"),
154
+ 'enable': False,
155
+ 'report': [],
156
+ 'icon': 'https://firebasestorage.googleapis.com/v0/b/cosmo-f5007.appspot.com/o/categories%2FIcons%2Ftaskicon.svg?alt=media&token=56f3fc55-8eda-4463-bceb-7bf3198dff3c',
157
+ 'color': 'FFD700',
158
+ 'sharedToMe': [],
159
+ 'sharedByMe': [],
160
+ 'repeat': reps,
161
+ 'reminders': [{
162
+ 'time': time.upper(),
163
+ 'enable': False,
164
+ 'repeat': reps,
165
+ 'title': msg,
166
+ 'id': idval,
167
+ 'note': '',
168
+ 'dates': [],
169
+ }],
170
+ }
171
+ }
172
+
173
+
174
+ return json.dumps(respo)
175
 
176
 
177
  gradio_interface = gr.Interface(