/
githubmirror
/
browser-extension
Обзор
Документация
Войти
/
githubmirror
/
browser-extension
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/common/SetAPIKey.tsx
72 строки
2 KB
arcticfly
Optionally record logs
16 янв 2025, 02:52
16 янв 2025, 02:52
bc3b549
Код
Авторство
О чём код?
import { Button, Input, VStack, Text, Link, HStack } from '@chakra-ui/react'; import React from 'react'; import { useAppState } from '../state/store'; const ModelDropdown = () => { const { updateSettings } = useAppState((state) => ({ updateSettings: state.settings.actions.update, })); const [openAIKey, setOpenAIKey] = React.useState(''); const [openPipeKey, setOpenPipeKey] = React.useState(''); const [showPassword, setShowPassword] = React.useState(false); return ( <VStack spacing={4}> <Text fontSize="sm"> You'll need an OpenAI API Key to run the Taxy in developer mode. If you don't already have one available, you can create one in your{' '} <Link href="https://platform.openai.com/account/api-keys" color="blue" isExternal > OpenAI account </Link> . <br /> <br /> Taxy stores your API key locally and securely, and it is only used to communicate with the OpenAI API. </Text> <HStack w="full"> <Input placeholder="OpenAI API Key" value={openAIKey} onChange={(event) => setOpenAIKey(event.target.value)} type={showPassword ? 'text' : 'password'} /> <Button onClick={() => setShowPassword(!showPassword)} variant="outline" > {showPassword ? 'Hide' : 'Show'} </Button> </HStack> <HStack w="full"> <Input placeholder="OpenPipe API Key (optional)" value={openPipeKey} onChange={(event) => setOpenPipeKey(event.target.value)} type={showPassword ? 'text' : 'password'} /> <Button onClick={() => setShowPassword(!showPassword)} variant="outline" > {showPassword ? 'Hide' : 'Show'} </Button> </HStack> <Button onClick={() => updateSettings({ openAIKey, openPipeKey })} w="full" disabled={!openAIKey} colorScheme="blue" > Save Keys </Button> </VStack> ); }; export default ModelDropdown;