Skip to content

Commit

Permalink
Skip API Token input page when Ollama is only selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Taewan-P committed Oct 26, 2024
1 parent b3ada3b commit ff590a6
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class SetupViewModel @Inject constructor(private val settingRepository: SettingR
Route.OLLAMA_API_ADDRESS,
Route.SETUP_COMPLETE
)
val commonSteps = setOf(Route.SELECT_PLATFORM, Route.TOKEN_INPUT, Route.SETUP_COMPLETE)
val commonSteps = mutableSetOf(Route.SELECT_PLATFORM, Route.TOKEN_INPUT, Route.SETUP_COMPLETE)
val platformStep = mapOf(
Route.OPENAI_MODEL_SELECT to ApiType.OPENAI,
Route.ANTHROPIC_MODEL_SELECT to ApiType.ANTHROPIC,
Expand All @@ -129,6 +129,12 @@ class SetupViewModel @Inject constructor(private val settingRepository: SettingR

val currentIndex = steps.indexOfFirst { it == currentRoute }
val enabledPlatform = platformState.value.filter { it.selected }.map { it.name }.toSet()

if (enabledPlatform.size == 1 && ApiType.OLLAMA in enabledPlatform) {
// Skip API Token input page
commonSteps.remove(Route.TOKEN_INPUT)
}

val remainingSteps = steps.filterIndexed { index, setupStep ->
index > currentIndex &&
(setupStep in commonSteps || platformStep[setupStep] in enabledPlatform)
Expand Down

0 comments on commit ff590a6

Please sign in to comment.