Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/features/xef-mobiles' into featu…
Browse files Browse the repository at this point in the history
…res/xef-mobiles

# Conflicts:
#	server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/CreateAssistantScreen.kt
  • Loading branch information
JoseP3r32 committed Jun 5, 2024
2 parents 3b34bf7 + e108a93 commit 3efe737
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,23 @@ fun CreateAssistantScreen(
var fileSearchEnabled by remember { mutableStateOf(false) }
var codeInterpreterEnabled by remember { mutableStateOf(false) }
var model by remember { mutableStateOf("gpt-4-turbo") }
val list = listOf(
"gpt-4o", "gpt-4o-2024-05-13", "gpt-4", "gpt-4-vision-preview", "gpt-4-turbo-preview",
"gpt-4-2024-04-09", "gpt-4-turbo", "gpt-4-1106-preview", "gpt-4-0613", "gpt-4-0125-preview",
"gpt-4", "gpt-3.5-turbo-16K", "gpt-3.5-turbo-0125", "gpt-3.5-turbo"
)
val list =
listOf(
"gpt-4o",
"gpt-4o-2024-05-13",
"gpt-4",
"gpt-4-vision-preview",
"gpt-4-turbo-preview",
"gpt-4-2024-04-09",
"gpt-4-turbo",
"gpt-4-1106-preview",
"gpt-4-0613",
"gpt-4-0125-preview",
"gpt-4",
"gpt-3.5-turbo-16K",
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo"
)
var isExpanded by remember { mutableStateOf(false) }
var selectedText by remember { mutableStateOf(list[0]) }
var showFilePicker by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -110,7 +122,8 @@ fun CreateAssistantScreen(
}
}

Scaffold(snackbarHost = { SnackbarHost(snackbarHostState) }, modifier = Modifier.fillMaxSize()) { paddingValues ->
Scaffold(snackbarHost = { SnackbarHost(snackbarHostState) }, modifier = Modifier.fillMaxSize()) {
paddingValues ->
Box(modifier = Modifier.fillMaxSize().padding(paddingValues)) {
LazyColumn(
modifier = Modifier.padding(8.dp).fillMaxSize(),
Expand All @@ -135,9 +148,7 @@ fun CreateAssistantScreen(
}
}

item {
Spacer(modifier = Modifier.height(12.dp))
}
item { Spacer(modifier = Modifier.height(12.dp)) }

item {
Box(modifier = Modifier.fillMaxWidth()) {
Expand All @@ -150,9 +161,7 @@ fun CreateAssistantScreen(
}
}

item {
Spacer(modifier = Modifier.height(12.dp))
}
item { Spacer(modifier = Modifier.height(12.dp)) }

item {
Box(modifier = Modifier.fillMaxWidth()) {
Expand All @@ -168,7 +177,10 @@ fun CreateAssistantScreen(
readOnly = true,
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = isExpanded) }
)
ExposedDropdownMenu(expanded = isExpanded, onDismissRequest = { isExpanded = false }) {
ExposedDropdownMenu(
expanded = isExpanded,
onDismissRequest = { isExpanded = false }
) {
val itemsToShow = if (showAllItems) list else list.take(5)
itemsToShow.forEachIndexed { index, text ->
DropdownMenuItem(
Expand All @@ -193,9 +205,7 @@ fun CreateAssistantScreen(
}
}

item {
Spacer(modifier = Modifier.height(12.dp))
}
item { Spacer(modifier = Modifier.height(12.dp)) }

item {
ToolsSection(
Expand All @@ -211,9 +221,7 @@ fun CreateAssistantScreen(
)
}

item {
Spacer(modifier = Modifier.height(12.dp))
}
item { Spacer(modifier = Modifier.height(12.dp)) }

item {
Column {
Expand All @@ -222,9 +230,7 @@ fun CreateAssistantScreen(
}
}

item {
Spacer(modifier = Modifier.height(12.dp))
}
item { Spacer(modifier = Modifier.height(12.dp)) }

item {
AssistantFloatField(
Expand Down Expand Up @@ -256,10 +262,11 @@ fun CreateAssistantScreen(
) {
Button(
onClick = { navController.navigateUp() },
colors = ButtonDefaults.buttonColors(
containerColor = customColors.buttonColor,
contentColor = MaterialTheme.colorScheme.onPrimary
)
colors =
ButtonDefaults.buttonColors(
containerColor = customColors.buttonColor,
contentColor = MaterialTheme.colorScheme.onPrimary
)
) {
Text("Cancel")
}
Expand Down Expand Up @@ -288,10 +295,11 @@ fun CreateAssistantScreen(
)
}
},
colors = ButtonDefaults.buttonColors(
containerColor = customColors.buttonColor,
contentColor = MaterialTheme.colorScheme.onPrimary
)
colors =
ButtonDefaults.buttonColors(
containerColor = customColors.buttonColor,
contentColor = MaterialTheme.colorScheme.onPrimary
)
) {
Text("Create")
}
Expand Down Expand Up @@ -338,19 +346,15 @@ fun CreateAssistantScreen(
FilePickerDialog(
onDismissRequest = { showFilePicker = false },
customColors = customColors,
onFilesSelected = {
showFilePicker = false
}
onFilesSelected = { showFilePicker = false }
)
}

if (showCodeInterpreterPicker) {
FilePickerDialog(
onDismissRequest = { showCodeInterpreterPicker = false },
customColors = customColors,
onFilesSelected = {
showCodeInterpreterPicker = false
},
onFilesSelected = { showCodeInterpreterPicker = false },
mimeTypeFilter = "text/*"
)
}
Expand All @@ -367,21 +371,19 @@ fun AssistantFloatField(
) {
val customColors = LocalCustomColors.current
Column(modifier = Modifier.fillMaxWidth()) {
Text(
text = label,
modifier = Modifier.padding(bottom = 2.dp)
)
Text(text = label, modifier = Modifier.padding(bottom = 2.dp))
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
Slider(
value = value,
onValueChange = onValueChange,
valueRange = valueRange,
steps = 200,
modifier = Modifier.weight(3f),
colors = SliderDefaults.colors(
thumbColor = customColors.sliderThumbColor,
activeTrackColor = customColors.sliderTrackColor
)
colors =
SliderDefaults.colors(
thumbColor = customColors.sliderThumbColor,
activeTrackColor = customColors.sliderTrackColor
)
)
Spacer(modifier = Modifier.width(2.dp))
TextField(
Expand Down Expand Up @@ -437,7 +439,8 @@ fun ToolsSection(
Spacer(modifier = Modifier.weight(1f))
IconButton(onClick = { expanded = !expanded }) {
Icon(
imageVector = if (expanded) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown,
imageVector =
if (expanded) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown,
contentDescription = if (expanded) "Collapse" else "Expand"
)
}
Expand All @@ -450,42 +453,46 @@ fun ToolsSection(
Row(verticalAlignment = Alignment.CenterVertically) {
TextButton(
onClick = { onShowFilePickerChange(true) },
colors = ButtonDefaults.outlinedButtonColors(
containerColor = Color.Transparent,
contentColor = customColors.buttonColor
)
colors =
ButtonDefaults.outlinedButtonColors(
containerColor = Color.Transparent,
contentColor = customColors.buttonColor
)
) {
Text("File Search +")
}
Spacer(modifier = Modifier.weight(1f))
Switch(
checked = fileSearchEnabled,
onCheckedChange = onFileSearchEnabledChange,
colors = SwitchDefaults.colors(
checkedThumbColor = customColors.sliderThumbColor,
checkedTrackColor = customColors.sliderTrackColor
)
colors =
SwitchDefaults.colors(
checkedThumbColor = customColors.sliderThumbColor,
checkedTrackColor = customColors.sliderTrackColor
)
)
}
Spacer(modifier = Modifier.height(8.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
TextButton(
onClick = { onShowCodeInterpreterPickerChange(true) },
colors = ButtonDefaults.outlinedButtonColors(
containerColor = Color.Transparent,
contentColor = customColors.buttonColor
)
colors =
ButtonDefaults.outlinedButtonColors(
containerColor = Color.Transparent,
contentColor = customColors.buttonColor
)
) {
Text("Code Interpreter +")
}
Spacer(modifier = Modifier.weight(1f))
Switch(
checked = codeInterpreterEnabled,
onCheckedChange = onCodeInterpreterEnabledChange,
colors = SwitchDefaults.colors(
checkedThumbColor = customColors.sliderThumbColor,
checkedTrackColor = customColors.sliderTrackColor
)
colors =
SwitchDefaults.colors(
checkedThumbColor = customColors.sliderThumbColor,
checkedTrackColor = customColors.sliderTrackColor
)
)
}
Spacer(modifier = Modifier.height(8.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ class AssistantViewModel(
viewModelScope.launch {
try {
val token = settingsViewModel.apiKey.value ?: throw Exception("API key not found")
val response: HttpResponse = apiService.deleteAssistant(authToken = token, assistantId = assistantId)
val response: HttpResponse =
apiService.deleteAssistant(authToken = token, assistantId = assistantId)

if (response.status == HttpStatusCode.NoContent) {
fetchAssistants()
Expand Down

0 comments on commit 3efe737

Please sign in to comment.