Merge remote-tracking branch 'origin/alpha' into alpha
This commit is contained in:
@@ -132,6 +132,7 @@ const EditChannelModal = (props) => {
|
||||
pass_through_body_enabled: false,
|
||||
system_prompt: '',
|
||||
system_prompt_override: false,
|
||||
settings: '',
|
||||
};
|
||||
const [batch, setBatch] = useState(false);
|
||||
const [multiToSingle, setMultiToSingle] = useState(false);
|
||||
@@ -187,38 +188,31 @@ const EditChannelModal = (props) => {
|
||||
handleInputChange('setting', settingsJson);
|
||||
};
|
||||
|
||||
// 解析渠道设置JSON为单独的状态
|
||||
const parseChannelSettings = (settingJson) => {
|
||||
try {
|
||||
if (settingJson && settingJson.trim()) {
|
||||
const parsed = JSON.parse(settingJson);
|
||||
setChannelSettings({
|
||||
force_format: parsed.force_format || false,
|
||||
thinking_to_content: parsed.thinking_to_content || false,
|
||||
proxy: parsed.proxy || '',
|
||||
pass_through_body_enabled: parsed.pass_through_body_enabled || false,
|
||||
system_prompt: parsed.system_prompt || '',
|
||||
});
|
||||
} else {
|
||||
setChannelSettings({
|
||||
force_format: false,
|
||||
thinking_to_content: false,
|
||||
proxy: '',
|
||||
pass_through_body_enabled: false,
|
||||
system_prompt: '',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('解析渠道设置失败:', error);
|
||||
setChannelSettings({
|
||||
force_format: false,
|
||||
thinking_to_content: false,
|
||||
proxy: '',
|
||||
pass_through_body_enabled: false,
|
||||
system_prompt: '',
|
||||
});
|
||||
const handleChannelOtherSettingsChange = (key, value) => {
|
||||
// 更新内部状态
|
||||
setChannelSettings(prev => ({ ...prev, [key]: value }));
|
||||
|
||||
// 同步更新到表单字段
|
||||
if (formApiRef.current) {
|
||||
formApiRef.current.setValue(key, value);
|
||||
}
|
||||
};
|
||||
|
||||
// 同步更新inputs状态
|
||||
setInputs(prev => ({ ...prev, [key]: value }));
|
||||
|
||||
// 需要更新settings,是一个json,例如{"azure_responses_version": "preview"}
|
||||
let settings = {};
|
||||
if (inputs.settings) {
|
||||
try {
|
||||
settings = JSON.parse(inputs.settings);
|
||||
} catch (error) {
|
||||
console.error('解析设置失败:', error);
|
||||
}
|
||||
}
|
||||
settings[key] = value;
|
||||
const settingsJson = JSON.stringify(settings);
|
||||
handleInputChange('settings', settingsJson);
|
||||
}
|
||||
|
||||
const handleInputChange = (name, value) => {
|
||||
if (formApiRef.current) {
|
||||
@@ -360,6 +354,17 @@ const EditChannelModal = (props) => {
|
||||
data.system_prompt_override = false;
|
||||
}
|
||||
|
||||
if (data.settings) {
|
||||
try {
|
||||
const parsedSettings = JSON.parse(data.settings);
|
||||
data.azure_responses_version = parsedSettings.azure_responses_version || '';
|
||||
} catch (error) {
|
||||
console.error('解析其他设置失败:', error);
|
||||
data.azure_responses_version = '';
|
||||
data.region = '';
|
||||
}
|
||||
}
|
||||
|
||||
setInputs(data);
|
||||
if (formApiRef.current) {
|
||||
formApiRef.current.setValues(data);
|
||||
@@ -1377,6 +1382,15 @@ const EditChannelModal = (props) => {
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Form.Input
|
||||
field='azure_responses_version'
|
||||
label={t('默认 Responses API 版本,为空则使用上方版本')}
|
||||
placeholder={t('例如:preview')}
|
||||
onChange={(value) => handleChannelOtherSettingsChange('azure_responses_version', value)}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user