-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
🐛 fix(db): desktop local db can't vectorization #8830
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
Conversation
Fixed ChunkService constructor to properly receive serverDB parameter, which is required for desktop file vectorization functionality. Fixes #8826
- Fixed 4 RAG evaluation models to accept LobeChatDatabase parameter - Updated UserService and NextAuthUserService constructors - Fixed all instantiation sites across routes and tests - Eliminates hardcoded serverDB imports for better testability Resolves desktop file vectorization issues by ensuring proper database instance management across all model/service layers. Fixes #8826
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideThis PR refactors core models and services to inject the database instance via constructor parameters instead of relying on hardcoded serverDB imports, and updates all instantiation sites and tests to pass the LobeChatDatabase parameter for improved dependency management and testability. Sequence diagram for model/service instantiation with injected databasesequenceDiagram
participant Route
participant DB as LobeChatDatabase
participant UserService
participant EvalDatasetModel
Route->>DB: Obtain database instance
Route->>UserService: new UserService(DB)
Route->>EvalDatasetModel: new EvalDatasetModel(DB, userId)
UserService->>DB: Use DB for operations
EvalDatasetModel->>DB: Use DB for operations
Class diagram for updated RAG evaluation models and servicesclassDiagram
class EvalDatasetModel {
- db: LobeChatDatabase
- userId: string
+ constructor(db: LobeChatDatabase, userId: string)
+ create(params: NewEvalDatasetsItem)
+ delete(id: number)
+ query(knowledgeBaseId: string): Promise<RAGEvalDataSetItem[]>
+ findById(id: number)
+ update(id: number, value: Partial<NewEvalDatasetsItem>)
}
class EvalDatasetRecordModel {
- db: LobeChatDatabase
- userId: string
+ constructor(db: LobeChatDatabase, userId: string)
+ create(params: NewEvalDatasetRecordsItem)
+ batchCreate(params: NewEvalDatasetRecordsItem[])
+ delete(id: number)
+ query(datasetId: number)
+ findByDatasetId(datasetId: number)
+ findById(id: number)
+ update(id: number, value: Partial<NewEvalDatasetRecordsItem>)
}
class EvalEvaluationModel {
- db: LobeChatDatabase
- userId: string
+ constructor(db: LobeChatDatabase, userId: string)
+ create(params: NewEvalEvaluationItem)
+ delete(id: number)
+ queryByKnowledgeBaseId(knowledgeBaseId: string)
+ findById(id: number)
+ update(id: number, value: Partial<NewEvalEvaluationItem>)
}
class EvaluationRecordModel {
- db: LobeChatDatabase
- userId: string
+ constructor(db: LobeChatDatabase, userId: string)
+ create(params: NewEvaluationRecordsItem)
+ batchCreate(params: NewEvaluationRecordsItem[])
+ delete(id: number)
+ query(reportId: number)
+ findById(id: number)
+ findByEvaluationId(evaluationId: number)
+ update(id: number, value: Partial<NewEvaluationRecordsItem>)
}
class UserService {
- db: LobeChatDatabase
+ constructor(db: LobeChatDatabase)
+ createUser(id: string, params: UserJSON)
+ deleteUser(id: string)
+ updateUser(id: string, params: UserJSON)
+ getUserApiKeys(id: string)
+ getUserAvatar(id: string, image: string)
}
class NextAuthUserService {
- db: LobeChatDatabase
- adapter
+ constructor(db: LobeChatDatabase)
+ safeUpdateUser(user: UserItem, provider: string)
}
class ChunkService {
- userId: string
+ constructor(db: LobeChatDatabase, userId: string)
...
}
LobeChatDatabase <|-- EvalDatasetModel
LobeChatDatabase <|-- EvalDatasetRecordModel
LobeChatDatabase <|-- EvalEvaluationModel
LobeChatDatabase <|-- EvaluationRecordModel
LobeChatDatabase <|-- UserService
LobeChatDatabase <|-- NextAuthUserService
LobeChatDatabase <|-- ChunkService
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There is too much information in the pull request to test. |
👍 @tjx666 Thank you for raising your pull request and contributing to our Community |
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- ChunkService now takes a db parameter but doesn’t assign it to a member or use it internally—ensure you store it (e.g. this.db = db) and update all internal calls to use the injected instance.
- Double‐check that you’ve added the
import { serverDB } from '@/database/server'
in every file where you passserverDB
to constructors to avoid missing import/runtime errors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- ChunkService now takes a db parameter but doesn’t assign it to a member or use it internally—ensure you store it (e.g. this.db = db) and update all internal calls to use the injected instance.
- Double‐check that you’ve added the `import { serverDB } from '@/database/server'` in every file where you pass `serverDB` to constructors to avoid missing import/runtime errors.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
❤️ Great PR @tjx666 ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
### [Version 1.113.1](v1.113.0...v1.113.1) <sup>Released on **2025-08-17**</sup> #### 🐛 Bug Fixes - **db**: Desktop local db can't vectorization. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **db**: Desktop local db can't vectorization, closes [#8830](#8830) ([a00fd9d](a00fd9d)) </details> <div align="right"> [](#readme-top) </div>
🎉 This PR is included in version 1.113.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [Version 1.113.0](v1.112.0...v1.113.0) <sup>Released on **2025-08-18**</sup> #### ♻ Code Refactoring - **misc**: Refactor const folder to a new package, refactor prompts folder to the `@lobechat/prompts` pacakge, 重构ArgsInput组件. #### ✨ Features - **provider**: Add BFL provider support for image generation. #### 🐛 Bug Fixes - **db**: Desktop local db can't vectorization. - **misc**: Improve mcp tracing with user config. #### 💄 Styles - **misc**: Add Imagen 4 GA models, style improve auth sign in box loading. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Refactor const folder to a new package, closes [lobehub#8756](https://github.com/jaworldwideorg/OneJA-Bot/issues/8756) ([30a4734](30a4734)) * **misc**: Refactor prompts folder to the `@lobechat/prompts` pacakge, closes [lobehub#8810](https://github.com/jaworldwideorg/OneJA-Bot/issues/8810) ([d82e7bb](d82e7bb)) * **misc**: 重构 ArgsInput 组件, closes [lobehub#8765](https://github.com/jaworldwideorg/OneJA-Bot/issues/8765) ([0905559](0905559)) #### What's improved * **provider**: Add BFL provider support for image generation, closes [lobehub#8806](https://github.com/jaworldwideorg/OneJA-Bot/issues/8806) ([519e03e](519e03e)) #### What's fixed * **db**: Desktop local db can't vectorization, closes [lobehub#8830](https://github.com/jaworldwideorg/OneJA-Bot/issues/8830) ([a00fd9d](a00fd9d)) * **misc**: Improve mcp tracing with user config, closes [lobehub#8827](https://github.com/jaworldwideorg/OneJA-Bot/issues/8827) ([5cab2ee](5cab2ee)) #### Styles * **misc**: Add Imagen 4 GA models, closes [lobehub#8799](https://github.com/jaworldwideorg/OneJA-Bot/issues/8799) ([2e9ad20](2e9ad20)) * **misc**: Style improve auth sign in box loading, closes [lobehub#8805](https://github.com/jaworldwideorg/OneJA-Bot/issues/8805) ([62f5a1b](62f5a1b)) </details> <div align="right"> [](#readme-top) </div>
@claude 这个改了哪些代码呢 |
@claude What codes did this change? |
Claude encountered an error —— View job I'll analyze this and get back to you. |
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
修复桌面版文件向量化失败问题,将所有 Model 和 Service 从硬编码
serverDB
导入改为接受数据库实例作为构造函数参数。主要变更:
EvalDatasetModel
,EvalDatasetRecordModel
,EvalEvaluationModel
,EvaluationRecordModel
UserService
和NextAuthUserService
构造函数serverDB
导入,改善依赖注入模式技术细节:
(db: LobeChatDatabase, userId: string)
参数📝 补充信息 | Additional Information
解决问题:修复 issue #8826 - 桌面版无法向量化的问题
测试状态:
影响范围: