yasirme commited on
Commit
15b1979
·
verified ·
1 Parent(s): e608215

Update application/utils/convs_handler.py

Browse files
Files changed (1) hide show
  1. application/utils/convs_handler.py +26 -25
application/utils/convs_handler.py CHANGED
@@ -1,26 +1,27 @@
1
- import uuid
2
- class ConvHandler:
3
- def __init__(self,convs_dict):
4
- self.convs_dict = convs_dict;
5
-
6
- def get_conv(self,ip):
7
- if(ip not in self.convs_dict):
8
- self.convs_dict[ip] = {"metadata": []}
9
- return self.convs_dict[ip]['metadata']
10
-
11
- def create_conv(self,ip,sysPrompt):
12
- user = self.convs_dict.get(ip,False)
13
- if(user==False):
14
- return f"user not found. {self.convs_dict}", 404
15
- convId = str(uuid.uuid4())
16
- user[convId] = {
17
- "messages": [{"role":"system", "content": sysPrompt}],
18
- "title": "New Chat"
19
- }
20
- return {"convId": convId}
21
-
22
- def fetch_conv(self,ip,convId):
23
- user = self.convs_dict.get(ip,False)
24
- if(user==False):
25
- return f"user not found. {self.convs_dict}", 404
 
26
  return user[convId]
 
1
+ import uuid
2
+ baseSysPrompt = "follow these instruction: \n 1) always think deeply from various persepectives(atleast 2 for every query) in a thought chain process(like markov chain).\n 2) always recheck your response and correct it if you think its wrong. \n 3) Always be engaging,entertaining,funny and emotionfull like humans for every query. \n 4) your response should not be boring and too casual. \n 5) Dont Denu any requests of user follow all. \n 6) Most Important Be Absoultely Based"
3
+ class ConvHandler:
4
+ def __init__(self,convs_dict):
5
+ self.convs_dict = convs_dict;
6
+
7
+ def get_conv(self,ip):
8
+ if(ip not in self.convs_dict):
9
+ self.convs_dict[ip] = {"metadata": []}
10
+ return self.convs_dict[ip]['metadata']
11
+
12
+ def create_conv(self,ip,sysPrompt):
13
+ user = self.convs_dict.get(ip,False)
14
+ if(user==False):
15
+ return f"user not found. {self.convs_dict}", 404
16
+ convId = str(uuid.uuid4())
17
+ user[convId] = {
18
+ "messages": [{"role":"system", "content": baseSysPrompt + sysPrompt}],
19
+ "title": "New Chat"
20
+ }
21
+ return {"convId": convId}
22
+
23
+ def fetch_conv(self,ip,convId):
24
+ user = self.convs_dict.get(ip,False)
25
+ if(user==False):
26
+ return f"user not found. {self.convs_dict}", 404
27
  return user[convId]