my-ChatGPT-clone / chatbot.py
Keyurjotaniya007's picture
Upload 3 files
d09befd verified
raw
history blame
547 Bytes
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