File size: 547 Bytes
d09befd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import shelve
from langchain_google_genai import ChatGoogleGenerativeAI

def get_default_model():
    return "gemini-2.5-flash"

def get_googlegenai_client():
    return ChatGoogleGenerativeAI(model=get_default_model(), streaming=True)

def get_storage_path():
    return os.path.join("/tmp", "chat_history")

def load_chat_history():
    with shelve.open(get_storage_path()) as db:
        return db.get("messages", [])

def save_chat_history(messages):
    with shelve.open(get_storage_path()) as db:
        db["messages"] = messages