@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.padding
2020import androidx.compose.foundation.layout.size
2121import androidx.compose.foundation.rememberScrollState
2222import androidx.compose.foundation.shape.RoundedCornerShape
23+ import androidx.compose.foundation.text.KeyboardOptions
2324import androidx.compose.foundation.verticalScroll
2425import androidx.compose.material.icons.Icons
2526import androidx.compose.material.icons.filled.ArrowBack
@@ -29,6 +30,7 @@ import androidx.compose.material3.Button
2930import androidx.compose.material3.ButtonDefaults
3031import androidx.compose.material3.Icon
3132import androidx.compose.material3.IconButton
33+ import androidx.compose.material3.OutlinedTextField
3234import androidx.compose.material3.RadioButton
3335import androidx.compose.material3.Switch
3436import androidx.compose.material3.SwitchDefaults
@@ -45,6 +47,7 @@ import androidx.compose.ui.Modifier
4547import androidx.compose.ui.graphics.Color
4648import androidx.compose.ui.platform.LocalContext
4749import androidx.compose.ui.text.font.FontWeight
50+ import androidx.compose.ui.text.input.KeyboardType
4851import androidx.compose.ui.unit.dp
4952import androidx.compose.ui.unit.sp
5053import com.example.executorchllamademo.AppSettings
@@ -68,11 +71,13 @@ fun AppSettingsScreen(
6871 var moduleSettings by remember { mutableStateOf(ModuleSettings ()) }
6972 var showAppearanceDialog by remember { mutableStateOf(false ) }
7073 var showClearChatDialog by remember { mutableStateOf(false ) }
74+ var maxSeqLenText by remember { mutableStateOf(" " ) }
7175
7276 LaunchedEffect (Unit ) {
7377 val prefs = DemoSharedPreferences (context)
7478 appSettings = prefs.getAppSettings()
7579 moduleSettings = prefs.getModuleSettings()
80+ maxSeqLenText = appSettings.maxSeqLen.toString()
7681 }
7782
7883 Column (
@@ -133,6 +138,56 @@ fun AppSettingsScreen(
133138
134139 Spacer (modifier = Modifier .height(24 .dp))
135140
141+ // Model Configuration section header
142+ Text (
143+ text = " Model Configuration" ,
144+ fontSize = 16 .sp,
145+ fontWeight = FontWeight .Bold ,
146+ color = appColors.settingsText
147+ )
148+
149+ Spacer (modifier = Modifier .height(8 .dp))
150+
151+ // Max Seq Len input field
152+ Column (
153+ modifier = Modifier
154+ .fillMaxWidth()
155+ .background(appColors.settingsRowBackground, RoundedCornerShape (8 .dp))
156+ .padding(horizontal = 16 .dp, vertical = 12 .dp)
157+ ) {
158+ Text (
159+ text = " Max Sequence Length" ,
160+ fontSize = 14 .sp,
161+ color = appColors.settingsText,
162+ fontWeight = FontWeight .Medium
163+ )
164+ Spacer (modifier = Modifier .height(8 .dp))
165+ OutlinedTextField (
166+ value = maxSeqLenText,
167+ onValueChange = { newValue ->
168+ maxSeqLenText = newValue
169+ val newMaxSeqLen = newValue.toIntOrNull()
170+ if (newMaxSeqLen != null && newMaxSeqLen > 0 ) {
171+ appSettings = appSettings.copy(maxSeqLen = newMaxSeqLen)
172+ val prefs = DemoSharedPreferences (context)
173+ prefs.saveAppSettings(appSettings)
174+ }
175+ },
176+ label = { Text (" Enter max sequence length" ) },
177+ keyboardOptions = KeyboardOptions (keyboardType = KeyboardType .Number ),
178+ modifier = Modifier .fillMaxWidth(),
179+ singleLine = true
180+ )
181+ Text (
182+ text = " Maximum number of tokens to generate (default: ${AppSettings .DEFAULT_MAX_SEQ_LEN } )" ,
183+ fontSize = 12 .sp,
184+ color = appColors.settingsText.copy(alpha = 0.6f ),
185+ modifier = Modifier .padding(top = 4 .dp)
186+ )
187+ }
188+
189+ Spacer (modifier = Modifier .height(24 .dp))
190+
136191 // Conversation section header
137192 Text (
138193 text = " Conversation" ,
0 commit comments