59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import type { ProviderConfiguration } from '../configurations/provider'
|
|
|
|
/** Configuration for an OpenAI-compatible Provider selected by one case. */
|
|
export interface OpenAIProviderOptions {
|
|
apiKey: string
|
|
baseUrl: string
|
|
model: string
|
|
provider: string
|
|
}
|
|
|
|
/** Configuration for an OpenAI-compatible speech Provider selected by one case. */
|
|
export interface OpenAISpeechProviderOptions extends OpenAIProviderOptions {
|
|
voice: string
|
|
}
|
|
|
|
/** Creates an OpenAI-compatible ASR Provider configuration. */
|
|
export function openaiAsr(options: OpenAIProviderOptions): ProviderConfiguration {
|
|
return {
|
|
config: {
|
|
apiKey: options.apiKey,
|
|
baseUrl: options.baseUrl,
|
|
},
|
|
definitionId: options.provider,
|
|
id: options.provider,
|
|
model: options.model,
|
|
}
|
|
}
|
|
|
|
/** Creates an OpenAI-compatible LLM Provider configuration. */
|
|
export function openaiLlm(options: OpenAIProviderOptions): ProviderConfiguration {
|
|
return {
|
|
config: {
|
|
apiKey: options.apiKey,
|
|
baseUrl: options.baseUrl,
|
|
},
|
|
definitionId: options.provider,
|
|
id: options.provider,
|
|
model: options.model,
|
|
}
|
|
}
|
|
|
|
/** Creates an OpenAI-compatible TTS Provider configuration. */
|
|
export function openaiTts(options: OpenAISpeechProviderOptions): { provider: ProviderConfiguration, voice: string } {
|
|
return {
|
|
provider: {
|
|
config: {
|
|
apiKey: options.apiKey,
|
|
baseUrl: options.baseUrl,
|
|
model: options.model,
|
|
voice: options.voice,
|
|
},
|
|
definitionId: options.provider,
|
|
id: options.provider,
|
|
model: options.model,
|
|
},
|
|
voice: options.voice,
|
|
}
|
|
}
|