Files
hackaton-2025-web-backend/misc/conversations.py
2025-05-04 22:26:56 +03:00

34 lines
700 B
Python

from misc.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 {"conversation":CONVERSATIONS[self.id], "id":self.id}