Skip to content

Commit

Permalink
Remove AICore feature due to license issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Taewan-P committed Nov 19, 2024
1 parent 1fffb59 commit 16c4ca0
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 39 deletions.
7 changes: 2 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId = "dev.chungjungsoo.gptmobile"
minSdk = 31
targetSdk = 35
versionCode = 12
versionName = "0.6.0"
versionCode = 13
versionName = "0.6.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -71,9 +71,6 @@ dependencies {
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)

// AI Edge SDK
implementation(libs.ai.core)

// SplashScreen
implementation(libs.splashscreen)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface ChatRepository {
suspend fun fetchChatList(): List<ChatRoom>
suspend fun fetchMessages(chatId: Int): List<Message>
fun generateDefaultChatTitle(messages: List<Message>): String?
fun generateAIChatTitle(messages: List<Message>): Flow<ApiState>
suspend fun updateChatTitle(chatRoom: ChatRoom, title: String)
suspend fun saveChat(chatRoom: ChatRoom, messages: List<Message>): ChatRoom
suspend fun deleteChats(chatRooms: List<ChatRoom>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import dev.chungjungsoo.gptmobile.data.network.AnthropicAPI
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onStart
Expand Down Expand Up @@ -180,33 +179,6 @@ class ChatRepositoryImpl @Inject constructor(

override fun generateDefaultChatTitle(messages: List<Message>): String? = messages.sortedBy { it.createdAt }.firstOrNull { it.platformType == null }?.content?.replace('\n', ' ')?.take(50)

override fun generateAIChatTitle(messages: List<Message>): Flow<ApiState> {
if (messages.isEmpty()) {
return flow { "Untitled Chat" }
}

val generationConfig = com.google.ai.edge.aicore.generationConfig {
context = appContext // required
temperature = 1f
maxOutputTokens = 25
}
val model = com.google.ai.edge.aicore.GenerativeModel(generationConfig = generationConfig)

var request = ModelConstants.CHAT_TITLE_GENERATE_PROMPT
messages.sortedBy { it.createdAt }.forEach { message ->
request += when (message.platformType) {
null -> "User: ${message.content}\n\n"
else -> "Assistant: ${message.content}\n\n"
}
}

return model.generateContentStream(request)
.map<com.google.ai.edge.aicore.GenerateContentResponse, ApiState> { response -> ApiState.Success(response.text ?: "") }
.catch { throwable -> emit(ApiState.Error("Cannot process this request at the moment.")) }
.onStart { emit(ApiState.Loading) }
.onCompletion { emit(ApiState.Done) }
}

override suspend fun updateChatTitle(chatRoom: ChatRoom, title: String) {
chatRoomDao.editChatRoom(chatRoom.copy(title = title.replace('\n', ' ').take(50)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ fun ChatScreen(
if (isChatTitleDialogOpen) {
ChatTitleDialog(
initialTitle = chatRoom.title,
aiCoreModeEnabled = canEnableAICoreMode,
aiCoreModeEnabled = false,
aiGeneratedResult = geminiNano.content,
isAICoreLoading = geminiNanoLoadingState == ChatViewModel.LoadingState.Loading,
onDefaultTitleMode = chatViewModel::generateDefaultChatTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ class ChatViewModel @Inject constructor(
viewModelScope.launch {
_geminiNanoLoadingState.update { LoadingState.Loading }
_geminiNanoMessage.update { it.copy(content = "") }
val chatFlow = chatRepository.generateAIChatTitle(_messages.value)
chatFlow.collect { chunk -> geminiNanoFlow.emit(chunk) }
}
}

Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[versions]
aicore = "0.0.1-exp01"
agp = "8.7.2"
autoLicense = "11.2.2"
kotlin = "2.0.20"
Expand Down Expand Up @@ -41,7 +40,6 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
ai-core = { group = "com.google.ai.edge.aicore", name = "aicore", version.ref = "aicore"}
auto-license-core = { group = "com.mikepenz", name = "aboutlibraries-core", version.ref = "autoLicense" }
auto-license-ui = { group = "com.mikepenz", name = "aboutlibraries-compose-m3", version.ref = "autoLicense" }
compose-markdown = { group = "com.github.jeziellago", name = "compose-markdown", version.ref = "markdown" }
Expand Down

0 comments on commit 16c4ca0

Please sign in to comment.