@@ -66,15 +66,14 @@ const PROVIDERS = {
6666 'whisper' : {
6767 name : 'Whisper (Local)' ,
6868 handler : ( ) => {
69- // Only load in main process
69+ // This needs to remain a function due to its conditional logic for renderer/ main process
7070 if ( typeof window === 'undefined' ) {
7171 return require ( "./providers/whisper" ) ;
7272 }
73- // Return dummy for renderer
73+ // Return a dummy object for the renderer process
7474 return {
75+ validateApiKey : async ( ) => ( { success : true } ) , // Mock validate for renderer
7576 createSTT : ( ) => { throw new Error ( 'Whisper STT is only available in main process' ) ; } ,
76- createLLM : ( ) => { throw new Error ( 'Whisper does not support LLM' ) ; } ,
77- createStreamingLLM : ( ) => { throw new Error ( 'Whisper does not support LLM' ) ; }
7877 } ;
7978 } ,
8079 llmModels : [ ] ,
@@ -130,6 +129,32 @@ function createStreamingLLM(provider, opts) {
130129 return handler . createStreamingLLM ( opts ) ;
131130}
132131
132+ function getProviderClass ( providerId ) {
133+ const providerConfig = PROVIDERS [ providerId ] ;
134+ if ( ! providerConfig ) return null ;
135+
136+ // Handle special cases for glass providers
137+ let actualProviderId = providerId ;
138+ if ( providerId === 'openai-glass' ) {
139+ actualProviderId = 'openai' ;
140+ }
141+
142+ // The handler function returns the module, from which we get the class.
143+ const module = providerConfig . handler ( ) ;
144+
145+ // Map provider IDs to their actual exported class names
146+ const classNameMap = {
147+ 'openai' : 'OpenAIProvider' ,
148+ 'anthropic' : 'AnthropicProvider' ,
149+ 'gemini' : 'GeminiProvider' ,
150+ 'ollama' : 'OllamaProvider' ,
151+ 'whisper' : 'WhisperProvider'
152+ } ;
153+
154+ const className = classNameMap [ actualProviderId ] ;
155+ return className ? module [ className ] : null ;
156+ }
157+
133158function getAvailableProviders ( ) {
134159 const stt = [ ] ;
135160 const llm = [ ] ;
@@ -145,5 +170,6 @@ module.exports = {
145170 createSTT,
146171 createLLM,
147172 createStreamingLLM,
173+ getProviderClass,
148174 getAvailableProviders,
149175} ;
0 commit comments