Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse files
lib/ai/provider-manager.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { createAnthropic } from '@ai-sdk/anthropic';
|
|
| 4 |
import { createOpenAI } from '@ai-sdk/openai';
|
| 5 |
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
| 6 |
|
| 7 |
-
type ProviderName = 'openai' | 'anthropic' | 'groq' | 'google';
|
| 8 |
|
| 9 |
// Client function type returned by @ai-sdk providers
|
| 10 |
export type ProviderClient =
|
|
@@ -40,6 +40,8 @@ function getEnvDefaults(provider: ProviderName): { apiKey?: string; baseURL?: st
|
|
| 40 |
return { apiKey: process.env.GROQ_API_KEY, baseURL: process.env.GROQ_BASE_URL };
|
| 41 |
case 'google':
|
| 42 |
return { apiKey: process.env.GEMINI_API_KEY, baseURL: process.env.GEMINI_BASE_URL };
|
|
|
|
|
|
|
| 43 |
default:
|
| 44 |
return {};
|
| 45 |
}
|
|
@@ -68,8 +70,11 @@ function getOrCreateClient(provider: ProviderName, apiKey?: string, baseURL?: st
|
|
| 68 |
case 'google':
|
| 69 |
client = createGoogleGenerativeAI({ apiKey: effective.apiKey || getEnvDefaults('google').apiKey, baseURL: effective.baseURL ?? getEnvDefaults('google').baseURL });
|
| 70 |
break;
|
|
|
|
|
|
|
|
|
|
| 71 |
default:
|
| 72 |
-
client =
|
| 73 |
}
|
| 74 |
|
| 75 |
clientCache.set(cacheKey, client);
|
|
@@ -111,8 +116,8 @@ export function getProviderForModel(modelId: string): ProviderResolution {
|
|
| 111 |
return { client, actualModel: modelId.replace('google/', '') };
|
| 112 |
}
|
| 113 |
|
| 114 |
-
// Default: use
|
| 115 |
-
const client = getOrCreateClient('
|
| 116 |
return { client, actualModel: modelId };
|
| 117 |
}
|
| 118 |
|
|
|
|
| 4 |
import { createOpenAI } from '@ai-sdk/openai';
|
| 5 |
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
| 6 |
|
| 7 |
+
type ProviderName = 'openai' | 'anthropic' | 'groq' | 'google' | 'helmholtz';
|
| 8 |
|
| 9 |
// Client function type returned by @ai-sdk providers
|
| 10 |
export type ProviderClient =
|
|
|
|
| 40 |
return { apiKey: process.env.GROQ_API_KEY, baseURL: process.env.GROQ_BASE_URL };
|
| 41 |
case 'google':
|
| 42 |
return { apiKey: process.env.GEMINI_API_KEY, baseURL: process.env.GEMINI_BASE_URL };
|
| 43 |
+
case 'helmholtz':
|
| 44 |
+
return { apiKey: process.env.BLABLADOR_API_KEY, baseURL: 'https://api.helmholtz-blablador.fz-juelich.de/v1' };
|
| 45 |
default:
|
| 46 |
return {};
|
| 47 |
}
|
|
|
|
| 70 |
case 'google':
|
| 71 |
client = createGoogleGenerativeAI({ apiKey: effective.apiKey || getEnvDefaults('google').apiKey, baseURL: effective.baseURL ?? getEnvDefaults('google').baseURL });
|
| 72 |
break;
|
| 73 |
+
case 'helmholtz':
|
| 74 |
+
client = createOpenAI({ apiKey: effective.apiKey || getEnvDefaults('helmholtz').apiKey, baseURL: effective.baseURL ?? getEnvDefaults('helmholtz').baseURL });
|
| 75 |
+
break;
|
| 76 |
default:
|
| 77 |
+
client = createOpenAI({ apiKey: effective.apiKey || getEnvDefaults('helmholtz').apiKey, baseURL: effective.baseURL ?? getEnvDefaults('helmholtz').baseURL });
|
| 78 |
}
|
| 79 |
|
| 80 |
clientCache.set(cacheKey, client);
|
|
|
|
| 116 |
return { client, actualModel: modelId.replace('google/', '') };
|
| 117 |
}
|
| 118 |
|
| 119 |
+
// Default: use Helmholtz with modelId as-is
|
| 120 |
+
const client = getOrCreateClient('helmholtz');
|
| 121 |
return { client, actualModel: modelId };
|
| 122 |
}
|
| 123 |
|