-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContextEntry.py
43 lines (30 loc) · 889 Bytes
/
ContextEntry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import datetime
import uuid
class ContextEntry(object):
def __init__(self, role, content, roleName, context, id=""):
self.role = role
self.content = content
self.tokens = None
self.tokensSize = 0
if(role != "ignore"):
context.calcTokenCount(self)
if(role == "user"):
roleName = context.userName
self.roleName = roleName
self.created = str(datetime.datetime.now())
if(not id):
id =f"{role}-{uuid.uuid4()}"
self.id = id
self.previous = None
self.next = None
self.commitedProcesses = []
def CommitProcess(self, processName):
self.commitedProcesses.append(processName)
def GetDictionary(self):
return {
"role": self.role,
"content": self.content,
"id": self.id,
}
def __str__(self) -> str:
return str(self.GetDictionary())