-
-
Save skydoves/2c58561dd92a0c8408506d804ec595cc to your computer and use it in GitHub Desktop.
chat_viewmodel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@HiltViewModel | |
class ChatViewModel @Inject constructor( | |
repository: ChatRepository, | |
chatClient: ChatClient, | |
) : ViewModel() { | |
private suspend fun sendTextMessage(text: String): String? { | |
val response = generativeChat.sendMessage(text) | |
val responseText = response.text | |
if (responseText != null) { | |
channelClient.sendMessage( | |
message = Message( | |
id = UUID.randomUUID().toString(), | |
cid = channelClient.cid, | |
text = responseText, | |
extraData = mutableMapOf(STREAM_CHANNEL_GEMINI_FLAG to true) | |
) | |
).await() | |
} | |
return responseText | |
} | |
.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment