()
| 9 | import Tooltip from "./kit/Tooltip"; |
| 10 | |
| 11 | const OpenAIApiConfigView = () => { |
| 12 | const { t } = useTranslation(); |
| 13 | const settingStore = useSettingStore(); |
| 14 | const [openAIApiConfig, setOpenAIApiConfig] = useState(settingStore.setting.openAIApiConfig); |
| 15 | const [maskKey, setMaskKey] = useState(true); |
| 16 | |
| 17 | const models = [ |
| 18 | { |
| 19 | id: "gpt-3.5-turbo", |
| 20 | title: `GPT-3.5 Turbo`, |
| 21 | cost: 1, |
| 22 | disabled: false, |
| 23 | tooltip: "", |
| 24 | }, |
| 25 | { |
| 26 | id: "gpt-4-turbo", |
| 27 | title: `GPT-4 Turbo`, |
| 28 | cost: 20, |
| 29 | disabled: false, |
| 30 | tooltip: "", |
| 31 | }, |
| 32 | { |
| 33 | id: "gpt-4", |
| 34 | title: `GPT-4`, |
| 35 | cost: 60, |
| 36 | disabled: false, |
| 37 | tooltip: "", |
| 38 | }, |
| 39 | { |
| 40 | id: "gpt-4o", |
| 41 | title: `GPT-4o`, |
| 42 | cost: 10, |
| 43 | disabled: false, |
| 44 | tooltip: "", |
| 45 | }, |
| 46 | { |
| 47 | id: "deepseek-chat", |
| 48 | title: `Deepseek Chat`, |
| 49 | cost: 1, |
| 50 | disabled: false, |
| 51 | tooltip: "", |
| 52 | }, |
| 53 | ]; |
| 54 | |
| 55 | const maskedKey = (str: string) => { |
| 56 | if (str.length < 7) { |
| 57 | return str; |
| 58 | } |
| 59 | const firstThree = str.slice(0, 3); |
| 60 | const lastFour = str.slice(-4); |
| 61 | const middle = ".".repeat(str.length - 7); |
| 62 | return `${firstThree}${middle}${lastFour}`; |
| 63 | }; |
| 64 | |
| 65 | useDebounce( |
| 66 | () => { |
| 67 | settingStore.setOpenAIApiConfig(openAIApiConfig); |
| 68 | }, |
nothing calls this directly
no test coverage detected