Skip to content

Commit 97493b0

Browse files
committed
update
1 parent c4c28ef commit 97493b0

2 files changed

Lines changed: 9 additions & 54 deletions

File tree

llm/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ui/screens/ModelSettingsScreen.kt

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -924,67 +924,20 @@ private fun AddModelDialog(viewModel: ModelSettingsViewModel) {
924924
}
925925
}
926926
3 -> {
927-
// Step 3: Confirm model type
928-
val modelTypes = ModelType.values().map { it.toString() }
929-
val preSelectedIndex = ModelType.values().indexOfFirst { it == viewModel.tempModelType }
930-
931-
AlertDialog(
932-
onDismissRequest = { viewModel.previousAddModelStep() },
933-
title = { Text("Step 3: Confirm Model Type") },
934-
text = {
935-
Column {
936-
modelTypes.forEachIndexed { index, option ->
937-
Row(
938-
modifier = Modifier
939-
.fillMaxWidth()
940-
.clickable {
941-
viewModel.selectTempModelType(ModelType.valueOf(option))
942-
}
943-
.padding(vertical = 8.dp),
944-
verticalAlignment = Alignment.CenterVertically
945-
) {
946-
RadioButton(
947-
selected = index == preSelectedIndex || viewModel.tempModelType.toString() == option,
948-
onClick = {
949-
viewModel.selectTempModelType(ModelType.valueOf(option))
950-
}
951-
)
952-
Text(
953-
text = option,
954-
modifier = Modifier.padding(start = 8.dp),
955-
fontSize = 14.sp
956-
)
957-
}
958-
}
959-
}
960-
},
961-
confirmButton = {
962-
TextButton(onClick = { viewModel.goToAddModelStep(4) }) {
963-
Text("Next")
964-
}
965-
},
966-
dismissButton = {
967-
TextButton(onClick = { viewModel.previousAddModelStep() }) {
968-
Text("Back")
969-
}
970-
}
971-
)
972-
}
973-
4 -> {
974-
// Step 4: Select adapter PTDs (optional, multi-select)
927+
// Step 3: Select adapter PTDs (0 or more, optional)
975928
val appColors = LocalAppColors.current
976929

977930
AlertDialog(
978931
onDismissRequest = { viewModel.previousAddModelStep() },
979-
title = { Text("Step 4: Select Adapter PTDs (Optional)") },
932+
title = { Text("Step 3: Select Adapter PTDs") },
980933
text = {
981934
Column(
982935
modifier = Modifier
983936
.fillMaxWidth()
984937
.height(400.dp)
985938
) {
986939
Text(
987-
text = "Select one or more adapter PTD files for this model:",
940+
text = "Select 0 or more adapter PTD files for this model (optional):",
988941
fontSize = 14.sp,
989942
modifier = Modifier.padding(bottom = 8.dp)
990943
)

llm/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ui/viewmodel/ModelSettingsViewModel.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,12 @@ class ModelSettingsViewModel : ViewModel() {
283283
*/
284284
fun selectTempTokenizer(tokenizerPath: String) {
285285
tempTokenizerPath = tokenizerPath
286-
addModelStep = 3
286+
// Auto-detect model type from PTE filename
287+
val detectedType = ModelType.fromFilePath(tempModelPath)
288+
if (detectedType != null) {
289+
tempModelType = detectedType
290+
}
291+
addModelStep = 3 // Skip model type, go to adapters
287292
}
288293

289294
/**
@@ -342,9 +347,6 @@ class ModelSettingsViewModel : ViewModel() {
342347
3 -> {
343348
addModelStep = 2
344349
}
345-
4 -> {
346-
addModelStep = 3
347-
}
348350
else -> cancelAddModel()
349351
}
350352
}

0 commit comments

Comments
 (0)