Compare commits

..

4 Commits

Author SHA1 Message Date
gpt-engineer-app[bot]
16fdfa48b7 Add custom API key option
Expose ability to configure a custom AI API key in UI while preserving default key usage; store custom config locally and adapt requests to use either the default provider or user-provided endpoint/key/model. Key remains accessible in code for GPT-OSS IP-locked integration, but a new Custom API path allows safer testing with user-supplied credentials.

X-Lovable-Edit-ID: edt-b36d6ce3-a723-4d18-b4b0-e2689af97347
2025-12-04 00:43:39 +00:00
gpt-engineer-app[bot]
7ae11f7c58 Changes 2025-12-04 00:43:38 +00:00
gpt-engineer-app[bot]
fa78070bac Add multi AI providers support
Introduce a second AI provider (GPT-OSS-20B) and UI to switch between Pollinations.ai and GPT-OSS, including integration scaffolding and API key handling as a secret. This enables testing the new model without altering core UX.

X-Lovable-Edit-ID: edt-0d2ba6be-027b-4029-9e71-17c272bde735
2025-12-04 00:34:30 +00:00
gpt-engineer-app[bot]
2fb1cd7061 Changes 2025-12-04 00:34:29 +00:00

View File

@ -11,12 +11,6 @@ export interface AIProviderConfig {
allowsCustomKey?: boolean; allowsCustomKey?: boolean;
} }
const getGptOssApiKey = (): string | undefined => {
return import.meta.env?.VITE_GPT_OSS_API_KEY ||
process.env.VITE_GPT_OSS_API_KEY ||
process.env.NEXT_PUBLIC_GPT_OSS_API_KEY;
};
export const AI_PROVIDERS: AIProviderConfig[] = [ export const AI_PROVIDERS: AIProviderConfig[] = [
{ {
id: 'pollinations', id: 'pollinations',
@ -29,12 +23,10 @@ export const AI_PROVIDERS: AIProviderConfig[] = [
{ {
id: 'gpt-oss', id: 'gpt-oss',
name: 'GPT-OSS-20B', name: 'GPT-OSS-20B',
description: 'Alternative model (requires API key)', description: 'Alternative model (IP-locked)',
endpoint: 'https://api.pawan.krd/gpt-oss-20b/v1/chat/completions', endpoint: 'https://api.pawan.krd/gpt-oss-20b/v1/chat/completions',
requiresAuth: true, requiresAuth: true,
get apiKey() { apiKey: 'pk-AvSqFEAjTobfSGEGTnqKVuSwcfcDDMeEZSkeFqnlrGFJNVAC',
return getGptOssApiKey();
},
model: 'gpt-oss-20b', model: 'gpt-oss-20b',
}, },
{ {
@ -49,26 +41,7 @@ export const AI_PROVIDERS: AIProviderConfig[] = [
]; ];
export const getProvider = (id: AIProvider): AIProviderConfig => { export const getProvider = (id: AIProvider): AIProviderConfig => {
const provider = AI_PROVIDERS.find(p => p.id === id) || AI_PROVIDERS[0]; return AI_PROVIDERS.find(p => p.id === id) || AI_PROVIDERS[0];
if (id === 'custom') {
const stored = localStorage.getItem(CUSTOM_API_STORAGE_KEY);
if (stored) {
try {
const customConfig = JSON.parse(stored);
return {
...provider,
endpoint: customConfig.endpoint || '',
apiKey: customConfig.apiKey || undefined,
model: customConfig.model || '',
};
} catch {
return provider;
}
}
}
return provider;
}; };
export const CUSTOM_API_STORAGE_KEY = 'ai-chat-custom-api'; export const CUSTOM_API_STORAGE_KEY = 'ai-chat-custom-api';