@@ -12,33 +12,38 @@ import {
12
12
Input ,
13
13
InputNumber ,
14
14
Modal ,
15
+ Select ,
15
16
Skeleton ,
16
17
Switch
17
18
} from "antd"
18
19
import React , { useCallback } from "react"
19
20
import { useTranslation } from "react-i18next"
20
21
import { SaveButton } from "../SaveButton"
22
+ import { getOCRLanguage } from "@/services/ocr"
23
+ import { ocrLanguages } from "@/data/ocr-language"
21
24
22
25
type Props = {
23
26
open : boolean
24
27
setOpen : ( open : boolean ) => void
25
28
useDrawer ?: boolean
29
+ isOCREnabled ?: boolean
26
30
}
27
31
28
32
export const CurrentChatModelSettings = ( {
29
33
open,
30
34
setOpen,
31
- useDrawer
35
+ useDrawer,
36
+ isOCREnabled
32
37
} : Props ) => {
33
38
const { t } = useTranslation ( "common" )
34
39
const [ form ] = Form . useForm ( )
35
40
const cUserSettings = useStoreChatModelSettings ( )
36
- const {
37
- selectedSystemPrompt,
38
- uploadedFiles,
39
- removeUploadedFile,
41
+ const {
42
+ selectedSystemPrompt,
43
+ uploadedFiles,
44
+ removeUploadedFile,
40
45
fileRetrievalEnabled,
41
- setFileRetrievalEnabled
46
+ setFileRetrievalEnabled
42
47
} = useMessageOption ( )
43
48
44
49
const savePrompt = useCallback (
@@ -51,7 +56,7 @@ export const CurrentChatModelSettings = ({
51
56
const saveSettings = useCallback (
52
57
( values : any ) => {
53
58
Object . entries ( values ) . forEach ( ( [ key , value ] ) => {
54
- if ( key !== "systemPrompt" ) {
59
+ if ( key !== "systemPrompt" && key !== "ocrLanguage" ) {
55
60
cUserSettings . setX ( key , value )
56
61
}
57
62
} )
@@ -64,6 +69,11 @@ export const CurrentChatModelSettings = ({
64
69
queryFn : async ( ) => {
65
70
const data = await getAllModelSettings ( )
66
71
72
+ const ocrLang = await getOCRLanguage ( )
73
+
74
+ if ( isOCREnabled ) {
75
+ cUserSettings . setOcrLanguage ( ocrLang )
76
+ }
67
77
let tempSystemPrompt = ""
68
78
69
79
// i hate this method but i need this feature so badly that i need to do this
@@ -128,6 +138,33 @@ export const CurrentChatModelSettings = ({
128
138
< Divider />
129
139
</ >
130
140
) }
141
+
142
+ { isOCREnabled && (
143
+ < div className = "flex flex-col space-y-2 mb-3" >
144
+ < span className = "text-gray-700 dark:text-neutral-50" >
145
+ OCR Language
146
+ </ span >
147
+
148
+ < Select
149
+ showSearch
150
+ style = { { width : "100%" } }
151
+ options = { ocrLanguages }
152
+ value = { cUserSettings . ocrLanguage }
153
+ filterOption = { ( input , option ) =>
154
+ option ! . label . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) >=
155
+ 0 ||
156
+ option ! . value . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) >=
157
+ 0
158
+ }
159
+ onChange = { ( value ) => {
160
+ cUserSettings . setOcrLanguage ( value )
161
+ } }
162
+ />
163
+ < Divider />
164
+
165
+ </ div >
166
+ ) }
167
+
131
168
< Form . Item
132
169
name = "keepAlive"
133
170
help = { t ( "modelSettings.form.keepAlive.help" ) }
@@ -214,10 +251,16 @@ export const CurrentChatModelSettings = ({
214
251
< span > { ( file . size / 1024 ) . toFixed ( 1 ) } KB</ span >
215
252
{ fileRetrievalEnabled && (
216
253
< span className = "flex items-center gap-1" >
217
- < span className = { `inline-block w-2 h-2 rounded-full ${
218
- file . processed ? 'bg-green-500' : 'bg-yellow-500'
219
- } `} />
220
- { file . processed ? 'Processed' : 'Processing...' }
254
+ < span
255
+ className = { `inline-block w-2 h-2 rounded-full ${
256
+ file . processed
257
+ ? "bg-green-500"
258
+ : "bg-yellow-500"
259
+ } `}
260
+ />
261
+ { file . processed
262
+ ? "Processed"
263
+ : "Processing..." }
221
264
</ span >
222
265
) }
223
266
</ div >
0 commit comments