mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Add AI settings
This commit is contained in:
12 files changed
+527
-40
No files matched your search
@@ -0,0 +1,88 @@
|
||||
import { useState } from 'react';
|
||||
import { Settings } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { useAISettings } from '@/contexts/AISettingsContext';
|
||||
|
||||
export function AISettingsDialog() {
|
||||
const { settings, updateSettings, isConfigured } = useAISettings();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [localSettings, setLocalSettings] = useState(settings);
|
||||
|
||||
const handleSave = () => {
|
||||
updateSettings(localSettings);
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
setLocalSettings(settings);
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="ghost" size="sm" className="gap-2">
|
||||
<Settings className="h-4 w-4" />
|
||||
AI Settings
|
||||
{!isConfigured && (
|
||||
<span className="ml-1 h-2 w-2 rounded-full bg-red-500" />
|
||||
)}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>AI Settings</DialogTitle>
|
||||
<DialogDescription>
|
||||
Configure your AI provider settings. These settings are stored locally in your browser.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-4">
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="apiKey">API Key</Label>
|
||||
<Input
|
||||
id="apiKey"
|
||||
type="password"
|
||||
placeholder="Enter your API key"
|
||||
value={localSettings.apiKey}
|
||||
onChange={(e) => setLocalSettings({ ...localSettings, apiKey: e.target.value })}
|
||||
/>
|
||||
{!localSettings.apiKey && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Required for AI functionality
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="baseUrl">Base URL</Label>
|
||||
<Input
|
||||
id="baseUrl"
|
||||
placeholder="https://openrouter.ai/api/v1"
|
||||
value={localSettings.baseUrl}
|
||||
onChange={(e) => setLocalSettings({ ...localSettings, baseUrl: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="model">Model</Label>
|
||||
<Input
|
||||
id="model"
|
||||
placeholder="anthropic/claude-sonnet-4"
|
||||
value={localSettings.model}
|
||||
onChange={(e) => setLocalSettings({ ...localSettings, model: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" onClick={handleCancel}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={handleSave}>
|
||||
Save Settings
|
||||
</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user