refactor: inline openai realtime config readers

This commit is contained in:
Peter Steinberger
2026-04-06 19:53:49 +01:00
parent 637bc8e458
commit a5b5632809
2 changed files with 4 additions and 16 deletions

View File

@@ -54,12 +54,6 @@ function normalizeProviderConfig(
};
}
function readProviderConfig(
providerConfig: RealtimeTranscriptionProviderConfig,
): OpenAIRealtimeTranscriptionProviderConfig {
return normalizeProviderConfig(providerConfig);
}
class OpenAIRealtimeTranscriptionSession implements RealtimeTranscriptionSession {
private static readonly MAX_RECONNECT_ATTEMPTS = 5;
private static readonly RECONNECT_DELAY_MS = 1000;
@@ -234,9 +228,9 @@ export function buildOpenAIRealtimeTranscriptionProvider(): RealtimeTranscriptio
autoSelectOrder: 10,
resolveConfig: ({ rawConfig }) => normalizeProviderConfig(rawConfig),
isConfigured: ({ providerConfig }) =>
Boolean(readProviderConfig(providerConfig).apiKey || process.env.OPENAI_API_KEY),
Boolean(normalizeProviderConfig(providerConfig).apiKey || process.env.OPENAI_API_KEY),
createSession: (req) => {
const config = readProviderConfig(req.providerConfig);
const config = normalizeProviderConfig(req.providerConfig);
const apiKey = config.apiKey || process.env.OPENAI_API_KEY;
if (!apiKey) {
throw new Error("OpenAI API key missing");

View File

@@ -105,12 +105,6 @@ function normalizeProviderConfig(
};
}
function readProviderConfig(
providerConfig: RealtimeVoiceProviderConfig,
): OpenAIRealtimeVoiceProviderConfig {
return normalizeProviderConfig(providerConfig);
}
function base64ToBuffer(b64: string): Buffer {
return Buffer.from(b64, "base64");
}
@@ -493,9 +487,9 @@ export function buildOpenAIRealtimeVoiceProvider(): RealtimeVoiceProviderPlugin
autoSelectOrder: 10,
resolveConfig: ({ rawConfig }) => normalizeProviderConfig(rawConfig),
isConfigured: ({ providerConfig }) =>
Boolean(readProviderConfig(providerConfig).apiKey || process.env.OPENAI_API_KEY),
Boolean(normalizeProviderConfig(providerConfig).apiKey || process.env.OPENAI_API_KEY),
createBridge: (req) => {
const config = readProviderConfig(req.providerConfig);
const config = normalizeProviderConfig(req.providerConfig);
const apiKey = config.apiKey || process.env.OPENAI_API_KEY;
if (!apiKey) {
throw new Error("OpenAI API key missing");