@@ -102,7 +102,9 @@ export function ProviderSettingsGrid() {
|
|||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<h2 className="text-2xl font-bold mb-6">AI Providers</h2>
|
<h2 className="text-2xl font-bold mb-6">AI Providers</h2>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
{providers?.map((provider: LanguageModelProvider) => {
|
{providers
|
||||||
|
?.filter((p) => p.type !== "local")
|
||||||
|
.map((provider: LanguageModelProvider) => {
|
||||||
const isCustom = provider.type === "custom";
|
const isCustom = provider.type === "custom";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export const PROVIDER_TO_ENV_VAR: Record<string, string> = {
|
|||||||
openrouter: "OPENROUTER_API_KEY",
|
openrouter: "OPENROUTER_API_KEY",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PROVIDERS: Record<
|
export const CLOUD_PROVIDERS: Record<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
displayName: 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),
|
* Fetches language model providers from both the database (custom) and hardcoded constants (cloud),
|
||||||
* merging them with custom providers taking precedence.
|
* merging them with custom providers taking precedence.
|
||||||
@@ -181,11 +198,11 @@ export async function getLanguageModelProviders(): Promise<
|
|||||||
|
|
||||||
// Get hardcoded cloud providers
|
// Get hardcoded cloud providers
|
||||||
const hardcodedProviders: LanguageModelProvider[] = [];
|
const hardcodedProviders: LanguageModelProvider[] = [];
|
||||||
for (const providerKey in PROVIDERS) {
|
for (const providerKey in CLOUD_PROVIDERS) {
|
||||||
if (Object.prototype.hasOwnProperty.call(PROVIDERS, providerKey)) {
|
if (Object.prototype.hasOwnProperty.call(CLOUD_PROVIDERS, providerKey)) {
|
||||||
// Ensure providerKey is a key of PROVIDERS
|
// Ensure providerKey is a key of PROVIDERS
|
||||||
const key = providerKey as keyof typeof PROVIDERS;
|
const key = providerKey as keyof typeof CLOUD_PROVIDERS;
|
||||||
const providerDetails = PROVIDERS[key];
|
const providerDetails = CLOUD_PROVIDERS[key];
|
||||||
if (providerDetails) {
|
if (providerDetails) {
|
||||||
// Ensure providerDetails is not undefined
|
// Ensure providerDetails is not undefined
|
||||||
hardcodedProviders.push({
|
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()];
|
return [...hardcodedProviders, ...customProvidersMap.values()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user