@@ -7,7 +7,10 @@ import {
|
7 | 7 | type RealtimeTranscriptionSessionCreateRequest, |
8 | 8 | type RealtimeTranscriptionWebSocketTransport, |
9 | 9 | } from "openclaw/plugin-sdk/realtime-transcription"; |
10 | | -import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input"; |
| 10 | +import { |
| 11 | +normalizeResolvedSecretInputString, |
| 12 | +normalizeSecretInput, |
| 13 | +} from "openclaw/plugin-sdk/secret-input"; |
11 | 14 | import { |
12 | 15 | asOptionalRecord as readRecord, |
13 | 16 | normalizeOptionalString, |
@@ -125,10 +128,7 @@ function normalizeProviderConfig(
|
125 | 128 | ): MistralRealtimeTranscriptionProviderConfig { |
126 | 129 | const raw = readNestedMistralConfig(config); |
127 | 130 | return { |
128 | | -apiKey: normalizeResolvedSecretInputString({ |
129 | | -value: raw.apiKey, |
130 | | -path: "plugins.entries.voice-call.config.streaming.providers.mistral.apiKey", |
131 | | -}), |
| 131 | +apiKey: normalizeMistralApiKey(raw.apiKey), |
132 | 132 | baseUrl: normalizeOptionalString(raw.baseUrl), |
133 | 133 | model: normalizeOptionalString(raw.model ?? raw.sttModel), |
134 | 134 | sampleRate: readFiniteNumber(raw.sampleRate ?? raw.sample_rate), |
@@ -139,6 +139,14 @@ function normalizeProviderConfig(
|
139 | 139 | }; |
140 | 140 | } |
141 | 141 | |
| 142 | +function normalizeMistralApiKey(value: unknown): string | undefined { |
| 143 | +const resolved = normalizeResolvedSecretInputString({ |
| 144 | + value, |
| 145 | +path: "plugins.entries.voice-call.config.streaming.providers.mistral.apiKey", |
| 146 | +}); |
| 147 | +return normalizeSecretInput(resolved) || undefined; |
| 148 | +} |
| 149 | + |
142 | 150 | function readErrorDetail(event: MistralRealtimeTranscriptionEvent): string { |
143 | 151 | const message = event.error?.message; |
144 | 152 | if (typeof message === "string") { |
@@ -241,10 +249,13 @@ export function buildMistralRealtimeTranscriptionProvider(): RealtimeTranscripti
|
241 | 249 | autoSelectOrder: 45, |
242 | 250 | resolveConfig: ({ rawConfig }) => normalizeProviderConfig(rawConfig), |
243 | 251 | isConfigured: ({ providerConfig }) => |
244 | | -Boolean(normalizeProviderConfig(providerConfig).apiKey || process.env.MISTRAL_API_KEY), |
| 252 | +Boolean( |
| 253 | +normalizeProviderConfig(providerConfig).apiKey || |
| 254 | +normalizeMistralApiKey(process.env.MISTRAL_API_KEY), |
| 255 | +), |
245 | 256 | createSession: (req) => { |
246 | 257 | const config = normalizeProviderConfig(req.providerConfig); |
247 | | -const apiKey = config.apiKey || process.env.MISTRAL_API_KEY; |
| 258 | +const apiKey = config.apiKey || normalizeMistralApiKey(process.env.MISTRAL_API_KEY); |
248 | 259 | if (!apiKey) { |
249 | 260 | throw new Error("Mistral API key missing"); |
250 | 261 | } |
|