Skip to content

Commit 815ce36

Browse files
lockrush-devautofix-ci[bot]nekomeowww
authored
fix(stage-*): OpenAI Compatible Speech and Hearing modules activation (#947)
--------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Neko <neko@ayaka.moe>
1 parent 153eb95 commit 815ce36

File tree

19 files changed

+1061
-390
lines changed

19 files changed

+1061
-390
lines changed

.github/actions/setup-swiftlint/action.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,28 @@ runs:
4444
shell: bash
4545
run: |
4646
if [[ "${{ inputs.version }}" == "latest" ]]; then
47-
VERSION=$(curl -s https://api.github.com/repos/realm/SwiftLint/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
48-
if [[ -z "$VERSION" ]]; then
49-
echo "Error: Failed to get latest version"
47+
# Fetch the latest release tag using a more robust method
48+
API_RESPONSE=$(curl -s https://api.github.com/repos/realm/SwiftLint/releases/latest)
49+
# Try using jq if available (most GitHub Actions runners have it)
50+
if command -v jq >/dev/null 2>&1; then
51+
VERSION=$(echo "$API_RESPONSE" | jq -r '.tag_name // empty')
52+
else
53+
# Fallback: parse JSON manually with sed, being very specific about the tag_name field
54+
VERSION=$(echo "$API_RESPONSE" | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
55+
fi
56+
57+
# Validate the version looks correct (should contain version numbers)
58+
if [[ -z "$VERSION" ]] || [[ "$VERSION" == "null" ]] || [[ ! "$VERSION" =~ ^[0-9] ]]; then
59+
echo "Error: Failed to get latest version or got invalid version: '$VERSION'"
60+
echo "API Response (first 50 lines):"
61+
echo "$API_RESPONSE" | head -50
5062
exit 1
5163
fi
5264
echo "Latest version: $VERSION"
5365
else
5466
VERSION="${{ inputs.version }}"
55-
if [[ ! "$VERSION" =~ ^v ]]; then
56-
VERSION="v$VERSION"
57-
fi
67+
# Remove 'v' prefix if user provided it, since SwiftLint tags don't use it
68+
VERSION="${VERSION#v}"
5869
echo "Using specified version: $VERSION"
5970
fi
6071
echo "version=$VERSION" >> $GITHUB_OUTPUT

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ plugins-local
121121
plugins-development
122122

123123
#ia
124-
GEMINI.md
124+
GEMINI.md

packages/stage-pages/src/pages/settings/modules/hearing.vue

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { useAudioContext } from '@proj-airi/stage-ui/stores/audio'
88
import { useHearingSpeechInputPipeline, useHearingStore } from '@proj-airi/stage-ui/stores/modules/hearing'
99
import { useProvidersStore } from '@proj-airi/stage-ui/stores/providers'
1010
import { useSettingsAudioDevice } from '@proj-airi/stage-ui/stores/settings'
11-
import { Button, FieldCheckbox, FieldRange, FieldSelect } from '@proj-airi/ui'
11+
import { Button, FieldCheckbox, FieldInput, FieldRange, FieldSelect } from '@proj-airi/ui'
1212
import { until } from '@vueuse/core'
1313
import { storeToRefs } from 'pinia'
14-
import { computed, onUnmounted, ref, watch } from 'vue'
14+
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
1515
import { useI18n } from 'vue-i18n'
1616
1717
const { t } = useI18n()
@@ -222,8 +222,29 @@ const speakingIndicatorClass = computed(() => {
222222
}
223223
})
224224
225-
function updateCustomModelName(value: string) {
226-
activeCustomModelName.value = value
225+
function updateCustomModelName(value: string | undefined) {
226+
const modelValue = value || ''
227+
activeCustomModelName.value = modelValue
228+
activeTranscriptionModel.value = modelValue
229+
}
230+
231+
// Sync OpenAI Compatible model from provider config
232+
function syncOpenAICompatibleSettings() {
233+
if (activeTranscriptionProvider.value !== 'openai-compatible-audio-transcription')
234+
return
235+
236+
const providerConfig = providersStore.getProviderConfig(activeTranscriptionProvider.value)
237+
// Always sync model from provider config (override any existing value from previous provider)
238+
if (providerConfig?.model) {
239+
activeTranscriptionModel.value = providerConfig.model as string
240+
updateCustomModelName(providerConfig.model as string)
241+
}
242+
else {
243+
// If no model in provider config, use default
244+
const defaultModel = 'whisper-1'
245+
activeTranscriptionModel.value = defaultModel
246+
updateCustomModelName(defaultModel)
247+
}
227248
}
228249
229250
onStopRecord(async (recording) => {
@@ -427,6 +448,7 @@ watch(activeTranscriptionProvider, async (provider) => {
427448
return
428449
429450
await hearingStore.loadModelsForProvider(provider)
451+
syncOpenAICompatibleSettings()
430452
431453
// Auto-select first model for Web Speech API if no model is selected
432454
if (provider === 'browser-web-speech-api' && !activeTranscriptionModel.value) {
@@ -438,6 +460,11 @@ watch(activeTranscriptionProvider, async (provider) => {
438460
}
439461
}, { immediate: true })
440462
463+
onMounted(async () => {
464+
// Audio devices are loaded on demand when user requests them
465+
syncOpenAICompatibleSettings()
466+
})
467+
441468
onUnmounted(() => {
442469
stopSTTTest()
443470
stopAudioMonitoring()
@@ -537,19 +564,25 @@ onUnmounted(() => {
537564
</div>
538565

539566
<!-- Model selection section -->
540-
<div v-if="activeTranscriptionProvider && supportsModelListing">
567+
<div v-if="activeTranscriptionProvider">
541568
<div flex="~ col gap-4">
542569
<div>
543570
<h2 class="text-lg md:text-2xl">
544571
{{ t('settings.pages.modules.consciousness.sections.section.provider-model-selection.title') }}
545572
</h2>
546573
<div text="neutral-400 dark:neutral-400">
547-
<span>{{ t('settings.pages.modules.consciousness.sections.section.provider-model-selection.subtitle') }}</span>
574+
<!-- Show different description based on whether provider supports model listing and has models -->
575+
<span v-if="supportsModelListing && providerModels.length > 0">
576+
{{ t('settings.pages.modules.consciousness.sections.section.provider-model-selection.subtitle') }}
577+
</span>
578+
<span v-else>
579+
Enter the transcription model to use (e.g., 'whisper-1', 'gpt-4o-transcribe')
580+
</span>
548581
</div>
549582
</div>
550583

551584
<!-- Loading state -->
552-
<div v-if="isLoadingActiveProviderModels" class="flex items-center justify-center py-4">
585+
<div v-if="isLoadingActiveProviderModels && supportsModelListing" class="flex items-center justify-center py-4">
553586
<div class="mr-2 animate-spin">
554587
<div i-solar:spinner-line-duotone text-xl />
555588
</div>
@@ -558,14 +591,26 @@ onUnmounted(() => {
558591

559592
<!-- Error state -->
560593
<ErrorContainer
561-
v-else-if="activeProviderModelError"
594+
v-else-if="activeProviderModelError && supportsModelListing"
562595
:title="t('settings.pages.modules.consciousness.sections.section.provider-model-selection.error')"
563596
:error="activeProviderModelError"
564597
/>
565598

566-
<!-- No models available -->
599+
<!-- Manual input for providers without model listing or when no models are available -->
600+
<div
601+
v-else-if="!supportsModelListing || (activeTranscriptionProvider === 'openai-compatible-audio-transcription' && providerModels.length === 0 && !isLoadingActiveProviderModels)"
602+
class="mt-2"
603+
>
604+
<FieldInput
605+
:model-value="activeTranscriptionModel || activeCustomModelName || ''"
606+
placeholder="whisper-1"
607+
@update:model-value="updateCustomModelName"
608+
/>
609+
</div>
610+
611+
<!-- No models available (for other providers with model listing but no models) -->
567612
<Alert
568-
v-else-if="providerModels.length === 0 && !isLoadingActiveProviderModels"
613+
v-else-if="providerModels.length === 0 && !isLoadingActiveProviderModels && supportsModelListing"
569614
type="warning"
570615
>
571616
<template #title>
@@ -576,8 +621,8 @@ onUnmounted(() => {
576621
</template>
577622
</Alert>
578623

579-
<!-- Using the new RadioCardManySelect component -->
580-
<template v-else-if="providerModels.length > 0">
624+
<!-- Using the new RadioCardManySelect component for providers with models -->
625+
<template v-else-if="providerModels.length > 0 && supportsModelListing">
581626
<RadioCardManySelect
582627
v-model="activeTranscriptionModel"
583628
v-model:search-query="transcriptionModelSearchQuery"

0 commit comments

Comments
 (0)