Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created bots and chat histories are not persisent #260

Open
weipienlee opened this issue Mar 30, 2024 · 3 comments
Open

created bots and chat histories are not persisent #260

weipienlee opened this issue Mar 30, 2024 · 3 comments

Comments

@weipienlee
Copy link

weipienlee commented Mar 30, 2024

All saved bots and chats disappear at some point with both the older redis and current prostgres docker versions.

Latest situation:

  • postgres-volume directory has been created
  • during browser refresh or new tab everything “seems” to persist, but all gone with browser restart
  • restart containers and browser not seems to persist everything

PS: used undocumented POSTGRES_PORT=5432, POSTGRES_DB=opengpts, POSTGRES_USER=postgres, POSTGRES_PASSWORD=postgres

PSS: running with docker on Apple silicon

@weipienlee
Copy link
Author

weipienlee commented Mar 31, 2024

found the problems:

  1. variable name mismatch: should all be opengpts_user_id (see below)
  2. expiration is apparently by default a session
if (document.cookie.indexOf("user_id") === -1) {
  document.cookie = `opengpts_user_id=${uuidv4()}`;
}

temporary solution - moving expiration date; will expire after month of no use:

const daysUntilExpiration = 30; // Number of days until cookie expiration

// Check if cookie exists
if (!document.cookie.includes("opengpts_user_id")) {
  const expires = new Date(Date.now() + daysUntilExpiration * 24 * 60 * 60 * 1000).toUTCString(); // Set initial expiration date
  document.cookie = `opengpts_user_id=${uuidv4()}; expires=${expires}; path=/`;
} else {
  const cookieParts = document.cookie.split('; ').find(cookie => cookie.startsWith("opengpts_user_id="));
  if (cookieParts) {
    const existingCookie = cookieParts.split('=');
    const userId = existingCookie[1];
    const expires = new Date(Date.now() + daysUntilExpiration * 24 * 60 * 60 * 1000).toUTCString(); // Reset expiration date
    document.cookie = `opengpts_user_id=${userId}; expires=${expires}; path=/`;
  }
}

@minovc3
Copy link

minovc3 commented Apr 4, 2024

Same here, all saved bots and chats disappear at some point. Persistence is required! Thank you!

@mkorpela
Copy link
Collaborator

mkorpela commented Apr 5, 2024

Hi @weipienlee and @minovc3 ,
Thanks for the feedback. Current user authentication mechanism is a bit weak. We are working on improving the situation. That should also make the bots and chats persistent work reliably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants