fix: optimize model selector

This commit is contained in:
alan.cl
2026-03-13 19:41:05 +08:00
parent 3bf9b9a95a
commit f4700b4439
3 changed files with 13 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ dependencies = [
"dbgpt-ext",
"dbgpt-serve",
"dbgpt-client",
"dbgpt-sandbox",
"aiofiles",
"httpx>=0.24.0",
"pyparsing",

View File

@@ -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>
))}

View File

@@ -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