Skip to content

Commit bd9c21b

Browse files
committed
update
1 parent 5472a47 commit bd9c21b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • llm/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ui/viewmodel

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class ChatViewModel(application: Application) : AndroidViewModel(application), L
110110
val isLoadModel = updatedSettingsFields.isLoadModel
111111
if (isUpdated) {
112112
checkForClearChatHistory(updatedSettingsFields)
113-
currentSettingsFields = updatedSettingsFields.copy()
114113
// Update media capabilities after settings are updated
115114
setBackendMode(updatedSettingsFields.backendType)
116115

@@ -121,9 +120,16 @@ class ChatViewModel(application: Application) : AndroidViewModel(application), L
121120
updatedSettingsFields.dataPath,
122121
updatedSettingsFields.temperature.toFloat()
123122
)
124-
demoSharedPreferences.saveModuleSettings(updatedSettingsFields.copy(isLoadModel = false))
125-
} else if (module == null) {
126-
addSystemMessage(systemPromptMessage)
123+
// Save with isLoadModel = false and update local copy to match,
124+
// preventing duplicate "To get started..." messages on subsequent calls
125+
val settingsWithLoadFlagCleared = updatedSettingsFields.copy(isLoadModel = false)
126+
demoSharedPreferences.saveModuleSettings(settingsWithLoadFlagCleared)
127+
currentSettingsFields = settingsWithLoadFlagCleared
128+
} else {
129+
currentSettingsFields = updatedSettingsFields.copy()
130+
if (module == null) {
131+
addSystemMessage(systemPromptMessage)
132+
}
127133
}
128134
} else {
129135
// Settings unchanged, but still update media capabilities for current settings

0 commit comments

Comments
 (0)