mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 11:20:07 +08:00
feat(ocr): update provider config by merging with existing values
Use lodash merge to combine existing provider config with updates instead of overwriting
This commit is contained in:
parent
4ab6961fcc
commit
b67b4c8178
@ -11,6 +11,7 @@ import type {
|
||||
} from '@types'
|
||||
import { BuiltinOcrProviderIds } from '@types'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { merge } from 'lodash'
|
||||
|
||||
import type { OcrBaseService } from './builtin/OcrBaseService'
|
||||
import { ovOcrService } from './builtin/OvOcrService'
|
||||
@ -84,7 +85,18 @@ export class OcrService {
|
||||
if (providers.length == 0) {
|
||||
throw new Error(`OCR provider ${update.id} not found`)
|
||||
}
|
||||
return { data: providers[0] }
|
||||
const config = providers[0].config
|
||||
const newConfig = merge({}, config, update.config)
|
||||
const [updated] = await dbService
|
||||
.getDb()
|
||||
.update(ocrProviderTable)
|
||||
.set({
|
||||
name: update.name,
|
||||
config: newConfig
|
||||
})
|
||||
.where(eq(ocrProviderTable.id, update.id))
|
||||
.returning()
|
||||
return { data: updated }
|
||||
}
|
||||
|
||||
public async ocr(file: SupportedOcrFile, params: OcrParams): Promise<OcrResult> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user