Skip to content

Commit

Permalink
Merge pull request #1 from Taewan-P/dev
Browse files Browse the repository at this point in the history
Add Claude 3.5 Sonnet support
  • Loading branch information
Taewan-P authored Jun 21, 2024
2 parents 7023cb4 + 979717b commit c5946c2
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 44 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/debug-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
jobs:
run:
runs-on: macos-14

permissions:
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
name: Release build APK

on:
push:
branches:
- "main"
paths-ignore:
- ".gitignore"
- "**.md"
- "LICENSE"
- ".idea/**"
- ".github/**"
- ".editorconfig"
- "images/**"
workflow_dispatch:

jobs:
Expand Down
18 changes: 14 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
# Gradle
*.iml
.gradle

# Android
/local.properties

# Android Studio
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/inspectionProfiles/Project_Default.xml
/.idea/appInsightsSettings.xml
/.idea/deploymentTargetSelector.xml

# MacOS
.DS_Store

# Build
/build
/captures
.externalNativeBuild
.cxx
local.properties
.idea/inspectionProfiles/Project_Default.xml
.idea/appInsightsSettings.xml
.idea/deploymentTargetSelector.xml
app/release/**
app/build/**
7 changes: 1 addition & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.android.hilt)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.kotlin.ksp)
alias(libs.plugins.kotlin.parcelize)
kotlin(libs.plugins.kotlin.serialization.get().pluginId).version(libs.versions.kotlin)
Expand Down Expand Up @@ -91,7 +90,7 @@ dependencies {
// Dependency Injection
implementation(libs.hilt)
implementation(libs.androidx.lifecycle.runtime.compose.android)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)

// Gemini SDK
implementation(libs.gemini)
Expand Down Expand Up @@ -131,7 +130,3 @@ dependencies {
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}

kapt {
correctErrorTypes = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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 anthropicModels = linkedSetOf("claude-3-5-sonnet-20240620", "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")

const val ANTHROPIC_MAXIMUM_TOKEN = 4096
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ fun PlatformSettingScreen(
onDismissRequest = { isApiTokenDialogOpen = false }
) { token ->
settingViewModel.updateToken(apiType, token)
settingViewModel.savePlatformSettings()
isApiTokenDialogOpen = false
}
}
Expand All @@ -150,9 +151,11 @@ fun PlatformSettingScreen(
ModelDialog(
apiType = apiType,
model = model ?: "",
onModelSelected = { m -> settingViewModel.updateModel(apiType, m) },
onDismissRequest = { isModelDialogOpen = false }
) { m ->
settingViewModel.updateModel(apiType, m)
settingViewModel.savePlatformSettings()
isModelDialogOpen = false
}
}
Expand Down Expand Up @@ -309,6 +312,7 @@ fun APIKeyDialog(
fun ModelDialog(
apiType: ApiType,
model: String,
onModelSelected: (String) -> Unit,
onDismissRequest: () -> Unit,
onConfirmRequest: (model: String) -> Unit
) {
Expand All @@ -322,7 +326,6 @@ fun ModelDialog(
ApiType.ANTHROPIC -> generateAnthropicModelList(models = modelList)
ApiType.GOOGLE -> generateGoogleModelList(models = modelList)
}
var model by remember { mutableStateOf(model) }
val configuration = LocalConfiguration.current

AlertDialog(
Expand All @@ -337,7 +340,7 @@ fun ModelDialog(
selected = model == m.aliasValue,
title = m.name,
description = m.description,
onSelected = { model = it }
onSelected = { onModelSelected(it) }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ class SettingViewModel @Inject constructor(
fetchPlatformStatus()
}

fun fetchPlatformStatus() {
viewModelScope.launch {
val platforms = settingRepository.fetchPlatforms()
_platformState.update { platforms }
}
}

fun toggleAPI(apiType: ApiType) {
val index = _platformState.value.indexOfFirst { it.name == apiType }

Expand All @@ -55,6 +48,12 @@ class SettingViewModel @Inject constructor(
}
}

fun savePlatformSettings() {
viewModelScope.launch {
settingRepository.updatePlatforms(_platformState.value)
}
}

fun updateToken(apiType: ApiType, token: String) {
val index = _platformState.value.indexOfFirst { it.name == apiType }

Expand All @@ -68,9 +67,6 @@ class SettingViewModel @Inject constructor(
}
}
}
viewModelScope.launch {
settingRepository.updatePlatforms(_platformState.value)
}
}
}

Expand All @@ -92,9 +88,6 @@ class SettingViewModel @Inject constructor(
}
}
}
viewModelScope.launch {
settingRepository.updatePlatforms(_platformState.value)
}
}
}

Expand All @@ -105,4 +98,11 @@ class SettingViewModel @Inject constructor(
fun closeThemeDialog() {
_isThemeDialogOpen.update { false }
}

private fun fetchPlatformStatus() {
viewModelScope.launch {
val platforms = settingRepository.fetchPlatforms()
_platformState.update { platforms }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ fun generateOpenAIModelList(models: LinkedHashSet<String>) = models.mapIndexed {
@Composable
fun generateAnthropicModelList(models: LinkedHashSet<String>) = models.mapIndexed { index, model ->
val (name, description) = when (index) {
0 -> stringResource(R.string.claude_3_opus) to stringResource(R.string.claude_3_opus_description)
1 -> stringResource(R.string.claude_3_sonnet) to stringResource(R.string.claude_3_sonnet_description)
2 -> stringResource(R.string.claude_3_haiku) to stringResource(R.string.claude_3_haiku_description)
0 -> stringResource(R.string.claude_3_5_sonnet) to stringResource(R.string.claude_3_5_sonnet_description)
1 -> stringResource(R.string.claude_3_opus) to stringResource(R.string.claude_3_opus_description)
2 -> stringResource(R.string.claude_3_sonnet) to stringResource(R.string.claude_3_sonnet_description)
3 -> stringResource(R.string.claude_3_haiku) to stringResource(R.string.claude_3_haiku_description)
else -> "" to ""
}
APIModel(name, description, model)
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="gpt_3_5_description">"간단한 작업을 위한 빠르고 저렴한 모델입니다. "</string>
<string name="select_anthropic_model">Anthropic 모델 선택</string>
<string name="select_anthropic_model_description">Anthropic 채팅 모델을 선택해 주세요. 현재 Claude3 제품군만 지원하고 텍스트 입력만 지원합니다.</string>
<string name="claude_3_opus_description">Anthropic의 가장 강력한 모델입니다.</string>
<string name="claude_3_opus_description">글쓰기 및 복잡한 작업에 탁월한 모델입니다.</string>
<string name="claude_3_sonnet_description">"지능과 속도 사이의 균형 잡힌 모델입니다. "</string>
<string name="claude_3_haiku_description">Anthropic의 가장 빠르고 컴팩트한 모델입니다.</string>
<string name="select_google_model">Google 모델 선택</string>
Expand Down Expand Up @@ -71,6 +71,7 @@
<string name="send">전송</string>
<string name="copy_text">복사</string>
<string name="retry">재시도</string>
<string name="ask_a_question">질문을 입력하세요...</string>
<string name="ask_a_question">질문을 입력하세요</string>
<string name="some_platforms_disabled">일부 API가 비활성화되었습니다</string>
<string name="claude_3_5_sonnet_description">Anthropic사의 가장 지능적인 모델입니다.</string>
</resources>
6 changes: 4 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
<string name="gpt_3_5_description">A fast, inexpensive model for simple tasks.</string>
<string name="select_anthropic_model">Select Anthropic Chat Model</string>
<string name="select_anthropic_model_description">Please select the Anthropic chat model. We currently support the Claude 3 family of models with only text inputs.</string>
<string name="claude_3_5_sonnet" translatable="false">Claude 3.5 Sonnet</string>
<string name="claude_3_opus" translatable="false">Claude 3 Opus</string>
<string name="claude_3_sonnet" translatable="false">Claude 3 Sonnet</string>
<string name="claude_3_haiku" translatable="false">Claude 3 Haiku</string>
<string name="claude_3_opus_description">Anthropic\'s most powerful model.</string>
<string name="claude_3_5_sonnet_description">Anthropic\'s most intelligent model.</string>
<string name="claude_3_opus_description">Excels at writing and complex tasks.</string>
<string name="claude_3_sonnet_description">Balanced model between intelligence and speed.</string>
<string name="claude_3_haiku_description">Anthropic\'s fastest and most compact model.</string>
<string name="select_google_model">Select Google Chat Model</string>
Expand Down Expand Up @@ -86,7 +88,7 @@
<string name="send">Send</string>
<string name="copy_text">Copy Text</string>
<string name="retry">Retry</string>
<string name="ask_a_question">Ask a question...</string>
<string name="ask_a_question">Ask a question</string>
<string name="some_platforms_disabled">Some APIs are disabled</string>
<string name="openai_brand_text" translatable="false">Powered by OpenAI</string>
<string name="anthropic_brand_text" translatable="false">Powered by Claude</string>
Expand Down

0 comments on commit c5946c2

Please sign in to comment.