first commit
This commit is contained in:
BIN
misc/__pycache__/random_string.cpython-312.pyc
Normal file
BIN
misc/__pycache__/random_string.cpython-312.pyc
Normal file
Binary file not shown.
33
misc/conversations.py
Normal file
33
misc/conversations.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from random_string import generate_secure_string
|
||||
|
||||
CONVERSATIONS = {}
|
||||
"""
|
||||
{
|
||||
messages:
|
||||
[{
|
||||
role:str,
|
||||
content:str,
|
||||
id:int
|
||||
}],
|
||||
last_message_id: int,
|
||||
workspace: str,
|
||||
user_name: str,
|
||||
problem_type: int
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
class Conversations:
|
||||
def __init__(self):
|
||||
self.id = ""
|
||||
|
||||
def create(self,user_message,workspace,user_name,problem_type):
|
||||
self.id = generate_secure_string(40)
|
||||
CONVERSATIONS[self.id] = {
|
||||
"messages":[],
|
||||
"last_message_id":0,
|
||||
"workspace":workspace,
|
||||
"user_name":user_name,
|
||||
"problem_type":problem_type}
|
||||
return CONVERSATIONS[self.id]
|
||||
|
||||
10
misc/random_string.py
Normal file
10
misc/random_string.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import secrets
|
||||
import string
|
||||
|
||||
def generate_secure_string(length):
|
||||
if length <= 0:
|
||||
return ""
|
||||
|
||||
characters = string.ascii_letters + string.digits
|
||||
return ''.join(secrets.choice(characters) for _ in range(length))
|
||||
|
||||
Reference in New Issue
Block a user