focusit CosmoAI commited on
Commit
5b58e89
·
0 Parent(s):

Duplicate from CosmoAI/Cosmo

Browse files

Co-authored-by: Sachin Verma <[email protected]>

Files changed (10) hide show
  1. .gitattributes +35 -0
  2. README.md +15 -0
  3. app.py +232 -0
  4. cookies.json +119 -0
  5. database/data.json +78 -0
  6. executequery.py +113 -0
  7. getvalues.py +95 -0
  8. intents.json +373 -0
  9. intents.pth +3 -0
  10. requirements.txt +7 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Cosmo
3
+ emoji: 😻
4
+ colorFrom: indigo
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 3.36.0
8
+ app_file: app.py
9
+ python_version: 3.9.13
10
+ pinned: true
11
+ license: openrail
12
+ duplicated_from: CosmoAI/Cosmo
13
+ ---
14
+
15
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import os
4
+ import time
5
+ import uuid
6
+ from datetime import datetime
7
+ import json
8
+ from bardapi import Bard
9
+ from dotenv import load_dotenv
10
+ from executequery import ExecuteQuery
11
+ from getvalues import getValues
12
+
13
+ load_dotenv()
14
+
15
+ bardkey = os.environ.get('_BARD_API_KEY')
16
+
17
+
18
+ def bardChat(data):
19
+
20
+
21
+ # Create a session object using the requests library
22
+ session = requests.Session()
23
+
24
+ # Set the headers for the session
25
+ session.headers = {
26
+ "Host": "bard.google.com",
27
+ "X-Same-Domain": "1",
28
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
29
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
30
+ "Origin": "https://bard.google.com",
31
+ "Referer": "https://bard.google.com/",
32
+ }
33
+
34
+ # Set the "__Secure-1PSID" cookie with the Bard API key
35
+ session.cookies.set("__Secure-1PSID", bardKey)
36
+
37
+ # Create a Bard object with the session and a timeout of 30 seconds
38
+ bard = Bard(session=session, timeout=30)
39
+ answer = bard.get_answer(data)['content']
40
+ return answer
41
+ # return json.dumps({'message':answer,'action':'null'})
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ def responsenew(data):
50
+
51
+ idval = str(uuid.uuid4())
52
+ result = ExecuteQuery(data)
53
+
54
+ if result[1] == 'opencosmo':
55
+ jdata = {
56
+ "message": bardChat(data),
57
+ "action": "chitchat",
58
+ "function": None
59
+ }
60
+ return jdata
61
+
62
+ elif result[1] == 'create_reminder':
63
+ remvalues = getValues(data)
64
+ jdata = {
65
+ "message": result[0],
66
+ "action": "create_reminder",
67
+ 'function': {
68
+ 'id': str(uuid.uuid4()),
69
+ 'sound': 'General',
70
+ 'subTitle': 'Task',
71
+ 'type': 'Note',
72
+ 'title': remvalues[0],
73
+ 'description': '',
74
+ 'time': remvalues[1].upper(),
75
+ 'timestamp' : datetime.now().strftime("%d-%m-%Y %H:%M:%S.%f"),
76
+ 'enable': False,
77
+ 'report': [],
78
+ 'icon': 'https://firebasestorage.googleapis.com/v0/b/cosmo-f5007.appspot.com/o/categories%2FIcons%2Ftaskicon.svg?alt=media&token=56f3fc55-8eda-4463-bceb-7bf3198dff3c',
79
+ 'color': 'FFD700',
80
+ 'sharedToMe': [],
81
+ 'sharedByMe': [],
82
+ 'repeat': 'Daily',
83
+ 'reminders': [{
84
+ 'time': remvalues[1].upper(),
85
+ 'enable': False,
86
+ 'repeat': remvalues[4],
87
+ 'title': remvalues[0],
88
+ 'id': str(uuid.uuid4()),
89
+ 'note': '',
90
+ 'dates': [],
91
+ }],
92
+ }
93
+ }
94
+ return jdata
95
+
96
+ elif result[1] == 'create_todo':
97
+ jdata = {
98
+ 'messages': result[0],
99
+ 'action': result[1],
100
+ 'function': {
101
+ 'name': 'defaulttodo',
102
+ 'id': str(uuid.uuid4()),
103
+ 'subTasks': [{
104
+ 'task':remvalues[0].replace("create a todo", ""),
105
+ 'done': False
106
+ }],
107
+ 'shared': [],
108
+ 'sharedByMe': [],
109
+ },
110
+ }
111
+
112
+ elif result[1] == 'show_routine_today':
113
+ jdata = {
114
+ "message": result[0],
115
+ "action": "show_routine_today",
116
+ "values": None
117
+ }
118
+ return jdata
119
+
120
+ elif result[1] == 'create_note':
121
+ notevalues = data.lower().replace('create a note ','').replace("remember","").replace('note','').replace('jot down', ''). replace('make a note','')
122
+ jdata = {
123
+ 'messages': result[0],
124
+ 'action': result[1],
125
+ 'function': {
126
+ 'title': 'defaultnote',
127
+ 'id': idval,
128
+ 'type': 'Note',
129
+ 'description': notevalues,
130
+ 'time': datetime.now().strftime("%d/%m/%Y"),
131
+ 'mainTime': datetime.now().strftime("%I:%M %p"),
132
+ 'complete': False,
133
+ 'shared': [],
134
+ 'sharedByMe': [],
135
+ }
136
+ }
137
+ return jdata
138
+
139
+
140
+ elif result[1] == 'show_people':
141
+ jdata = {
142
+ 'messages': result[0],
143
+ 'action': result[1]
144
+ }
145
+ return jdata
146
+
147
+ elif result[1] == 'show_friends':
148
+ jdata = {
149
+ 'messages': result[0],
150
+ 'action': result[1]
151
+ }
152
+ return jdata
153
+
154
+ elif result[1] == 'show_allgroups':
155
+ jdata = {
156
+ 'messages': result[0],
157
+ 'action': result[1]
158
+ }
159
+ return jdata
160
+
161
+ elif result[1] == 'show_mygroups':
162
+ jdata = {
163
+ 'messages': result[0],
164
+ 'action': result[1]
165
+ }
166
+ return jdata
167
+
168
+ elif result[1] == 'show_allcommunities':
169
+ jdata = {
170
+ 'messages': result[0],
171
+ 'action': result[1]
172
+ }
173
+ return jdata
174
+
175
+ elif result[1] == 'show_mycommunities':
176
+ jdata = {
177
+ 'messages': result[0],
178
+ 'action': result[1]
179
+ }
180
+ return jdata
181
+
182
+ elif result[1] == 'name':
183
+ jdata = {
184
+ 'messages': result[0],
185
+ 'action': result[1]
186
+ }
187
+ return jdata
188
+
189
+ elif result[1] == 'creator':
190
+ jdata = {
191
+ 'messages': result[0],
192
+ 'action': result[1]
193
+ }
194
+ return jdata
195
+
196
+ elif result[1] == 'commands':
197
+ jdata = {
198
+ 'messages': result[0],
199
+ 'action': result[1]
200
+ }
201
+ return jdata
202
+
203
+ elif result[1] == 'goodbye':
204
+ jdata = {
205
+ 'messages': result[0],
206
+ 'action': result[1]
207
+ }
208
+ return jdata
209
+
210
+ elif result[1] == 'view_commands':
211
+ jdata = {
212
+ 'messages': result[0],
213
+ 'action': result[1]
214
+ }
215
+ return jdata
216
+
217
+
218
+ with gr.Blocks() as demo:
219
+ chatbot = gr.Chatbot()
220
+ msg = gr.Textbox()
221
+ # clear = gr.ClearButton([msg, chatbot])
222
+
223
+ def respond(message, chat_history):
224
+ bot_message = responsenew(message)
225
+ chat_history.append((message, bot_message))
226
+ time.sleep(2)
227
+ return "", chat_history
228
+
229
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
230
+
231
+ if __name__ == "__main__":
232
+ demo.launch()
cookies.json ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "domain": ".huggingface.co",
4
+ "expirationDate": 1720958854,
5
+ "hostOnly": false,
6
+ "httpOnly": false,
7
+ "name": "__stripe_mid",
8
+ "path": "/",
9
+ "sameSite": "strict",
10
+ "secure": true,
11
+ "session": false,
12
+ "storeId": null,
13
+ "value": "2461430b-f4b2-469d-b190-1803f43e4e91940b94"
14
+ },
15
+ {
16
+ "domain": ".huggingface.co",
17
+ "expirationDate": 1723982852.916105,
18
+ "hostOnly": false,
19
+ "httpOnly": false,
20
+ "name": "_ga",
21
+ "path": "/",
22
+ "sameSite": null,
23
+ "secure": false,
24
+ "session": false,
25
+ "storeId": null,
26
+ "value": "GA1.1.1157622098.1688730215"
27
+ },
28
+ {
29
+ "domain": ".huggingface.co",
30
+ "expirationDate": 1723872324.987826,
31
+ "hostOnly": false,
32
+ "httpOnly": false,
33
+ "name": "_ga_R4JMGZWPD9",
34
+ "path": "/",
35
+ "sameSite": null,
36
+ "secure": false,
37
+ "session": false,
38
+ "storeId": null,
39
+ "value": "GS1.1.1689311953.2.0.1689312324.0.0.0"
40
+ },
41
+ {
42
+ "domain": ".huggingface.co",
43
+ "expirationDate": 1720789881.61771,
44
+ "hostOnly": false,
45
+ "httpOnly": true,
46
+ "name": "token",
47
+ "path": "/",
48
+ "sameSite": "lax",
49
+ "secure": true,
50
+ "session": false,
51
+ "storeId": null,
52
+ "value": "PfgRQXmdEuDtwQQKmfHrbLqysAPNJorxuExZrHHXfIruxhjZNFyRwUgyyZWqKiIngKOsxXUFFzjvoQiFEYIBqCJUpmvVCLixjTYOkQalOsOljswGSiWMLVBUgHTcnavG"
53
+ },
54
+ {
55
+ "domain": ".huggingface.co",
56
+ "expirationDate": 1689424654,
57
+ "hostOnly": false,
58
+ "httpOnly": false,
59
+ "name": "__stripe_sid",
60
+ "path": "/",
61
+ "sameSite": "strict",
62
+ "secure": true,
63
+ "session": false,
64
+ "storeId": null,
65
+ "value": "8edac1fb-17b8-4b72-a3de-7b4e6e938a6bcacdd4"
66
+ },
67
+ {
68
+ "domain": ".huggingface.co",
69
+ "expirationDate": 1723982852.915394,
70
+ "hostOnly": false,
71
+ "httpOnly": false,
72
+ "name": "_ga_8Q63TH4CSL",
73
+ "path": "/",
74
+ "sameSite": null,
75
+ "secure": false,
76
+ "session": false,
77
+ "storeId": null,
78
+ "value": "GS1.1.1689420718.5.1.1689422852.0.0.0"
79
+ },
80
+ {
81
+ "domain": ".huggingface.co",
82
+ "expirationDate": 1689422912,
83
+ "hostOnly": false,
84
+ "httpOnly": false,
85
+ "name": "_gat",
86
+ "path": "/",
87
+ "sameSite": null,
88
+ "secure": false,
89
+ "session": false,
90
+ "storeId": null,
91
+ "value": "1"
92
+ },
93
+ {
94
+ "domain": ".huggingface.co",
95
+ "expirationDate": 1689509252,
96
+ "hostOnly": false,
97
+ "httpOnly": false,
98
+ "name": "_gid",
99
+ "path": "/",
100
+ "sameSite": null,
101
+ "secure": false,
102
+ "session": false,
103
+ "storeId": null,
104
+ "value": "GA1.2.1368513703.1689404013"
105
+ },
106
+ {
107
+ "domain": "huggingface.co",
108
+ "expirationDate": 1721045184.390155,
109
+ "hostOnly": true,
110
+ "httpOnly": true,
111
+ "name": "hf-chat",
112
+ "path": "/",
113
+ "sameSite": "no_restriction",
114
+ "secure": true,
115
+ "session": false,
116
+ "storeId": null,
117
+ "value": "4852609b-4587-4767-b2d8-65595c9f5170"
118
+ }
119
+ ]
database/data.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "reminders": [
3
+ {
4
+ "rmid": 1,
5
+ "message": " learn python",
6
+ "date": "24/11/2022",
7
+ "status": "incomplete",
8
+ "day": "today",
9
+ "repeat": "no",
10
+ "time": "05:00"
11
+ },
12
+ {
13
+ "rmid": "317329a4-7639-41ec-b785-dbef654fad47",
14
+ "message": " buy fruits at ",
15
+ "status": "incomplete",
16
+ "time": "5:00 pm",
17
+ "date": "nodate",
18
+ "day": "tomorrow",
19
+ "repeat": "No repeat found"
20
+ },
21
+ {
22
+ "rmid": "8543e845-1263-4f5e-9e3d-e28425cf773b",
23
+ "message": " to finish task evening",
24
+ "status": "incomplete",
25
+ "time": "notime",
26
+ "date": "nodate",
27
+ "day": "today",
28
+ "repeat": "norepeat"
29
+ },
30
+ {
31
+ "rmid": "d6fafd32-ceea-455d-9125-3ecfee55034a",
32
+ "message": " buy flowers",
33
+ "status": "incomplete",
34
+ "time": "notime",
35
+ "date": "nodate",
36
+ "day": "noday",
37
+ "repeat": "norepeat"
38
+ },
39
+ {
40
+ "rmid": "1d3d95da-e923-4eb8-9f95-d97f9677b883",
41
+ "message": " me on to go to markett",
42
+ "status": "incomplete",
43
+ "time": "notime",
44
+ "date": "nodate",
45
+ "day": "wednesday",
46
+ "repeat": "norepeat"
47
+ },
48
+ {
49
+ "rmid": "99d0a2b9-9054-4778-85d6-5120525f554c",
50
+ "message": " do 20 pushups before lunch",
51
+ "status": "incomplete",
52
+ "time": "notime",
53
+ "date": "nodate",
54
+ "day": "today",
55
+ "repeat": "norepeat"
56
+ }
57
+ ],
58
+ "notes": [
59
+ {
60
+ "nid": 1,
61
+ "date": "29/11/2022",
62
+ "time": "18:10:05",
63
+ "content": "this is the firstt note"
64
+ },
65
+ {
66
+ "nid": "8f3a9410-8a01-474d-8565-d862ba675cd4",
67
+ "date": "02/08/2023",
68
+ "time": "12:47:13",
69
+ "note": " that we need to exercise more"
70
+ },
71
+ {
72
+ "nid": "54887a03-9ebe-4868-bc8b-e3d6e49e877a",
73
+ "date": "02/08/2023",
74
+ "time": "13:46:33",
75
+ "note": " we need to bring sanah from school"
76
+ }
77
+ ]
78
+ }
executequery.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch.utils.data import Dataset,DataLoader
3
+ import torch.nn as nn
4
+ import nltk
5
+ from nltk.stem.porter import PorterStemmer
6
+ import json
7
+ import numpy as np
8
+ import random
9
+
10
+ nltk.download('punkt')
11
+
12
+ def ExecuteQuery(query):
13
+
14
+ class NeuralNet(nn.Module):
15
+
16
+ def __init__(self,input_size,hidden_size,num_classes):
17
+ super(NeuralNet,self).__init__()
18
+ self.l1 = nn.Linear(input_size,hidden_size)
19
+ self.l2 = nn.Linear(hidden_size,hidden_size)
20
+ self.l3 = nn.Linear(hidden_size,num_classes)
21
+ self.relu = nn.ReLU()
22
+
23
+ def forward(self,x):
24
+ out = self.l1(x)
25
+ out = self.relu(out)
26
+ out = self.l2(out)
27
+ out = self.relu(out)
28
+ out = self.l3(out)
29
+ return out
30
+
31
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
32
+
33
+ with open('intents.json', 'r') as json_data:
34
+ intents = json.load(json_data)
35
+
36
+ FILE = "intents.pth"
37
+ data = torch.load(FILE)
38
+ # with open('Data/Tasks.pth') as f:
39
+ # data = torch.load(f)
40
+
41
+
42
+ input_size = data["input_size"]
43
+ hidden_size = data["hidden_size"]
44
+ output_size = data["output_size"]
45
+ all_words = data["all_words"]
46
+ tags = data["tags"]
47
+ model_state = data["model_state"]
48
+
49
+ model = NeuralNet(input_size,hidden_size,output_size).to(device)
50
+ model.load_state_dict(model_state)
51
+ model.eval()
52
+
53
+ Stemmer = PorterStemmer()
54
+
55
+ def tokenize(sentence):
56
+ return nltk.word_tokenize(sentence)
57
+
58
+ def stem(word):
59
+ return Stemmer.stem(word.lower())
60
+
61
+ def bag_of_words(tokenized_sentence,words):
62
+ sentence_word = [stem(word) for word in tokenized_sentence]
63
+ bag = np.zeros(len(words),dtype=np.float32)
64
+
65
+ for idx , w in enumerate(words):
66
+ if w in sentence_word:
67
+ bag[idx] = 1
68
+
69
+ return bag
70
+
71
+ sentence = str(query)
72
+
73
+ sentence = tokenize(sentence)
74
+ X = bag_of_words(sentence,all_words)
75
+ X = X.reshape(1,X.shape[0])
76
+ X = torch.from_numpy(X).to(device)
77
+
78
+ output = model(X)
79
+
80
+ _ , predicted = torch.max(output,dim=1)
81
+
82
+ tag = tags[predicted.item()]
83
+
84
+ probs = torch.softmax(output,dim=1)
85
+ prob = probs[0][predicted.item()]
86
+
87
+ if prob.item() >= 0.96:
88
+
89
+ for intent in intents['intents']:
90
+
91
+ if tag == intent["tag"]:
92
+
93
+ reply = random.choice(intent["responses"])
94
+
95
+ return reply, tag, prob.item()
96
+ if prob.item() <= 0.95:
97
+ reply = "opencosmo"
98
+ tag = "opencosmo"
99
+ return reply, tag, prob.item()
100
+
101
+
102
+
103
+ # def test():
104
+ # query = input("Enter your query: ")
105
+ # reply = ExecuteQuery(query)
106
+ # print(f"Cosmo: {reply[0]}" )
107
+ # print(f"Tag: {reply[1]}")
108
+ # print(f"Prob: {reply[2]}")
109
+
110
+
111
+
112
+ # while True:
113
+ # test()
getvalues.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ # from listen import *
3
+
4
+ # find time in the string input provided by the user
5
+ def findTime(input):
6
+ # time = re.search(r'\d{1,2}:\d{2}', input)
7
+ # meridiem = re.search(r'\b(am|pm)\b', input)
8
+ # if time:
9
+ # tvalue = f"{time.group()} {meridiem.group()}"
10
+ # return tvalue
11
+ # else:
12
+ # return "notime"
13
+ time_regex1 = r"(1[0-2]|[1-9]):[0-5][0-9] (am|AM|PM|pm)"
14
+ time_search = re.search(time_regex1, input)
15
+ if time_search:
16
+ time = time_search.group(0)
17
+ # meridian = time_search.group(2)
18
+ return time
19
+ else:
20
+ time_regex2 = r"(1[0-2]|[1-9])\s?(am|AM|pm|PM)"
21
+ time_search = re.search(time_regex2, input)
22
+ if time_search:
23
+ time = time_search.group(0)
24
+ # meridian = time_search.group(2)
25
+ return time
26
+ else:
27
+ return "notime"
28
+
29
+ # find number in the string input provided by the user
30
+ def findNumber(input):
31
+ number = re.search(r'\d+', input)
32
+ if number:
33
+ return number.group()
34
+ else:
35
+ return "nonum"
36
+
37
+ # # find date in the string input provided by the user
38
+ def findDate(input):
39
+ date = re.search(r'\d{1,2}/\d{1,2}/\d{4}', input)
40
+ if date:
41
+ return date.group()
42
+ else:
43
+ return "nodate"
44
+
45
+ # find month in the string input provided by the user
46
+ def findMonth(input):
47
+ month = re.search(r'\b(january|february|march|april|may|june|july|august|september|october|november|december|next month)\b', input)
48
+ if month:
49
+ return month.group()
50
+ else:
51
+ return "nomonth"
52
+
53
+ # find day in the string input provided by the user
54
+ def findDay(input):
55
+ day = re.search(r'\b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|day after tomorrow|this week|next week|today)\b', input)
56
+ if day:
57
+ return day.group()
58
+ else:
59
+ return "noday"
60
+
61
+ def findrepeat(input):
62
+ repeat = re.search(r'\b(daily|everyday|every week|every month|every sunday|every monday|every tuesday|every wednesday|every thursday|every friday|every saturday)\b', input)
63
+ if repeat:
64
+ return repeat.group()
65
+ else:
66
+ return "norepeat"
67
+
68
+
69
+ def getValues(query):
70
+ time = findTime(query)
71
+ num = findNumber(query)
72
+ reps = findrepeat(query)
73
+ date = findDate(query)
74
+ month = findMonth(query)
75
+ day = findDay(query)
76
+ message = query.lower().replace(time, "").replace(day, "").replace(reps, "").replace("create a reminder", "").replace("remind me to", "").replace("cosmo", ""). replace("remind", "")
77
+ return message, time, day, date, reps, num, month
78
+
79
+ # query = "remind me to work on my portfolio at 5:00 pm tomorrow"
80
+ # print(getValues(query))
81
+
82
+ # query = input("Enter your query : ")
83
+ # # time = findTime(query)
84
+ # # date = findDate(query)
85
+ # # day = findDay(query)
86
+ # # if day == "noday":
87
+ # # print("No day")
88
+ # # elif time == "notime":
89
+ # # print("Time not found")
90
+ # # else:
91
+ # # print("Time found")
92
+
93
+
94
+ # # query = MicExecution()
95
+ # print(findDay(query))
intents.json ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "intents": [
3
+ {
4
+ "tag": "view_commands",
5
+ "patterns": [
6
+ "view commands",
7
+ "show commands",
8
+ "show me commands",
9
+ "view all commands",
10
+ "show all commands"
11
+ ],
12
+ "responses": [
13
+ "Here is the list of commands you can use:\n1. View Commands\n2. Create a reminder/Remind me\n3. Create/Add a todo\n4. Create a note/Remember\n5. Create a goal\n6. Show my routine for today\n7. Show my routine for tomorrow\n8. Show my todo list\n9. Show my notes\n10. Show my goals\n11. Show My Friends\n12. Meet New People\n13. Find groups\n13. Show my groups\n14. Find communities\n15. Show my communities\n16. Show new requests\n17. Recharge Coins"
14
+ ]
15
+ },
16
+ {
17
+ "tag": "greeting",
18
+ "patterns": [
19
+ "hello",
20
+ "hey",
21
+ "how are you",
22
+ "whats up",
23
+ "hi",
24
+ "hey cosmo",
25
+ "hi cosmo"
26
+ ],
27
+ "responses": [
28
+ "Hello",
29
+ "Hey, I Was Waiting For Your Presence.",
30
+ "Hey What's Up.",
31
+ "Hi, how can I help you?",
32
+ "Yo! wassup?"
33
+ ]
34
+ },
35
+ {
36
+ "tag": "goodbye",
37
+ "patterns": [
38
+ "bye",
39
+ "see you later",
40
+ "see you soon",
41
+ "goodbye"
42
+
43
+ ],
44
+ "responses": [
45
+ "See you later, thanks for visiting",
46
+ "Have a nice day",
47
+ "Bye! Come back again soon.",
48
+ "See you soon, I'll be waiting for you."
49
+ ]
50
+ },
51
+ {
52
+ "tag": "commands",
53
+ "patterns": [
54
+ "what do you do",
55
+ "what can you do",
56
+ "what can you do for me",
57
+ "what are your features",
58
+ "how are you different from other chatbot assistants"
59
+
60
+ ],
61
+ "responses": [
62
+ "I can help you with a variety of tasks, such as providing information, answering questions, helping you create routines, reminders, todos, notes and connect you with other like minded people, and much more. Say View Commands to see all the things I can do for you."
63
+
64
+ ]
65
+ },
66
+ {
67
+ "tag": "creator",
68
+ "patterns": [
69
+ "who created you",
70
+ "who made you",
71
+ "who is your creator",
72
+ "who is your father"
73
+
74
+ ],
75
+ "responses": [
76
+ "I am created by Emerging Technologies and Innovations team"
77
+ ]
78
+ },
79
+ {
80
+ "tag": "name",
81
+ "patterns": [
82
+ "whats your name",
83
+ "what is your name",
84
+ "what should I call you",
85
+ "what should I call you?",
86
+ "who are you",
87
+ "who are you?",
88
+ "who am I talking to",
89
+ "do I know you?"
90
+
91
+ ],
92
+ "responses": [
93
+ "My name is Cosmo, I am your personal assistant."
94
+ ]
95
+ },
96
+ {
97
+ "tag": "create_reminder",
98
+ "patterns": [
99
+ "remind me to",
100
+ "remind me at",
101
+ "remind me on",
102
+ "create a reminder",
103
+ "set a reminder",
104
+ "remind me"
105
+ ],
106
+ "responses": [
107
+ "I'll make sure to remind you that",
108
+ "I'll remember that",
109
+ "I'll remind you about that",
110
+ "No worries, I've written it on stone"
111
+ ]
112
+ },
113
+ {
114
+ "tag": "create_todo",
115
+ "patterns": [
116
+ "create a todo",
117
+ "set a todo",
118
+ "todo list",
119
+ "todo"
120
+ ],
121
+ "responses": [
122
+ "Todo created"
123
+ ]
124
+ },
125
+ {
126
+ "tag": "create_routine",
127
+ "patterns": [
128
+ "create a routine",
129
+ "set a routine",
130
+ "daily routine"
131
+ ],
132
+ "responses": [
133
+ "Your routine has been created",
134
+ "I'll help you to in following your routine",
135
+ "I'll make sure you follow your routine"
136
+ ]
137
+ },
138
+ {
139
+ "tag": "create_note",
140
+ "patterns": [
141
+ "make a note",
142
+ "note that",
143
+ "note down",
144
+ "jot down",
145
+ "remember",
146
+ "note",
147
+ "remember to",
148
+ "remember that",
149
+ "create a note"
150
+ ],
151
+ "responses": [
152
+ "I've Noted it down and will remember it for you",
153
+ "I'll remember that",
154
+ "Note saved! I'll remember that for you",
155
+ "I've saved that as a note"
156
+ ]
157
+ },
158
+ {
159
+ "tag": "show_note",
160
+ "patterns": [
161
+ "show my notes",
162
+ "show notes",
163
+ "what did i said to remember",
164
+ "what did i said to note",
165
+ "what do you remember about",
166
+ "what did i tell you about",
167
+ "remember i told you about",
168
+ "what did i tell you to remember",
169
+ "what did i tell you to note"
170
+ ],
171
+ "responses": [
172
+ "Here are your saved notes:"
173
+ ]
174
+ },
175
+ {
176
+ "tag": "create_goal",
177
+ "patterns": [
178
+ "create a goal",
179
+ "set a goal"
180
+ ],
181
+ "responses": [
182
+ "Your goal has been created",
183
+ "I'll help you to in following your goal",
184
+ "I'll make sure you follow your goal",
185
+ "I'll help you to achieve your goal",
186
+ "I'll make sure you achieve your goal"
187
+ ]
188
+ },
189
+ {
190
+ "tag": "show_routine_today",
191
+ "patterns": [
192
+ "show my routine",
193
+ "show my routine for today",
194
+ "show my routine for the day",
195
+ "show schedule for today",
196
+ "show schedule for the day",
197
+ "show my schedule for today",
198
+ "what's my routine for today",
199
+ "what's my routine for the day",
200
+ "what's my schedule for today",
201
+ "what's my schedule for the day"
202
+ ],
203
+ "responses": [
204
+ "Here's your routine for today",
205
+ "Here's your today's routine",
206
+ "Here's your routine for the day",
207
+ "Here it is",
208
+ "Here you go",
209
+ "Here's your routine",
210
+ "Here's your schedule for today",
211
+ "Here's your today's schedule",
212
+ "Here's your schedule for the day",
213
+ "Here's your schedule",
214
+ "Here's your today's schedule"
215
+ ]
216
+ },
217
+ {
218
+ "tag": "show_routine_tomorrow",
219
+ "patterns": [
220
+ "show my routine for tomorrow",
221
+ "show my schedule for tomorrow",
222
+ "what's my routine for tomorrow",
223
+ "what's my schedule for tomorrow",
224
+ "what's my routine for the next day",
225
+ "what's my schedule for the next day",
226
+ "show my routine for the next day",
227
+ "show my schedule for the next day"
228
+ ],
229
+ "responses": [
230
+ "Here's your routine for tomorrow",
231
+ "Here's your tomorrow's routine",
232
+ "Here it is",
233
+ "Here you go",
234
+ "Here's your routine",
235
+ "Here's your schedule for tomorrow",
236
+ "Here's your tomorrow's schedule",
237
+ "Here's your schedule"
238
+ ]
239
+ },
240
+ {
241
+ "tag": "new_requests",
242
+ "patterns": [
243
+ "do i have any new requests",
244
+ "are there any new requests"
245
+ ],
246
+ "responses": [
247
+ "Here are the requests you've recieved"
248
+ ]
249
+ },
250
+ {
251
+ "tag": "shared_reminders",
252
+ "patterns": [
253
+ "show my shared routines",
254
+ "show my shared reminders",
255
+ "show all shared reminders",
256
+ "show all shared routines",
257
+ "show reminders shared by me",
258
+ "show routines shared by me",
259
+ "show reminders shared with me",
260
+ "show routines shared with me"
261
+ ],
262
+ "responses": [
263
+ "Here are your shared reminders"
264
+ ]
265
+ },
266
+ {
267
+ "tag": "show_people",
268
+ "patterns": [
269
+ "show all people on this app",
270
+ "show all people",
271
+ "I want to make friends with people",
272
+ "I want to make friends",
273
+ "I want to make friends with people on this app",
274
+ "Find people on this app to make friends with",
275
+ "Find people to make friends with",
276
+ "show new users",
277
+ "show new users on this app",
278
+ "show new users on this app to make friends with",
279
+ "show users",
280
+ "show people"
281
+ ],
282
+ "responses": [
283
+ "Here are all the people on this app",
284
+ "Here are all the people",
285
+ "Here are all the users on this app",
286
+ "Here are all the users",
287
+ "Here are all the new users on this app",
288
+ "Here are all the new users",
289
+ "Here are all the new users on this app to make friends with",
290
+ "Here are all the new users to make friends with",
291
+ "Here are all the people on this app to make friends with",
292
+ "Here are all the people to make friends with"
293
+ ]
294
+ },
295
+ {
296
+ "tag": "show_friends",
297
+ "patterns": [
298
+ "show my friends",
299
+ "how many friends do I have",
300
+ "how many friends do I have on this app"
301
+ ],
302
+ "responses": [
303
+ "Here are all your friends",
304
+ "Here are all your friends on this app",
305
+ "Here are you buddies",
306
+ "Here's your gang",
307
+ "Here's your squad",
308
+ "Here's your crew"
309
+ ]
310
+ },
311
+ {
312
+ "tag": "show_allgroups",
313
+ "patterns": [
314
+ "how many groups are there",
315
+ "show all the groups",
316
+ "show all the groups on this app"
317
+ ],
318
+ "responses": [
319
+ "Here are all the groups on this app",
320
+ "Here are all the groups",
321
+ "Here are all the groups on this app to join",
322
+ "Here are all the groups to join"
323
+ ]
324
+ },
325
+ {
326
+ "tag": "show_mygroups",
327
+ "patterns": [
328
+ "show my groups",
329
+ "show my groups on this app",
330
+ "how many groups do I have",
331
+ "how many groups do I have on this app"
332
+ ],
333
+ "responses": [
334
+ "Here are all your groups",
335
+ "Here are all your groups on this app",
336
+ "Here are your groups",
337
+ "Here are the groups you've joined",
338
+ "Here are the groups you've joined on this app"
339
+ ]
340
+ },
341
+ {
342
+ "tag": "show_allcommunities",
343
+ "patterns": [
344
+ "show all communities",
345
+ "show all communities on this app",
346
+ "show all the communities",
347
+ "how many communities are there"
348
+ ],
349
+ "responses": [
350
+ "Here are all the communities on this app",
351
+ "Here are all the communities",
352
+ "Here are all the communities on this app to join",
353
+ "Here are all the communities to join"
354
+ ]
355
+ },
356
+ {
357
+ "tag": "show_mycommunities",
358
+ "patterns": [
359
+ "show my communities",
360
+ "show my communities on this app",
361
+ "how many communities do I have",
362
+ "how many communities do I have on this app"
363
+ ],
364
+ "responses": [
365
+ "Here are all your communities",
366
+ "Here are all your communities on this app",
367
+ "Here are your communities",
368
+ "Here are the communities you've joined",
369
+ "Here you go"
370
+ ]
371
+ }
372
+ ]
373
+ }
intents.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0c876f26d4d73f8e8d530351ef348f9445c8a435e645ee01b904e3fc4503ea2
3
+ size 7383
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ gradio
2
+ requests
3
+ bardapi
4
+ python-dotenv
5
+ torch
6
+ nltk
7
+ numpy