mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Support proxying AI provider traffic
This commit is contained in:
13 files changed
+126
-30
No files matched your search
@@ -13,6 +13,7 @@ import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { createAIClient } from '@/lib/ai-client';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import { AIProvider } from '@/contexts/AISettingsContext';
|
||||
|
||||
interface CreditsDialogProps {
|
||||
@@ -183,6 +184,7 @@ function LightningPayment({ invoice, amount, onClose }: LightningPaymentProps) {
|
||||
|
||||
export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogProps) {
|
||||
const { user } = useCurrentUser();
|
||||
const { config } = useAppContext();
|
||||
const { toast } = useToast();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -195,7 +197,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
const { data: payments, isLoading: isLoadingPayments } = useQuery({
|
||||
queryKey: ['ai-payments', provider.nostr ? user?.pubkey ?? '' : '', provider.id],
|
||||
queryFn: async (): Promise<Payment[]> => {
|
||||
const ai = createAIClient(provider, user);
|
||||
const ai = createAIClient(provider, user, config.corsProxy);
|
||||
const data = await ai.get('/credits/payments?limit=50') as PaymentsResponse;
|
||||
return data.data;
|
||||
},
|
||||
@@ -207,7 +209,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
// Mutation for adding credits
|
||||
const addCreditsMutation = useMutation({
|
||||
mutationFn: async (request: AddCreditsRequest): Promise<Payment> => {
|
||||
const ai = createAIClient(provider, user);
|
||||
const ai = createAIClient(provider, user, config.corsProxy);
|
||||
return await ai.post('/credits/add', {
|
||||
body: request,
|
||||
}) as Payment;
|
||||
@@ -248,7 +250,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
// Mutation for checking payment status
|
||||
const checkPaymentMutation = useMutation({
|
||||
mutationFn: async (paymentId: string): Promise<Payment> => {
|
||||
const ai = createAIClient(provider, user);
|
||||
const ai = createAIClient(provider, user, config.corsProxy);
|
||||
return await ai.get(`/credits/payments/${paymentId}`) as Payment;
|
||||
},
|
||||
onMutate: async (paymentId: string) => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useFS } from '@/hooks/useFS';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { useProviderModels } from '@/hooks/useProviderModels';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
|
||||
interface SessionManagerProviderProps {
|
||||
children: ReactNode;
|
||||
@@ -18,12 +19,13 @@ export function SessionManagerProvider({ children }: SessionManagerProviderProps
|
||||
const { settings } = useAISettings();
|
||||
const { models } = useProviderModels();
|
||||
const { user, metadata } = useCurrentUser();
|
||||
const { config } = useAppContext();
|
||||
|
||||
const sessionManager = useMemo(() => {
|
||||
const getProviderModels = () => models;
|
||||
const getCurrentUser = () => ({ user, metadata });
|
||||
return new SessionManager(fs, settings, getProviderModels, getCurrentUser);
|
||||
}, [fs, settings, models, user, metadata]);
|
||||
return new SessionManager(fs, settings, getProviderModels, getCurrentUser, config.corsProxy);
|
||||
}, [fs, settings, models, user, metadata, config.corsProxy]);
|
||||
|
||||
// Cleanup on unmount
|
||||
useEffect(() => {
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface AIProvider {
|
||||
baseURL: string;
|
||||
apiKey?: string;
|
||||
nostr?: boolean;
|
||||
proxy?: boolean;
|
||||
}
|
||||
|
||||
export interface AISettings {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { z } from 'zod';
|
||||
import { createAIClient } from '@/lib/ai-client';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import { AIProvider } from '@/contexts/AISettingsContext';
|
||||
|
||||
const creditsResponseSchema = z.object({
|
||||
@@ -18,12 +19,13 @@ export interface CreditsResponse {
|
||||
/** Custom hook to fetch AI provider credits */
|
||||
export function useAICredits(provider: AIProvider) {
|
||||
const { user } = useCurrentUser();
|
||||
const { config } = useAppContext();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['ai-credits', provider.nostr ? user?.pubkey ?? '' : '', provider.id],
|
||||
queryFn: async (): Promise<CreditsResponse> => {
|
||||
try {
|
||||
const ai = createAIClient(provider, user);
|
||||
const ai = createAIClient(provider, user, config.corsProxy);
|
||||
const data = await ai.get('/credits');
|
||||
return creditsResponseSchema.parse(data);
|
||||
} catch (error) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { renderHook, waitFor } from '@testing-library/react';
|
||||
import { useAIProjectId } from './useAIProjectId';
|
||||
import { useAISettings } from './useAISettings';
|
||||
import { useCurrentUser } from './useCurrentUser';
|
||||
import { useAppContext } from './useAppContext';
|
||||
import { useProjectsManager } from './useProjectsManager';
|
||||
import { createAIClient } from '@/lib/ai-client';
|
||||
import { parseProviderModel } from '@/lib/parseProviderModel';
|
||||
@@ -11,6 +12,7 @@ import type { ProjectsManager } from '@/lib/ProjectsManager';
|
||||
// Mock the hooks and dependencies
|
||||
vi.mock('./useAISettings');
|
||||
vi.mock('./useCurrentUser');
|
||||
vi.mock('./useAppContext');
|
||||
vi.mock('./useProjectsManager');
|
||||
vi.mock('@/lib/ai-client');
|
||||
vi.mock('@/lib/parseProviderModel');
|
||||
@@ -18,6 +20,7 @@ vi.mock('@/lib/parseProviderModel');
|
||||
describe('useAIProjectId', () => {
|
||||
const mockUseAISettings = vi.mocked(useAISettings);
|
||||
const mockUseCurrentUser = vi.mocked(useCurrentUser);
|
||||
const mockUseAppContext = vi.mocked(useAppContext);
|
||||
const mockUseProjectsManager = vi.mocked(useProjectsManager);
|
||||
const mockCreateAIClient = vi.mocked(createAIClient);
|
||||
const mockParseProviderModel = vi.mocked(parseProviderModel);
|
||||
@@ -34,6 +37,20 @@ describe('useAIProjectId', () => {
|
||||
users: [],
|
||||
});
|
||||
|
||||
// Mock useAppContext
|
||||
mockUseAppContext.mockReturnValue({
|
||||
config: {
|
||||
theme: 'dark',
|
||||
relayUrl: 'wss://relay.damus.io',
|
||||
projectTemplate: 'https://github.com/example/template',
|
||||
deployServer: 'shakespeare.wtf',
|
||||
esmUrl: 'https://esm.sh',
|
||||
corsProxy: 'https://proxy.example.com/{href}',
|
||||
previewDomain: 'local-shakespeare.dev',
|
||||
},
|
||||
updateConfig: vi.fn(),
|
||||
});
|
||||
|
||||
// Mock useProjectsManager
|
||||
const mockProjectsManager = {
|
||||
getProject: vi.fn().mockResolvedValue(null),
|
||||
@@ -170,7 +187,8 @@ describe('useAIProjectId', () => {
|
||||
]);
|
||||
expect(mockCreateAIClient).toHaveBeenCalledWith(
|
||||
{ id: 'openai', apiKey: 'test-key', baseURL: 'https://api.openai.com/v1' },
|
||||
undefined
|
||||
undefined,
|
||||
'https://proxy.example.com/{href}'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { createAIClient } from '@/lib/ai-client';
|
||||
import { parseProviderModel } from '@/lib/parseProviderModel';
|
||||
@@ -13,6 +14,7 @@ export function useAIProjectId({ onError }: UseAIProjectIdOptions = {}) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const { settings, isConfigured } = useAISettings();
|
||||
const { user } = useCurrentUser();
|
||||
const { config } = useAppContext();
|
||||
const projectsManager = useProjectsManager();
|
||||
|
||||
const generateProjectId = useCallback(async (providerModel: string, prompt: string): Promise<string> => {
|
||||
@@ -29,7 +31,7 @@ export function useAIProjectId({ onError }: UseAIProjectIdOptions = {}) {
|
||||
try {
|
||||
// Initialize OpenAI client
|
||||
const { model, provider } = parseProviderModel(providerModel, settings.providers);
|
||||
const openai = createAIClient(provider, user);
|
||||
const openai = createAIClient(provider, user, config.corsProxy);
|
||||
|
||||
const systemPrompt = `You are a product expert. Given the user's project description, come up with a short, unique, and memorable name for their product or brand. Generate only the name without any additional text or punctuation. The name should be lowercase, use hyphens instead of spaces, and contain only alphanumeric characters and hyphens. Avoid using special characters or underscores.`;
|
||||
|
||||
@@ -84,7 +86,7 @@ export function useAIProjectId({ onError }: UseAIProjectIdOptions = {}) {
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [isConfigured, settings, onError, user, projectsManager]);
|
||||
}, [isConfigured, settings, onError, user, projectsManager, config.corsProxy]);
|
||||
|
||||
return {
|
||||
generateProjectId,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import { createAIClient } from '@/lib/ai-client';
|
||||
|
||||
interface ProviderModel {
|
||||
@@ -32,6 +33,7 @@ interface ModelFetchResult {
|
||||
export function useProviderModels(): ModelFetchResult {
|
||||
const { settings } = useAISettings();
|
||||
const { user } = useCurrentUser();
|
||||
const { config } = useAppContext();
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const {
|
||||
@@ -46,7 +48,7 @@ export function useProviderModels(): ModelFetchResult {
|
||||
// Fetch models from each configured provider in parallel
|
||||
const providerPromises = settings.providers.map(async (provider) => {
|
||||
try {
|
||||
const openai = createAIClient(provider, user);
|
||||
const openai = createAIClient(provider, user, config.corsProxy);
|
||||
|
||||
// Fetch models with timeout
|
||||
try {
|
||||
|
||||
@@ -60,17 +60,20 @@ export class SessionManager {
|
||||
private aiSettings: { providers: AIProvider[] };
|
||||
private getProviderModels?: () => Array<{ id: string; provider: string; contextLength?: number; pricing?: { prompt: import('decimal.js').Decimal; completion: import('decimal.js').Decimal } }>;
|
||||
private getCurrentUser?: () => { user?: NUser; metadata?: NostrMetadata };
|
||||
private corsProxy?: string;
|
||||
|
||||
constructor(
|
||||
fs: JSRuntimeFS,
|
||||
aiSettings: { providers: AIProvider[] },
|
||||
getProviderModels?: () => Array<{ id: string; provider: string; contextLength?: number; pricing?: { prompt: import('decimal.js').Decimal; completion: import('decimal.js').Decimal } }>,
|
||||
getCurrentUser?: () => { user?: NUser; metadata?: NostrMetadata },
|
||||
corsProxy?: string,
|
||||
) {
|
||||
this.fs = fs;
|
||||
this.aiSettings = aiSettings;
|
||||
this.getProviderModels = getProviderModels;
|
||||
this.getCurrentUser = getCurrentUser;
|
||||
this.corsProxy = corsProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +209,7 @@ export class SessionManager {
|
||||
|
||||
// Initialize OpenAI client
|
||||
const { user, metadata } = this.getCurrentUser?.() ?? {};
|
||||
const openai = createAIClient(provider, user);
|
||||
const openai = createAIClient(provider, user, this.corsProxy);
|
||||
|
||||
let stepCount = 0;
|
||||
const maxSteps = session.maxSteps || 50;
|
||||
|
||||
+38
-19
@@ -1,39 +1,58 @@
|
||||
import OpenAI from 'openai';
|
||||
import { NIP98Client } from '@nostrify/nostrify';
|
||||
import { NIP98 } from '@nostrify/nostrify';
|
||||
import { N64 } from '@nostrify/nostrify/utils';
|
||||
import type { NUser } from '@nostrify/react/login';
|
||||
import type { AIProvider } from '@/contexts/AISettingsContext';
|
||||
import { proxyUrl } from './proxyUrl';
|
||||
|
||||
/**
|
||||
* Create an OpenAI client instance with the appropriate configuration.
|
||||
* If the connection requires Nostr authentication (NIP-98), it will use
|
||||
* the NIP98Client for authenticated requests.
|
||||
* If the provider has proxy enabled, requests will be proxied through the corsProxy.
|
||||
*/
|
||||
export function createAIClient(provider: AIProvider, user?: NUser): OpenAI {
|
||||
export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: string): OpenAI {
|
||||
const baseConfig: ConstructorParameters<typeof OpenAI>[0] = {
|
||||
baseURL: provider.baseURL,
|
||||
apiKey: provider.apiKey ?? '',
|
||||
dangerouslyAllowBrowser: true,
|
||||
defaultHeaders: provider.id === 'openrouter' ? {
|
||||
// https://openrouter.ai/docs/app-attribution
|
||||
'HTTP-Referer': 'https://shakespeare.diy',
|
||||
'X-Title': 'Shakespeare',
|
||||
} : {},
|
||||
};
|
||||
|
||||
let openai: OpenAI;
|
||||
const openai = new OpenAI({
|
||||
...baseConfig,
|
||||
fetch: async (input, init) => {
|
||||
let request = new Request(input, init);
|
||||
|
||||
// If Nostr authentication is required and we have a user, use NIP-98
|
||||
if (provider.nostr && user?.signer) {
|
||||
const nip98Client = new NIP98Client({ signer: user.signer });
|
||||
// Add OpenRouter headers
|
||||
// https://openrouter.ai/docs/app-attribution
|
||||
if (provider.id === 'openrouter') {
|
||||
const headers = new Headers(request.headers);
|
||||
headers.set('HTTP-Referer', 'https://shakespeare.diy');
|
||||
headers.set('X-Title', 'Shakespeare');
|
||||
request = new Request(request, { headers });
|
||||
}
|
||||
|
||||
openai = new OpenAI({
|
||||
...baseConfig,
|
||||
fetch: (input, init) => nip98Client.fetch(input, init),
|
||||
});
|
||||
} else {
|
||||
// Standard OpenAI client
|
||||
openai = new OpenAI(baseConfig);
|
||||
}
|
||||
// If Nostr authentication is required and we have a user, use NIP-98
|
||||
if (provider.nostr && user?.signer) {
|
||||
// Create the NIP98 token
|
||||
const template = await NIP98.template(request);
|
||||
const event = await user.signer.signEvent(template);
|
||||
const token = N64.encodeEvent(event);
|
||||
|
||||
// Add the Authorization header
|
||||
const headers = new Headers(request.headers);
|
||||
headers.set('Authorization', `Nostr ${token}`);
|
||||
request = new Request(request, { headers });
|
||||
}
|
||||
|
||||
// If proxy is enabled and we have a CORS proxy URL, modify the request URL
|
||||
if (provider.proxy && corsProxy) {
|
||||
request = new Request(proxyUrl(corsProxy, request.url), request);
|
||||
}
|
||||
|
||||
return fetch(request);
|
||||
},
|
||||
});
|
||||
|
||||
const createCompletion: typeof openai.chat.completions.create
|
||||
= openai.chat.completions.create.bind(openai.chat.completions);
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface PresetProvider {
|
||||
apiKeysURL?: string;
|
||||
nostr?: boolean;
|
||||
tosURL?: string;
|
||||
proxy?: boolean;
|
||||
}
|
||||
|
||||
export const AI_PROVIDER_PRESETS: PresetProvider[] = [
|
||||
@@ -71,6 +72,14 @@ export const AI_PROVIDER_PRESETS: PresetProvider[] = [
|
||||
apiKeysURL: "https://platform.deepseek.com/api_keys",
|
||||
tosURL: "https://cdn.deepseek.com/policies/en-US/deepseek-open-platform-terms-of-service.html",
|
||||
},
|
||||
{
|
||||
id: "moonshot",
|
||||
name: "Moonshot AI",
|
||||
baseURL: "https://api.moonshot.ai/v1",
|
||||
apiKeysURL: "https://platform.moonshot.ai/console/api-keys",
|
||||
tosURL: "https://platform.moonshot.ai/docs/agreement/modeluse",
|
||||
proxy: true,
|
||||
},
|
||||
];
|
||||
|
||||
// Helper function to get a specific preset by ID
|
||||
|
||||
@@ -13,6 +13,7 @@ const aiProviderSchema: z.ZodType<AIProvider> = z.object({
|
||||
baseURL: z.string().url(),
|
||||
apiKey: z.string().optional(),
|
||||
nostr: z.boolean().optional(),
|
||||
proxy: z.boolean().optional(),
|
||||
});
|
||||
|
||||
const providerModelSchema = z.string().regex(
|
||||
|
||||
@@ -195,6 +195,7 @@ const resources = {
|
||||
baseUrl: 'Base URL',
|
||||
apiKey: 'API Key',
|
||||
authentication: 'Authentication',
|
||||
useCorsProxy: 'Use CORS Proxy',
|
||||
addCustomProviderButton: 'Add Custom Provider',
|
||||
providerExists: 'Provider with this name already exists',
|
||||
agreeToTermsOfService: 'I agree to {{providerName}}’s',
|
||||
@@ -510,6 +511,7 @@ const resources = {
|
||||
baseUrl: 'URL Base',
|
||||
apiKey: 'Chave de API',
|
||||
authentication: 'Autenticação',
|
||||
useCorsProxy: 'Usar Proxy CORS',
|
||||
addCustomProviderButton: 'Adicionar Provedor Personalizado',
|
||||
providerExists: 'Provedor com este nome já existe',
|
||||
agreeToTermsOfService: 'Concordo com {{providerName}}',
|
||||
@@ -831,6 +833,7 @@ const resources = {
|
||||
baseUrl: '基础URL',
|
||||
apiKey: 'API密钥',
|
||||
authentication: '身份验证',
|
||||
useCorsProxy: '使用CORS代理',
|
||||
addCustomProviderButton: '添加自定义提供商',
|
||||
providerExists: '此名称的提供商已存在',
|
||||
agreeToTermsOfService: '我同意{{providerName}}',
|
||||
@@ -1152,6 +1155,7 @@ const resources = {
|
||||
baseUrl: 'URL na Tushe',
|
||||
apiKey: 'Maɓallin API',
|
||||
authentication: 'Tabbatarwa',
|
||||
useCorsProxy: 'Yi amfani da CORS Proxy',
|
||||
addCustomProviderButton: 'Ƙara Mai Samarwa na Musamman',
|
||||
providerExists: 'Mai samarwa da wannan suna ya riga ya wanzu',
|
||||
agreeToTermsOfService: 'Na yarda da {{providerName}}',
|
||||
@@ -1473,6 +1477,7 @@ const resources = {
|
||||
baseUrl: 'URL Ipilẹ',
|
||||
apiKey: 'Bọtini API',
|
||||
authentication: 'Ijẹrisi',
|
||||
useCorsProxy: 'Lo CORS Proxy',
|
||||
addCustomProviderButton: 'Fi Olupese Aṣa kun',
|
||||
providerExists: 'Olupese pẹlu orukọ yii ti wa tẹlẹ',
|
||||
agreeToTermsOfService: 'Mo gba {{providerName}}',
|
||||
@@ -1789,6 +1794,7 @@ const resources = {
|
||||
baseUrl: 'URL Ntọala',
|
||||
apiKey: 'Igodo API',
|
||||
authentication: 'Nkwenye',
|
||||
useCorsProxy: 'Jiri CORS Proxy',
|
||||
addCustomProviderButton: 'Tinye Onye Na-enye Omenala',
|
||||
providerExists: 'Onye na-enye nwere aha a adịlarị',
|
||||
agreeToTermsOfService: 'Ekwenyere m na {{providerName}}',
|
||||
|
||||
@@ -145,6 +145,19 @@ function SortableProviderItem({ provider, preset, onRemove, onSetProvider, onOpe
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id={`${provider.id}-proxy`}
|
||||
checked={provider.proxy || false}
|
||||
onCheckedChange={(checked) => onSetProvider({
|
||||
...provider,
|
||||
proxy: checked === true || undefined
|
||||
})}
|
||||
/>
|
||||
<Label htmlFor={`${provider.id}-proxy`} className="cursor-pointer">
|
||||
{t('useCorsProxy')}
|
||||
</Label>
|
||||
</div>
|
||||
</div>
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
@@ -161,6 +174,7 @@ export function AISettings() {
|
||||
const [customBaseURL, setCustomBaseURL] = useState('');
|
||||
const [customApiKey, setCustomApiKey] = useState('');
|
||||
const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr'>('api-key');
|
||||
const [customProxy, setCustomProxy] = useState(false);
|
||||
const [presetApiKeys, setPresetApiKeys] = useState<Record<string, string>>({});
|
||||
const [presetTermsAgreements, setPresetTermsAgreements] = useState<Record<string, boolean>>({});
|
||||
const [activeCreditsDialog, setActiveCreditsDialog] = useState<string | null>(null);
|
||||
@@ -189,6 +203,9 @@ export function AISettings() {
|
||||
if (typeof preset.nostr === 'boolean') {
|
||||
newProvider.nostr = preset.nostr;
|
||||
}
|
||||
if (typeof preset.proxy === 'boolean') {
|
||||
newProvider.proxy = preset.proxy;
|
||||
}
|
||||
|
||||
// Auto-save: Add provider immediately to persistent storage
|
||||
setProvider(newProvider);
|
||||
@@ -212,6 +229,7 @@ export function AISettings() {
|
||||
baseURL: customBaseURL.trim(),
|
||||
apiKey: customAuthMethod === 'nostr' ? undefined : customApiKey.trim(),
|
||||
nostr: customAuthMethod === 'nostr' || undefined,
|
||||
proxy: customProxy || undefined,
|
||||
};
|
||||
|
||||
// Auto-save: Add provider immediately to persistent storage
|
||||
@@ -221,6 +239,7 @@ export function AISettings() {
|
||||
setCustomBaseURL('');
|
||||
setCustomApiKey('');
|
||||
setCustomAuthMethod('api-key');
|
||||
setCustomProxy(false);
|
||||
};
|
||||
|
||||
const handleRemoveProvider = (id: string) => {
|
||||
@@ -501,6 +520,16 @@ export function AISettings() {
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="custom-proxy"
|
||||
checked={customProxy}
|
||||
onCheckedChange={(checked) => setCustomProxy(checked === true)}
|
||||
/>
|
||||
<Label htmlFor="custom-proxy" className="cursor-pointer">
|
||||
{t('useCorsProxy')}
|
||||
</Label>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleAddCustomProvider}
|
||||
disabled={
|
||||
|
||||
Reference in new issue
Block a user