lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
40.75k stars 9.27k forks source link

[Bug] 对话后刷新网页,对话不会保留 #3864

Closed BiFangKNT closed 1 week ago

BiFangKNT commented 1 week ago

📦 部署环境

Docker

📌 软件版本

lobehub/lobe-chat-database:1.15.26

💻 系统环境

Other Linux

🌐 浏览器

Chrome

🐛 问题描述

对话完刷新网页,或者单纯是切换一下对话,对话内容都会消失

对话: image 切换一下对话: image image

各容器没有报错

docker-compose如下:

services:
  postgresql:
    image: pgvector/pgvector:pg16
    container_name: lobe-postgres
    ports:
      - '5454:5432'
    volumes:
      - './data:/var/lib/postgresql/data'
    environment:
      - 'POSTGRES_DB=lobe'
      - 'POSTGRES_PASSWORD=(占位符)'
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 5s
      timeout: 5s
      retries: 5
    restart: always

  minio:
    image: minio/minio
    container_name: lobe-minio
    ports:
      - '19000:9000'
      - '19001:9001'
    volumes:
      - './s3_data:/data'
    environment:
      - 'MINIO_ROOT_USER=(占位符)'
      - 'MINIO_ROOT_PASSWORD=(占位符)'
      - 'MINIO_DOMAIN=minio.(占位符)'
      - 'MINIO_API_CORS_ALLOW_ORIGIN=https://lobechat.(占位符)' # Your LobeChat's domain name.
    restart: always
    command: >
      server /data --address ":9000" --console-address ":9001"

  lobe:
    image: lobehub/lobe-chat-database
    container_name: lobe-database
    ports:
      - '3210:3210'
    volumes:
      - '/volume1/docker/lobechat/resolv.conf:/etc/resolv.conf'
    depends_on:
      - postgresql
      - minio
#      - logto
    env_file:
      - .env
    restart: always

volumes:
  data:
    driver: local
  s3_data:
    driver: local

.env如下:

# 必填,LobeChat 域名,用于 tRPC 调用
# 请保证此域名在你的 NextAuth 鉴权服务提供商、S3 服务商的 CORS 白名单中
APP_URL=https://lobechat.(占位符)/

# Postgres 相关,也即 DB 必需的环境变量
# 必填,用于加密敏感信息的密钥,可以使用 openssl rand -base64 32 生成
KEY_VAULTS_SECRET=(占位符)
# 必填,Postgres 数据库连接字符串,用于连接到数据库
# 格式:postgresql://username:password@host:port/dbname,如果你的 pg 实例为 Docker 容器且位于同一 docker-compose 文件中,亦可使用容器名作为 host
DATABASE_URL=postgresql://postgres:(占位符)@192.168.5.8:5454/lobe

# NEXT_AUTH 相关,也即鉴权服务必需的环境变量
# 可以使用 auth0、Azure AD、GitHub、Authentik、Zitadel、Logto 等,如有其他接入诉求欢迎提 PR
# 目前支持的鉴权服务提供商请参考:https://lobehub.com/zh/docs/self-hosting/advanced/auth#next-auth
# 如果你有 ACCESS_CODE,请务必清空,我们以 NEXT_AUTH 作为唯一鉴权来源
# 必填,用于 NextAuth 的密钥,可以使用 openssl rand -base64 32 生成
NEXT_AUTH_SECRET=(占位符)
# 必填,指定鉴权服务提供商,这里以 Logto 为例
NEXT_AUTH_SSO_PROVIDERS=cloudflare-zero-trust
# 必填,NextAuth 的 URL,用于 NextAuth 的回调
NEXTAUTH_URL=https://lobechat.(占位符)/api/auth

# NextAuth 鉴权服务提供商部分,以 Logto 为例
# 其他鉴权服务提供商所需的环境变量,请参考:https://lobehub.com/zh/docs/self-hosting/environment-variables/auth

CLOUDFLARE_ZERO_TRUST_CLIENT_ID=(占位符)
CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET=(占位符)
CLOUDFLARE_ZERO_TRUST_ISSUER=https://(占位符).cloudflareaccess.com/cdn-cgi/access/sso/oidc/(占位符)

# 代理相关,如果你需要的话(比如你使用 GitHub 作为鉴权服务提供商)
# HTTP_PROXY=http://localhost:7890
# HTTPS_PROXY=http://localhost:7890

# S3 相关,也即非结构化数据(文件、图片等)存储必需的环境变量
# 这里以 MinIO 为例
# 必填,S3 的 Access Key ID,对于 MinIO 来说,直到在 MinIO UI 中手动创建之前都是无效的
S3_ACCESS_KEY_ID=(占位符)
# 必填,S3 的 Secret Access Key,对于 MinIO 来说,直到在 MinIO UI 中手动创建之前都是无效的
S3_SECRET_ACCESS_KEY=(占位符)
# 必填,S3 的 Endpoint,用于服务端/客户端连接到 S3 API
S3_ENDPOINT=https://minio.(占位符)
# 必填,S3 的 Bucket,直到在 MinIO UI 中手动创建之前都是无效的
S3_BUCKET=lobe
# 必填,S3 的 Public Domain,用于客户端通过公开连接访问非结构化数据
S3_PUBLIC_DOMAIN=https://minio.(占位符)
# 选填,S3 的 Enable Path Style
# 对于主流 S3 Cloud 服务商,一般填 0 即可;对于自部署的 MinIO,请填 1
# 请参考:https://lobehub.com/zh/docs/self-hosting/advanced/s3#s-3-enable-path-style
S3_ENABLE_PATH_STYLE=1

# 其他基础环境变量,视需求而定。注意不要有 ACCESS_CODE
# 请参考:https://lobehub.com/zh/docs/self-hosting/environment-variables/basic
# 请注意,对于服务端版本,其 API 必须支持嵌入(即 OpenAI text-embedding-3-small)模型,否则无法对上传文件进行处理,但你无需在 OPENAI_MODEL_LIST 中指定此模型
OPENAI_API_KEY=(占位符)
OPENAI_PROXY_URL=https://api.chatanywhere.tech/v1
DEEPSEEK_API_KEY=(占位符)
ZHIPU_API_KEY=(占位符)
# OPENAI_MODEL_LIST=...

📷 复现步骤

如上所述

🚦 期望结果

正常保留对话

📝 补充信息

No response

lobehubbot commented 1 week ago

👀 @BiFangKNT

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.\ 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot commented 1 week ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


📦 Deployment environment

Docker

📌 Software version

lobehub/lobe-chat-database:1.15.26

💻 System environment

Other Linux

🌐 Browser

Chrome

🐛 Problem description

After refreshing the web page after the conversation, or simply switching the conversation, the conversation content will disappear.

dialogue: image Switch the conversation: image image

No errors are reported for each container

docker-compose is as follows:

services:
  postgresql:
    image: pgvector/pgvector:pg16
    container_name: lobe-postgres
    ports:
      - '5454:5432'
    volumes:
      - './data:/var/lib/postgresql/data'
    environment:
      - 'POSTGRES_DB=lobe'
      - 'POSTGRES_PASSWORD=(placeholder)'
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 5s
      timeout: 5s
      retries: 5
    restart: always

  minio:
    image: minio/minio
    container_name: lobe-minio
    ports:
      - '19000:9000'
      - '19001:9001'
    volumes:
      - './s3_data:/data'
    environment:
      - 'MINIO_ROOT_USER=(placeholder)'
      - 'MINIO_ROOT_PASSWORD=(placeholder)'
      - 'MINIO_DOMAIN=minio. (placeholder)'
      - 'MINIO_API_CORS_ALLOW_ORIGIN=https://lobechat. (placeholder)' # Your LobeChat's domain name.
    restart: always
    command: >
      server /data --address ":9000" --console-address ":9001"

  lobe:
    image: lobehub/lobe-chat-database
    container_name: lobe-database
    ports:
      - '3210:3210'
    volumes:
      - '/volume1/docker/lobechat/resolv.conf:/etc/resolv.conf'
    depends_on:
      -postgresql
      - minio
#-logto
    env_file:
      - .env
    restart: always

volumes:
  data:
    driver:local
  s3_data:
    driver: local

.env is as follows:

# Required, LobeChat domain name, used for tRPC calls
# Please ensure that this domain name is in the CORS whitelist of your NextAuth authentication service provider and S3 service provider
APP_URL=https://lobechat.(placeholder)/

# Postgres related, that is, DB necessary environment variables
# Required, the key used to encrypt sensitive information can be generated using openssl rand -base64 32
KEY_VAULTS_SECRET= (placeholder)
#Required, Postgres database connection string, used to connect to the database
# Format: postgresql://username:password@host:port/dbname, if your pg instance is a Docker container and is located in the same docker-compose file, you can also use the container name as host
DATABASE_URL=postgresql://postgres: (placeholder)@192.168.5.8:5454/lobe

# NEXT_AUTH related, that is, the environment variable necessary for the authentication service
# You can use auth0, Azure AD, GitHub, Authentik, Zitadel, Logto, etc. If you have other access requirements, please submit a PR.
# For currently supported authentication service providers, please refer to: https://lobehub.com/zh/docs/self-hosting/advanced/auth#next-auth
# If you have ACCESS_CODE, be sure to clear it. We use NEXT_AUTH as the only authentication source.
# Required, the key used for NextAuth can be generated using openssl rand -base64 32
NEXT_AUTH_SECRET= (placeholder)
# Required, specify the authentication service provider, take Logto as an example here
NEXT_AUTH_SSO_PROVIDERS=cloudflare-zero-trust
# Required, NextAuth URL, used for NextAuth callback
NEXTAUTH_URL=https://lobechat.(placeholder)/api/auth

# NextAuth authentication service provider part, taking Logto as an example
# For other environment variables required by authentication service providers, please refer to: https://lobehub.com/zh/docs/self-hosting/environment-variables/auth

CLOUDFLARE_ZERO_TRUST_CLIENT_ID= (placeholder)
CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET= (placeholder)
CLOUDFLARE_ZERO_TRUST_ISSUER=https://(placeholder).cloudflareaccess.com/cdn-cgi/access/sso/oidc/(placeholder)

# Proxy related, if you need it (for example, if you use GitHub as the authentication service provider)
# HTTP_PROXY=http://localhost:7890
# HTTPS_PROXY=http://localhost:7890

# S3 related, that is, environment variables necessary for storing unstructured data (files, pictures, etc.)
# Here we take MinIO as an example
# Required, the Access Key ID of S3 is invalid for MinIO until it is manually created in the MinIO UI
S3_ACCESS_KEY_ID= (placeholder)
# Required, the Secret Access Key of S3 is invalid for MinIO until it is manually created in the MinIO UI.
S3_SECRET_ACCESS_KEY= (placeholder)
# Required, S3 Endpoint, used for server/client to connect to S3 API
S3_ENDPOINT=https://minio. (placeholder)
# Required, S3 Bucket is invalid until manually created in MinIO UI
S3_BUCKET=lobe
# Required, Public Domain of S3, used for clients to access unstructured data through public connections
S3_PUBLIC_DOMAIN=https://minio. (placeholder)
# Optional, S3’s Enable Path Style
# For mainstream S3 Cloud service providers, generally fill in 0; for self-deployed MinIO, please fill in 1
# Please refer to: https://lobehub.com/zh/docs/self-hosting/advanced/s3#s-3-enable-path-style
S3_ENABLE_PATH_STYLE=1

# Other basic environment variables, depending on needs. Be careful not to have ACCESS_CODE
# Please refer to: https://lobehub.com/zh/docs/self-hosting/environment-variables/basic
# Please note that for the server version, its API must support the embedded (i.e. OpenAI text-embedding-3-small) model, otherwise the uploaded file cannot be processed, but you do not need to specify this model in OPENAI_MODEL_LIST
OPENAI_API_KEY= (placeholder)
OPENAI_PROXY_URL=https://api.chatanywhere.tech/v1
DEEPSEEK_API_KEY= (placeholder)
ZHIPU_API_KEY= (placeholder)
# OPENAI_MODEL_LIST=...

📷 Steps to reproduce

as mentioned above

🚦 Expected results

Keep conversation normally

📝 Supplementary information

No response

dosubot[bot] commented 1 week ago

I found some similar issues and discussions that might be relevant to your problem:

  1. [Bug] 服务器版设置,有时候保存不上 - This issue is open and was last updated on August 26, 2024 [1].
  2. [Bug] 配置丢失,设置、会话、插件、助手,全部数据丢失 - This issue is open and was last updated on August 13, 2024. The suggested solution is to ensure sufficient disk space and consider frequent backups [2].
  3. [Request] Chat history to be persisted across different browser sessions based on users - This issue is closed and was last updated on February 25, 2024 [3].

To ensure that conversations are retained after refreshing the webpage or switching chats in LobeChat, you can rely on the fact that all chat records are stored in your local browser. This means that redeploying LobeChat using Docker will not result in the loss of your chat records [4][5].

Additionally, LobeChat's integration with PostgreSQL and MinIO ensures the persistence and retrieval of chat data. PostgreSQL handles structured data like chat messages and user information, while MinIO manages unstructured data like file uploads and images. Both services are configured to store data in local volumes, ensuring persistence across container restarts [6][7][8].

Make sure your Docker and environment configurations are correctly set up to support these features. If the issue persists, you might want to check for any errors in the browser console or Docker logs that could provide more insights.

To continue talking to Dosu, mention @dosu.

lobehubbot commented 1 week ago

✅ @BiFangKNT

This issue is closed, If you have any questions, you can comment and reply.\ 此问题已经关闭。如果您有任何问题,可以留言并回复。

BiFangKNT commented 1 week ago

是我犯糊涂了,原来消息列表在右边,左边的是类似于面具的列表,切换左边的助手会新建对话,造成了一种对话消息不会保存的错觉🤣🤣

lobehubbot commented 1 week ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I was confused. It turns out that the message list is on the right, and the left is a list similar to a mask. Switching the assistant on the left will create a new conversation, which creates the illusion that the conversation messages will not be saved🤣🤣