File size: 420 Bytes
64fd9b7
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
# app/store.py
from collections import defaultdict
from typing import List, Dict

# in-memory chat tarixi (prod üçün Redis/Postgres məsləhətdir)
_history: Dict[str, List[dict]] = defaultdict(list)

def add_history(session_id: str, role: str, content: str):
    _history[session_id].append({"role": role, "content": content})

def get_history(session_id: str) -> List[dict]:
    return _history.get(session_id, [])