- {providers?.map((provider: LanguageModelProvider) => {
- const isCustom = provider.type === "custom";
+ {providers
+ ?.filter((p) => p.type !== "local")
+ .map((provider: LanguageModelProvider) => {
+ const isCustom = provider.type === "custom";
- return (
-
- handleProviderClick(provider.id)}
+ return (
+
-
- {provider.name}
- {isProviderSetup(provider.id) ? (
-
- Ready
-
- ) : (
-
- Needs Setup
-
- )}
-
-
- {provider.hasFreeTier && (
-
-
- Free tier available
-
- )}
-
-
-
- {isCustom && (
- e.stopPropagation()}
+
handleProviderClick(provider.id)}
>
-
-
-
-
-
-
-
- setProviderToDelete(provider.id)}
- >
-
- Delete Provider
-
-
-
-
- )}
-
- );
- })}
+
+ {provider.name}
+ {isProviderSetup(provider.id) ? (
+
+ Ready
+
+ ) : (
+
+ Needs Setup
+
+ )}
+
+
+ {provider.hasFreeTier && (
+
+
+ Free tier available
+
+ )}
+
+
+
+ {isCustom && (
+
e.stopPropagation()}
+ >
+
+
+
+
+
+
+
+ setProviderToDelete(provider.id)}
+ >
+
+ Delete Provider
+
+
+
+
+ )}
+
+ );
+ })}
{/* Add custom provider button */}
= {
openrouter: "OPENROUTER_API_KEY",
};
-export const PROVIDERS: Record<
+export const CLOUD_PROVIDERS: Record<
string,
{
displayName: string;
@@ -153,6 +153,23 @@ export const PROVIDERS: Record<
},
};
+const LOCAL_PROVIDERS: Record<
+ string,
+ {
+ displayName: string;
+ hasFreeTier: boolean;
+ }
+> = {
+ ollama: {
+ displayName: "Ollama",
+ hasFreeTier: true,
+ },
+ lmstudio: {
+ displayName: "LM Studio",
+ hasFreeTier: true,
+ },
+};
+
/**
* Fetches language model providers from both the database (custom) and hardcoded constants (cloud),
* merging them with custom providers taking precedence.
@@ -181,11 +198,11 @@ export async function getLanguageModelProviders(): Promise<
// Get hardcoded cloud providers
const hardcodedProviders: LanguageModelProvider[] = [];
- for (const providerKey in PROVIDERS) {
- if (Object.prototype.hasOwnProperty.call(PROVIDERS, providerKey)) {
+ for (const providerKey in CLOUD_PROVIDERS) {
+ if (Object.prototype.hasOwnProperty.call(CLOUD_PROVIDERS, providerKey)) {
// Ensure providerKey is a key of PROVIDERS
- const key = providerKey as keyof typeof PROVIDERS;
- const providerDetails = PROVIDERS[key];
+ const key = providerKey as keyof typeof CLOUD_PROVIDERS;
+ const providerDetails = CLOUD_PROVIDERS[key];
if (providerDetails) {
// Ensure providerDetails is not undefined
hardcodedProviders.push({
@@ -202,6 +219,19 @@ export async function getLanguageModelProviders(): Promise<
}
}
+ for (const providerKey in LOCAL_PROVIDERS) {
+ if (Object.prototype.hasOwnProperty.call(LOCAL_PROVIDERS, providerKey)) {
+ const key = providerKey as keyof typeof LOCAL_PROVIDERS;
+ const providerDetails = LOCAL_PROVIDERS[key];
+ hardcodedProviders.push({
+ id: key,
+ name: providerDetails.displayName,
+ hasFreeTier: providerDetails.hasFreeTier,
+ type: "local",
+ });
+ }
+ }
+
return [...hardcodedProviders, ...customProvidersMap.values()];
}