refactor(providers): a provider is a vendor and a key, and the table is gone
The dropdown was listing "connections" — a row per adapter + model + key — which made choosing a model an act of configuration, put a key icon and a bin inside a menu item, and showed five accounts nobody had created. A provider is now a vendor Officer curates. Every one is listed, set up or not, because a vendor you have no key for is exactly what you need to see in order to add one. The model is chosen per generation, from that provider's entry in the catalogue, beside it. With the model off the row, all that remained of a "provider" was the key for OpenAI — and Officer already stores keys: one active value per purpose, 0600 inside a 0700 directory, outside the backup tarball, created on first use so nothing needs provisioning. So `atelier_providers` is dropped, along with `generations.provider_id` that pointed into it. `provider` and `model` stay as text on each generation, which were always the historical fact rather than a pointer to configuration. `getSecret`, never `getKey`: this is a foreign credential, and getKey mints a random value for a purpose it cannot find — which for someone else's API key means authenticating with something invented. Resolution follows: a request names a model, and the catalogue says whose it is, rather than a database being asked which stored row served it. A model nobody in the catalogue claims is still accepted — the catalogue is advisory, and a model released today should work before we ship a file that mentions it. Two routes replace five: PUT and DELETE on /providers/:name/key. Deleting a key that came from the environment is refused rather than faked — it belongs to the install, not to this screen.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -11,17 +12,17 @@ import { BACKGROUNDS, QUALITIES, SIZES, useGenerateManager } from './useGenerate
|
||||
|
||||
export const Generate = () => {
|
||||
const providers = useProviders();
|
||||
const manager = useGenerateManager(providers.providers);
|
||||
// The model lives here, between the two: chosen in the bar above, used by the form below.
|
||||
const [model, setModel] = useState('');
|
||||
const manager = useGenerateManager(providers.providers, model);
|
||||
|
||||
return (
|
||||
<div className="h-full space-y-6 overflow-y-auto p-4">
|
||||
{/* Which provider, then what to make with it — one panel, in that order. */}
|
||||
<ProvidersBar manager={providers} />
|
||||
{/* Which provider and model, then what to make with it — one panel, in that order. */}
|
||||
<ProvidersBar manager={providers} model={model} onModelChange={setModel} />
|
||||
|
||||
{providers.providers.length > 0 && manager.usableProviders.length === 0 && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
No provider is ready. Set an API key from the dropdown above.
|
||||
</p>
|
||||
{!providers.loading && manager.usableProviders.length === 0 && (
|
||||
<p className="text-sm text-muted-foreground">No provider has a key yet — add one above.</p>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
@@ -36,21 +37,6 @@ export const Generate = () => {
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<Field label="Model" id="atelier-model">
|
||||
<Select value={manager.model} onValueChange={manager.setModel}>
|
||||
<SelectTrigger id="atelier-model" className="w-full">
|
||||
<SelectValue placeholder="Choose" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{manager.models.map((model) => (
|
||||
<SelectItem key={model} value={model}>
|
||||
{model}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field label="Count" id="atelier-n">
|
||||
<Input
|
||||
id="atelier-n"
|
||||
|
||||
Reference in New Issue
Block a user