Skip to content

Commit

Permalink
We back)
Browse files Browse the repository at this point in the history
  • Loading branch information
saharulik committed Mar 31, 2024
1 parent caa764d commit 888d1cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import ai.elimu.soga.GenerativeViewModelFactory
import ai.elimu.soga.R
import ai.elimu.soga.ui.theme.Gold80
import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
Expand All @@ -58,12 +59,15 @@ import androidx.compose.ui.res.painterResource
internal fun ChatRoute(
chatViewModel: ChatViewModel = viewModel(factory = GenerativeViewModelFactory)
) {
Log.i("Mytag","ChatRoute")
val chatUiState by chatViewModel.uiState.collectAsState()
val listState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()


Scaffold(
topBar = {
// backgroundColor="transparent"
LinearProgressIndicator(
progress = chatViewModel.pointCounter,
modifier = Modifier.height(30.dp).fillMaxWidth().padding(10.dp,0.dp),
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatUiState.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ai.elimu.soga.feature.chat

import android.util.Log
import androidx.compose.runtime.toMutableStateList

class ChatUiState(
Expand All @@ -18,6 +19,7 @@ class ChatUiState(
val newMessage = lastMessage.apply { isPending = false }
_messages.removeLast()
_messages.add(newMessage)
Log.i("Mytag","ChatUiState")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ai.elimu.soga.feature.chat

import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.ai.client.generativeai.GenerativeModel
Expand Down Expand Up @@ -54,6 +55,8 @@ class ChatViewModel(

_uiState.value.replaceLastPendingMessage()

Log.i("NumberGenerated","Number 2")

response.text?.let { modelResponse ->
_uiState.value.addMessage(
ChatMessage(
Expand All @@ -62,7 +65,8 @@ class ChatViewModel(
isPending = false
)
)
if (modelResponse.contains("\uD83C\uDF1F") || modelResponse.contains("correct") || modelResponse.contains("Correct")) { pointCounter += 0.1f }
if (modelResponse.contains("\uD83C\uDF1F") || modelResponse.contains("Nya") || modelResponse.contains("Correct") || modelResponse.contains("that's right") || modelResponse.contains("fantastic")) { pointCounter += 0.1f
Log.i("Mytag","viewModelScope") }
}
} catch (e: Exception) {
_uiState.value.replaceLastPendingMessage()
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ dependencyResolutionManagement {
}
}

rootProject.name = "Soga"
include(":app")

0 comments on commit 888d1cf

Please sign in to comment.