2025-05-04 22:26:56 +03:00
|
|
|
from misc.random_string import generate_secure_string
|
2025-05-04 16:30:07 +03:00
|
|
|
|
|
|
|
|
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}
|
2025-05-04 22:26:56 +03:00
|
|
|
return {"conversation":CONVERSATIONS[self.id], "id":self.id}
|
2025-05-04 16:30:07 +03:00
|
|
|
|