Skip to content

Commit

Permalink
Extract model string linked hash set
Browse files Browse the repository at this point in the history
  • Loading branch information
Taewan-P committed May 31, 2024
1 parent c570db0 commit fd8b1e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.chungjungsoo.gptmobile.presentation.common

object ModelConstants {
// LinkedHashSet should be used to guarantee item order
val openaiModels = linkedSetOf("gpt-4o", "gpt-4-turbo", "gpt-4", "gpt-3.5-turbo")
val anthropicModels = linkedSetOf("claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307")
val googleModels = linkedSetOf("gemini-1.5-pro-latest", "gemini-1.5-flash-latest", "gemini-1.0-pro")
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import androidx.hilt.navigation.compose.hiltViewModel
import dev.chungjungsoo.gptmobile.R
import dev.chungjungsoo.gptmobile.data.dto.APIModel
import dev.chungjungsoo.gptmobile.data.model.ApiType
import dev.chungjungsoo.gptmobile.presentation.common.ModelConstants.anthropicModels
import dev.chungjungsoo.gptmobile.presentation.common.ModelConstants.googleModels
import dev.chungjungsoo.gptmobile.presentation.common.ModelConstants.openaiModels
import dev.chungjungsoo.gptmobile.presentation.common.PrimaryLongButton
import dev.chungjungsoo.gptmobile.presentation.common.RadioItem
import dev.chungjungsoo.gptmobile.util.collectManagedState
Expand All @@ -44,9 +47,9 @@ fun SelectModelScreen(
val title = getAPIModelSelectTitle(platformType)
val description = getAPIModelSelectDescription(platformType)
val availableModels = when (platformType) {
ApiType.OPENAI -> generateOpenAIModelList(models = setupViewModel.openaiModels)
ApiType.ANTHROPIC -> generateAnthropicModelList(models = setupViewModel.anthropicModels)
ApiType.GOOGLE -> generateGoogleModelList(models = setupViewModel.googleModels)
ApiType.OPENAI -> generateOpenAIModelList(models = openaiModels)
ApiType.ANTHROPIC -> generateAnthropicModelList(models = anthropicModels)
ApiType.GOOGLE -> generateGoogleModelList(models = googleModels)
}
val defaultModel = remember {
derivedStateOf {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import dev.chungjungsoo.gptmobile.data.dto.Platform
import dev.chungjungsoo.gptmobile.data.model.ApiType
import dev.chungjungsoo.gptmobile.data.repository.SettingRepository
import dev.chungjungsoo.gptmobile.presentation.common.ModelConstants.anthropicModels
import dev.chungjungsoo.gptmobile.presentation.common.ModelConstants.googleModels
import dev.chungjungsoo.gptmobile.presentation.common.ModelConstants.openaiModels
import dev.chungjungsoo.gptmobile.presentation.common.Route
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -17,11 +20,6 @@ import kotlinx.coroutines.launch
@HiltViewModel
class SetupViewModel @Inject constructor(private val settingRepository: SettingRepository) : ViewModel() {

// LinkedHashSet should be used to guarantee item order
val openaiModels = linkedSetOf("gpt-4o", "gpt-4-turbo", "gpt-4", "gpt-3.5-turbo")
val anthropicModels = linkedSetOf("claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307")
val googleModels = linkedSetOf("gemini-1.5-pro-latest", "gemini-1.5-flash-latest", "gemini-1.0-pro")

private val _platformState = MutableStateFlow(
listOf(
Platform(ApiType.OPENAI),
Expand Down

0 comments on commit fd8b1e4

Please sign in to comment.