feat: allow entering a custom AI model name in settings

This commit is contained in:
zhoubinjia committed 2026-05-12 11:20:35 +08:00
1 parent bc8aff7af8
commit ae03a224d7
3 files changed
+64 -2

No files matched your search

@@ -316,6 +316,8 @@ fun SettingsScreen(
// 日志查看器弹窗状态
var showLogViewerDialog by remember { mutableStateOf(false) }
var showCustomAIModelDialog by remember { mutableStateOf(false) }
var customAIModelValue by remember { mutableStateOf("") }
var softwareProcessingExpanded by remember { mutableStateOf(false) }
var calibrationExpanded by remember { mutableStateOf(false) }
var showGhostPermissionDialog by remember { mutableStateOf(false) }
@@ -849,15 +851,23 @@ fun SettingsScreen(
modifier = Modifier.padding(vertical = 8.dp)
)
val customModelLabel = stringResource(R.string.settings_ai_model_custom)
DropdownSettingItem(
title = stringResource(R.string.settings_ai_model),
description = stringResource(R.string.settings_ai_model_desc),
value = openAIModel ?: OpenAIApiClient.DEFAULT_MODEL,
options = availableOpenAIModels,
options = availableOpenAIModels + customModelLabel,
isLoading = isFetchingAIModels,
enabled = !openAIApiKey.isNullOrBlank(),
onExpanded = { viewModel.fetchAvailableAIModels() },
onOptionSelected = { viewModel.setOpenAIModel(it) }
onOptionSelected = {
if (it == customModelLabel) {
customAIModelValue = openAIModel ?: ""
showCustomAIModelDialog = true
} else {
viewModel.setOpenAIModel(it)
}
}
)
}
@@ -1546,6 +1556,52 @@ fun SettingsScreen(
)
}
if (showCustomAIModelDialog) {
AlertDialog(
onDismissRequest = { showCustomAIModelDialog = false },
title = { Text(text = stringResource(R.string.settings_ai_model_custom_dialog_title)) },
text = {
Column {
Text(
text = stringResource(R.string.settings_ai_model_custom_dialog_desc),
style = MaterialTheme.typography.bodyMedium,
color = Color.White.copy(alpha = 0.7f)
)
Spacer(modifier = Modifier.height(16.dp))
androidx.compose.material3.OutlinedTextField(
value = customAIModelValue,
onValueChange = { customAIModelValue = it },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
colors = androidx.compose.material3.OutlinedTextFieldDefaults.colors(
focusedTextColor = Color.White,
unfocusedTextColor = Color.White,
focusedBorderColor = Color(0xFFE5A324),
unfocusedBorderColor = Color.White.copy(alpha = 0.2f)
)
)
}
},
confirmButton = {
TextButton(
onClick = {
if (customAIModelValue.isNotBlank()) {
viewModel.setOpenAIModel(customAIModelValue.trim())
}
showCustomAIModelDialog = false
}
) {
Text(stringResource(R.string.confirm))
}
},
dismissButton = {
TextButton(onClick = { showCustomAIModelDialog = false }) {
Text(stringResource(R.string.cancel))
}
}
)
}
baselinePickerTarget?.let { target ->
val currentBaselineLutId = when (target) {
BaselineColorCorrectionTarget.JPG -> jpgBaselineLutId
@@ -801,6 +801,9 @@
<string name="settings_ai_model_select">点此选择模型…</string>
<string name="settings_ai_model_fetching">正在请求列表…</string>
<string name="settings_ai_model_empty">未找到任何可用模型</string>
<string name="settings_ai_model_custom">自定义…</string>
<string name="settings_ai_model_custom_dialog_title">自定义 AI 模型</string>
<string name="settings_ai_model_custom_dialog_desc">输入要使用的 AI 模型名称。</string>
<string name="general">常用</string>
<string name="imaging">影像</string>
<string name="phantom">幻影</string>
+3
View File
@@ -806,6 +806,9 @@
<string name="settings_ai_model_select">Select a model…</string>
<string name="settings_ai_model_fetching">Fetching…</string>
<string name="settings_ai_model_empty">No models found</string>
<string name="settings_ai_model_custom">Custom…</string>
<string name="settings_ai_model_custom_dialog_title">Custom AI Model</string>
<string name="settings_ai_model_custom_dialog_desc">Enter the name of the AI model to use.</string>
<string name="general">General</string>
<string name="imaging">Imaging</string>
<string name="phantom">Phantom</string>