Adicionar app/chat_store.py
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
# All comments are in English.
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
class ChatStore:
|
||||||
|
"""Simple in-memory chat store with multiple conversations."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.conversations = {}
|
||||||
|
|
||||||
|
def new_conversation(self):
|
||||||
|
cid = str(uuid.uuid4())
|
||||||
|
self.conversations[cid] = []
|
||||||
|
return cid
|
||||||
|
|
||||||
|
def add_message(self, cid, role, content):
|
||||||
|
self.conversations[cid].append({"role": role, "content": content})
|
||||||
|
|
||||||
|
def get_messages(self, cid):
|
||||||
|
return self.conversations.get(cid, [])
|
||||||
Reference in New Issue
Block a user