Skip to content

Commit

Permalink
Support for vision bot profile (and switch to Anthropic when it's sel…
Browse files Browse the repository at this point in the history
…ected)
  • Loading branch information
marcus-daily committed Aug 30, 2024
1 parent ed449a9 commit 28adccf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@ object ConfigConstants {
)
}

val llmProviders = NamedOptionList<LLMProvider>(listOf(Anthropic, Together), default = Together)

val ttsProviders = NamedOptionList<TTSProvider>(listOf(Cartesia))

val botProfiles = NamedOptionList(
listOf(
"Voice only" isProfile "voice_2024_08",
"Voice and vision" isProfile "vision_2024_08"
BotProfile(
name = "Voice only",
id = "voice_2024_08",
llmProviders = NamedOptionList(listOf(Anthropic, Together), default = Together),
ttsProviders = NamedOptionList(listOf(Cartesia))
),
BotProfile(
name = "Voice and vision",
id = "vision_2024_08",
llmProviders = NamedOptionList(listOf(Anthropic)),
ttsProviders = NamedOptionList(listOf(Cartesia))
),
)
)
}
Expand Down Expand Up @@ -87,6 +93,8 @@ interface LLMProvider : NamedOption {
data class BotProfile(
override val name: String,
override val id: String,
val llmProviders: NamedOptionList<LLMProvider>,
val ttsProviders: NamedOptionList<TTSProvider>,
) : NamedOption

data class LLMOptionModel(
Expand All @@ -100,5 +108,4 @@ data class TTSOptionVoice(
) : NamedOption

private infix fun String.isModel(id: String) = LLMOptionModel(name = this, id = id)
private infix fun String.isVoice(id: String) = TTSOptionVoice(name = this, id = id)
private infix fun String.isProfile(id: String) = BotProfile(name = this, id = id)
private infix fun String.isVoice(id: String) = TTSOptionVoice(name = this, id = id)
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,16 @@ data class LastInitOptions(
)
}

fun inflateInit() = VoiceClientManager.InitOptions(
botProfile = ConfigConstants.botProfiles.byIdOrDefault(botProfile),
ttsProvider = ConfigConstants.ttsProviders.byIdOrDefault(ttsProvider),
llmProvider = ConfigConstants.llmProviders.byIdOrDefault(llmProvider),
)
fun inflateInit(): VoiceClientManager.InitOptions {

val botProfile = ConfigConstants.botProfiles.byIdOrDefault(botProfile)

return VoiceClientManager.InitOptions(
botProfile = botProfile,
ttsProvider = botProfile.ttsProviders.byIdOrDefault(ttsProvider),
llmProvider = botProfile.llmProviders.byIdOrDefault(llmProvider),
)
}

fun inflateRuntime(initOptions: VoiceClientManager.InitOptions) = VoiceClientManager.RuntimeOptions(
ttsVoice = initOptions.ttsProvider.voices.byIdOrDefault(ttsVoice),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ class VoiceClientManager(private val context: Context) {
val llmProvider: LLMProvider,
) {
companion object {
fun default() = InitOptions(
botProfile = ConfigConstants.botProfiles.default,
ttsProvider = ConfigConstants.ttsProviders.default,
llmProvider = ConfigConstants.llmProviders.default,
)
fun default() = ConfigConstants.botProfiles.default.let { botProfile ->
InitOptions(
botProfile = botProfile,
ttsProvider = botProfile.ttsProviders.default,
llmProvider = botProfile.llmProviders.default,
)
}
}
}

Expand All @@ -57,10 +59,12 @@ class VoiceClientManager(private val context: Context) {
val llmModel: LLMOptionModel,
) {
companion object {
fun default() = RuntimeOptions(
ttsVoice = ConfigConstants.ttsProviders.default.voices.default,
llmModel = ConfigConstants.llmProviders.default.models.default,
)
fun default() = ConfigConstants.botProfiles.default.let { botProfile ->
RuntimeOptions(
ttsVoice = botProfile.ttsProviders.default.voices.default,
llmModel = botProfile.llmProviders.default.models.default,
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ fun VoiceClientSettingsPanel(
.verticalScroll(scrollState)
.padding(horizontal = 20.dp)
) {
Header("Bot Configuration")

RadioGroup(
label = "Bot Profile",
onSelect = { updatePref { copy(botProfile = it.id) } },
Expand All @@ -69,7 +71,7 @@ fun VoiceClientSettingsPanel(
label = "Service",
onSelect = { updatePref { copy(ttsProvider = it.id) } },
selected = initOptions.ttsProvider,
options = ConfigConstants.ttsProviders,
options = initOptions.botProfile.ttsProviders,
)

RadioGroup(
Expand All @@ -85,7 +87,7 @@ fun VoiceClientSettingsPanel(
label = "Service",
onSelect = { updatePref { copy(llmProvider = it.id) } },
selected = initOptions.llmProvider,
options = ConfigConstants.llmProviders
options = initOptions.botProfile.llmProviders
)

RadioGroup(
Expand All @@ -102,7 +104,7 @@ fun VoiceClientSettingsPanel(
@Composable
private fun ColumnScope.Header(text: String) {

Spacer(Modifier.height(30.dp))
Spacer(Modifier.height(42.dp))

Text(
text = text,
Expand All @@ -119,7 +121,7 @@ private fun <E : NamedOption> ColumnScope.RadioGroup(
selected: E,
options: NamedOptionList<E>,
) {
Spacer(Modifier.height(20.dp))
Spacer(Modifier.height(26.dp))

Text(
text = label,
Expand Down

0 comments on commit 28adccf

Please sign in to comment.