()
| 17 | import type { OpenAIModel } from "@/types/type"; |
| 18 | |
| 19 | export const APIKeyInput = () => { |
| 20 | const [apiKey, setApiKey] = useAtom(apiKeyAtom); |
| 21 | const [model, setModel] = useAtom(modelAtom); |
| 22 | |
| 23 | const handleChange = (e: ChangeEvent<HTMLInputElement>) => |
| 24 | setApiKey(e.target.value); |
| 25 | |
| 26 | const handleModelChange = (value: OpenAIModel) => { |
| 27 | setModel(value); |
| 28 | }; |
| 29 | |
| 30 | const handleSave = () => { |
| 31 | localStorage.setItem("apiKey", apiKey); |
| 32 | localStorage.setItem("model", model); |
| 33 | }; |
| 34 | |
| 35 | return ( |
| 36 | <div className="grid w-full max-w-sm items-center gap-1.5"> |
| 37 | <div> |
| 38 | <Label htmlFor="api-key">OpenAI API key</Label> |
| 39 | <Input |
| 40 | type="password" |
| 41 | id="api-key" |
| 42 | placeholder="OpenAI API Key" |
| 43 | value={apiKey} |
| 44 | onChange={handleChange} |
| 45 | className="mt-2" |
| 46 | /> |
| 47 | </div> |
| 48 | |
| 49 | <div className="mb-2"> |
| 50 | <Label htmlFor="model">OpenAI model</Label> |
| 51 | <Select value={model} onValueChange={handleModelChange}> |
| 52 | <SelectTrigger className="w-[180px] mt-2"> |
| 53 | <SelectValue id="model" placeholder="Select model" /> |
| 54 | </SelectTrigger> |
| 55 | <SelectContent> |
| 56 | <SelectItem value="gpt-4">gpt-4o</SelectItem> |
| 57 | <SelectItem value="gpt-4">gpt-4o-mini</SelectItem> |
| 58 | <SelectItem value="gpt-4">gpt-4</SelectItem> |
| 59 | <SelectItem value="gpt-3.5-turbo">gpt-3.5-turbo</SelectItem> |
| 60 | </SelectContent> |
| 61 | </Select> |
| 62 | </div> |
| 63 | <Button onClick={handleSave}>Save</Button> |
| 64 | </div> |
| 65 | ); |
| 66 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected