mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-07-16 17:15:22 +00:00
fix: optimize model selector
This commit is contained in:
@@ -15,6 +15,7 @@ dependencies = [
|
||||
"dbgpt-ext",
|
||||
"dbgpt-serve",
|
||||
"dbgpt-client",
|
||||
"dbgpt-sandbox",
|
||||
"aiofiles",
|
||||
"httpx>=0.24.0",
|
||||
"pyparsing",
|
||||
|
||||
@@ -42,16 +42,17 @@ function ModelSelector({ onChange }: Props) {
|
||||
<Select
|
||||
value={model}
|
||||
placeholder={t('choose_model')}
|
||||
className='w-52'
|
||||
className='min-w-[120px]'
|
||||
popupMatchSelectWidth={false}
|
||||
onChange={val => {
|
||||
onChange?.(val);
|
||||
}}
|
||||
>
|
||||
{modelList.map(item => (
|
||||
<Select.Option key={item}>
|
||||
<Select.Option key={item} title={item}>
|
||||
<div className='flex items-center'>
|
||||
{renderModelIcon(item)}
|
||||
<span className='ml-2'>{MODEL_ICON_MAP[item]?.label || item}</span>
|
||||
<span className='ml-2'>{item}</span>
|
||||
</div>
|
||||
</Select.Option>
|
||||
))}
|
||||
|
||||
@@ -60,6 +60,14 @@ export const parseResourceValue = (value: any): any[] => {
|
||||
|
||||
try {
|
||||
// If the value is a string, try to parse it as JSON
|
||||
// Plain strings (e.g. knowledge space names like "知识库1") are not valid JSON,
|
||||
// skip JSON.parse to avoid noisy console errors
|
||||
if (typeof value === 'string') {
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed.startsWith('[') && !trimmed.startsWith('{')) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
let resourceData = typeof value === 'string' ? JSON.parse(value) : value;
|
||||
|
||||
// If resourceData is not an array but an object, convert it to array format
|
||||
|
||||
Reference in New Issue
Block a user