99package com.example.executorchllamademo.ui.screens
1010
1111import androidx.compose.foundation.background
12+ import androidx.compose.foundation.border
1213import androidx.compose.foundation.clickable
1314import androidx.compose.foundation.layout.Column
1415import androidx.compose.foundation.layout.Row
@@ -20,6 +21,8 @@ import androidx.compose.foundation.layout.padding
2021import androidx.compose.foundation.layout.size
2122import androidx.compose.foundation.rememberScrollState
2223import androidx.compose.foundation.shape.RoundedCornerShape
24+ import androidx.compose.foundation.text.BasicTextField
25+ import androidx.compose.foundation.text.KeyboardOptions
2326import androidx.compose.foundation.verticalScroll
2427import androidx.compose.material.icons.Icons
2528import androidx.compose.material.icons.filled.ArrowBack
@@ -43,8 +46,11 @@ import androidx.compose.runtime.setValue
4346import androidx.compose.ui.Alignment
4447import androidx.compose.ui.Modifier
4548import androidx.compose.ui.graphics.Color
49+ import androidx.compose.ui.graphics.SolidColor
4650import androidx.compose.ui.platform.LocalContext
51+ import androidx.compose.ui.text.TextStyle
4752import androidx.compose.ui.text.font.FontWeight
53+ import androidx.compose.ui.text.input.KeyboardType
4854import androidx.compose.ui.unit.dp
4955import androidx.compose.ui.unit.sp
5056import com.example.executorchllamademo.AppSettings
@@ -68,11 +74,13 @@ fun AppSettingsScreen(
6874 var moduleSettings by remember { mutableStateOf(ModuleSettings ()) }
6975 var showAppearanceDialog by remember { mutableStateOf(false ) }
7076 var showClearChatDialog by remember { mutableStateOf(false ) }
77+ var maxSeqLenText by remember { mutableStateOf(" " ) }
7178
7279 LaunchedEffect (Unit ) {
7380 val prefs = DemoSharedPreferences (context)
7481 appSettings = prefs.getAppSettings()
7582 moduleSettings = prefs.getModuleSettings()
83+ maxSeqLenText = appSettings.maxSeqLen.toString()
7684 }
7785
7886 Column (
@@ -133,6 +141,77 @@ fun AppSettingsScreen(
133141
134142 Spacer (modifier = Modifier .height(24 .dp))
135143
144+ // Model Configuration section header
145+ Text (
146+ text = " Model Configuration" ,
147+ fontSize = 16 .sp,
148+ fontWeight = FontWeight .Bold ,
149+ color = appColors.settingsText
150+ )
151+
152+ Spacer (modifier = Modifier .height(8 .dp))
153+
154+ // Max Seq Len input field
155+ Column (
156+ modifier = Modifier
157+ .fillMaxWidth()
158+ .background(appColors.settingsRowBackground, RoundedCornerShape (8 .dp))
159+ .padding(horizontal = 16 .dp, vertical = 12 .dp)
160+ ) {
161+ Text (
162+ text = " Max Sequence Length" ,
163+ fontSize = 14 .sp,
164+ color = appColors.settingsText,
165+ fontWeight = FontWeight .Medium
166+ )
167+ Spacer (modifier = Modifier .height(8 .dp))
168+ BasicTextField (
169+ value = maxSeqLenText,
170+ onValueChange = { newValue ->
171+ maxSeqLenText = newValue
172+ val newMaxSeqLen = newValue.toIntOrNull()
173+ if (newMaxSeqLen != null && newMaxSeqLen > 0 ) {
174+ appSettings = appSettings.copy(maxSeqLen = newMaxSeqLen)
175+ val prefs = DemoSharedPreferences (context)
176+ prefs.saveAppSettings(appSettings)
177+ }
178+ },
179+ keyboardOptions = KeyboardOptions (keyboardType = KeyboardType .Number ),
180+ singleLine = true ,
181+ textStyle = TextStyle (
182+ color = appColors.settingsText,
183+ fontSize = 16 .sp
184+ ),
185+ cursorBrush = SolidColor (appColors.settingsText),
186+ modifier = Modifier .fillMaxWidth(),
187+ decorationBox = { innerTextField ->
188+ Row (
189+ modifier = Modifier
190+ .fillMaxWidth()
191+ .border(1 .dp, appColors.settingsText.copy(alpha = 0.5f ), RoundedCornerShape (4 .dp))
192+ .padding(horizontal = 12 .dp, vertical = 14 .dp)
193+ ) {
194+ if (maxSeqLenText.isEmpty()) {
195+ Text (
196+ text = " Enter max sequence length" ,
197+ color = appColors.settingsText.copy(alpha = 0.5f ),
198+ fontSize = 16 .sp
199+ )
200+ }
201+ innerTextField()
202+ }
203+ }
204+ )
205+ Text (
206+ text = " Maximum number of tokens to generate (default: ${AppSettings .DEFAULT_MAX_SEQ_LEN } )" ,
207+ fontSize = 12 .sp,
208+ color = appColors.settingsText.copy(alpha = 0.6f ),
209+ modifier = Modifier .padding(top = 4 .dp)
210+ )
211+ }
212+
213+ Spacer (modifier = Modifier .height(24 .dp))
214+
136215 // Conversation section header
137216 Text (
138217 text = " Conversation" ,
0 commit comments