gzdaniel commited on
Commit
059809e
·
1 Parent(s): cbddb5e

Improve query settings input experience in WebUI

Browse files
lightrag_webui/src/components/retrieval/QuerySettings.tsx CHANGED
@@ -2,7 +2,6 @@ import { useCallback } from 'react'
2
  import { QueryMode, QueryRequest } from '@/api/lightrag'
3
  // Removed unused import for Text component
4
  import Checkbox from '@/components/ui/Checkbox'
5
- import NumberInput from '@/components/ui/NumberInput'
6
  import Input from '@/components/ui/Input'
7
  import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/Card'
8
  import {
@@ -121,13 +120,23 @@ export default function QuerySettings() {
121
  </TooltipProvider>
122
  <div>
123
  {/* Removed sr-only label */}
124
- <NumberInput
125
  id="top_k"
126
- stepper={1}
127
- value={querySettings.top_k}
128
- onValueChange={(v) => handleChange('top_k', v)}
 
 
 
 
 
 
 
 
 
129
  min={1}
130
  placeholder={t('retrievePanel.querySettings.topKPlaceholder')}
 
131
  />
132
  </div>
133
  </>
@@ -149,13 +158,23 @@ export default function QuerySettings() {
149
  </TooltipProvider>
150
  <div>
151
  {/* Removed sr-only label */}
152
- <NumberInput
153
  id="max_token_for_text_unit"
154
- stepper={500}
155
- value={querySettings.max_token_for_text_unit}
156
- onValueChange={(v) => handleChange('max_token_for_text_unit', v)}
 
 
 
 
 
 
 
 
 
157
  min={1}
158
  placeholder={t('retrievePanel.querySettings.maxTokensTextUnit')}
 
159
  />
160
  </div>
161
  </>
@@ -175,13 +194,23 @@ export default function QuerySettings() {
175
  </TooltipProvider>
176
  <div>
177
  {/* Removed sr-only label */}
178
- <NumberInput
179
  id="max_token_for_global_context"
180
- stepper={500}
181
- value={querySettings.max_token_for_global_context}
182
- onValueChange={(v) => handleChange('max_token_for_global_context', v)}
 
 
 
 
 
 
 
 
 
183
  min={1}
184
  placeholder={t('retrievePanel.querySettings.maxTokensGlobalContext')}
 
185
  />
186
  </div>
187
  </>
@@ -201,13 +230,23 @@ export default function QuerySettings() {
201
  </TooltipProvider>
202
  <div>
203
  {/* Removed sr-only label */}
204
- <NumberInput
205
  id="max_token_for_local_context"
206
- stepper={500}
207
- value={querySettings.max_token_for_local_context}
208
- onValueChange={(v) => handleChange('max_token_for_local_context', v)}
 
 
 
 
 
 
 
 
 
209
  min={1}
210
  placeholder={t('retrievePanel.querySettings.maxTokensLocalContext')}
 
211
  />
212
  </div>
213
  </>
@@ -229,15 +268,23 @@ export default function QuerySettings() {
229
  </TooltipProvider>
230
  <div>
231
  {/* Removed sr-only label */}
232
- <NumberInput
233
- className="!border-input"
234
  id="history_turns"
235
- stepper={1}
236
- type="text"
237
- value={querySettings.history_turns}
238
- onValueChange={(v) => handleChange('history_turns', v)}
 
 
 
 
 
 
 
 
239
  min={0}
240
  placeholder={t('retrievePanel.querySettings.historyTurnsPlaceholder')}
 
241
  />
242
  </div>
243
  </>
 
2
  import { QueryMode, QueryRequest } from '@/api/lightrag'
3
  // Removed unused import for Text component
4
  import Checkbox from '@/components/ui/Checkbox'
 
5
  import Input from '@/components/ui/Input'
6
  import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/Card'
7
  import {
 
120
  </TooltipProvider>
121
  <div>
122
  {/* Removed sr-only label */}
123
+ <Input
124
  id="top_k"
125
+ type="number"
126
+ value={querySettings.top_k ?? ''}
127
+ onChange={(e) => {
128
+ const value = e.target.value
129
+ handleChange('top_k', value === '' ? '' : parseInt(value) || 0)
130
+ }}
131
+ onBlur={(e) => {
132
+ const value = e.target.value
133
+ if (value === '' || isNaN(parseInt(value))) {
134
+ handleChange('top_k', 1)
135
+ }
136
+ }}
137
  min={1}
138
  placeholder={t('retrievePanel.querySettings.topKPlaceholder')}
139
+ className="h-9"
140
  />
141
  </div>
142
  </>
 
158
  </TooltipProvider>
159
  <div>
160
  {/* Removed sr-only label */}
161
+ <Input
162
  id="max_token_for_text_unit"
163
+ type="number"
164
+ value={querySettings.max_token_for_text_unit ?? ''}
165
+ onChange={(e) => {
166
+ const value = e.target.value
167
+ handleChange('max_token_for_text_unit', value === '' ? '' : parseInt(value) || 0)
168
+ }}
169
+ onBlur={(e) => {
170
+ const value = e.target.value
171
+ if (value === '' || isNaN(parseInt(value))) {
172
+ handleChange('max_token_for_text_unit', 10000)
173
+ }
174
+ }}
175
  min={1}
176
  placeholder={t('retrievePanel.querySettings.maxTokensTextUnit')}
177
+ className="h-9"
178
  />
179
  </div>
180
  </>
 
194
  </TooltipProvider>
195
  <div>
196
  {/* Removed sr-only label */}
197
+ <Input
198
  id="max_token_for_global_context"
199
+ type="number"
200
+ value={querySettings.max_token_for_global_context ?? ''}
201
+ onChange={(e) => {
202
+ const value = e.target.value
203
+ handleChange('max_token_for_global_context', value === '' ? '' : parseInt(value) || 0)
204
+ }}
205
+ onBlur={(e) => {
206
+ const value = e.target.value
207
+ if (value === '' || isNaN(parseInt(value))) {
208
+ handleChange('max_token_for_global_context', 4000)
209
+ }
210
+ }}
211
  min={1}
212
  placeholder={t('retrievePanel.querySettings.maxTokensGlobalContext')}
213
+ className="h-9"
214
  />
215
  </div>
216
  </>
 
230
  </TooltipProvider>
231
  <div>
232
  {/* Removed sr-only label */}
233
+ <Input
234
  id="max_token_for_local_context"
235
+ type="number"
236
+ value={querySettings.max_token_for_local_context ?? ''}
237
+ onChange={(e) => {
238
+ const value = e.target.value
239
+ handleChange('max_token_for_local_context', value === '' ? '' : parseInt(value) || 0)
240
+ }}
241
+ onBlur={(e) => {
242
+ const value = e.target.value
243
+ if (value === '' || isNaN(parseInt(value))) {
244
+ handleChange('max_token_for_local_context', 4000)
245
+ }
246
+ }}
247
  min={1}
248
  placeholder={t('retrievePanel.querySettings.maxTokensLocalContext')}
249
+ className="h-9"
250
  />
251
  </div>
252
  </>
 
268
  </TooltipProvider>
269
  <div>
270
  {/* Removed sr-only label */}
271
+ <Input
 
272
  id="history_turns"
273
+ type="number"
274
+ value={querySettings.history_turns ?? ''}
275
+ onChange={(e) => {
276
+ const value = e.target.value
277
+ handleChange('history_turns', value === '' ? '' : parseInt(value) || 0)
278
+ }}
279
+ onBlur={(e) => {
280
+ const value = e.target.value
281
+ if (value === '' || isNaN(parseInt(value))) {
282
+ handleChange('history_turns', 0)
283
+ }
284
+ }}
285
  min={0}
286
  placeholder={t('retrievePanel.querySettings.historyTurnsPlaceholder')}
287
+ className="h-9"
288
  />
289
  </div>
290
  </>