From 7529ab37b49f5a5e58d641454b09f56b8c33dd22 Mon Sep 17 00:00:00 2001 From: guangzhengli Date: Tue, 27 Jun 2023 20:31:42 +0800 Subject: [PATCH] feat: add the apiModel to keyConfiguration. --- components/Sidebar/KeySettings.tsx | 62 ++++++++++---------------- components/Sidebar/SidebarSettings.tsx | 2 +- 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/components/Sidebar/KeySettings.tsx b/components/Sidebar/KeySettings.tsx index 37bc308..6b885aa 100644 --- a/components/Sidebar/KeySettings.tsx +++ b/components/Sidebar/KeySettings.tsx @@ -1,40 +1,24 @@ -import { FC, MouseEventHandler, useState } from 'react'; -import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" -import { Label } from "@/components/ui/label" -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" -import { - Sheet, - SheetClose, - SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, - SheetTitle, - SheetTrigger, -} from "@/components/ui/sheet" -import { - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, - } from "@/components/ui/card" -import { KeyConfiguration, ModelType } from '@/types'; +import {FC, useState} from 'react'; +import {Button} from "@/components/ui/button" +import {Input} from "@/components/ui/input" +import {Label} from "@/components/ui/label" +import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs" +import {Sheet, SheetClose, SheetContent, SheetHeader, SheetTitle, SheetTrigger,} from "@/components/ui/sheet" +import {Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle,} from "@/components/ui/card" +import {KeyConfiguration, ModelType} from '@/types'; interface Props { keyConfiguration: KeyConfiguration; - onKeyConfigrationChange: (keySettings: KeyConfiguration) => void; + onKeyConfigurationChange: (keySettings: KeyConfiguration) => void; keyConfigurationButtonRef: React.RefObject; } export const KeySettings: FC = ({ keyConfiguration, - onKeyConfigrationChange, + onKeyConfigurationChange, keyConfigurationButtonRef, }) => { - const [fromkeyConfigration, setFromKeyConfigration] = useState({ + const [fromKeyConfiguration, setFromKeyConfiguration] = useState({ apiType: keyConfiguration.apiType, apiKey: keyConfiguration.apiKey, azureApiKey: keyConfiguration.azureApiKey, @@ -45,18 +29,18 @@ export const KeySettings: FC = ({ }) const handleOpenAISubmit = () => { - fromkeyConfigration.apiType = ModelType.OPENAI; - onKeyConfigrationChange(fromkeyConfigration); + fromKeyConfiguration.apiType = ModelType.OPENAI; + onKeyConfigurationChange(fromKeyConfiguration); }; const handleAzureOpenAISubmit = () => { - fromkeyConfigration.apiType = ModelType.AZURE_OPENAI; - onKeyConfigrationChange(fromkeyConfigration); + fromKeyConfiguration.apiType = ModelType.AZURE_OPENAI; + onKeyConfigurationChange(fromKeyConfiguration); }; const handleChange = (event: React.ChangeEvent) => { - setFromKeyConfigration({ - ...fromkeyConfigration, + setFromKeyConfiguration({ + ...fromKeyConfiguration, [event.target.name]: event.target.value, }); }; @@ -87,7 +71,7 @@ export const KeySettings: FC = ({
- +
@@ -108,23 +92,23 @@ export const KeySettings: FC = ({
- +
- +
- +
- +
- +
diff --git a/components/Sidebar/SidebarSettings.tsx b/components/Sidebar/SidebarSettings.tsx index bae42f5..48b3010 100644 --- a/components/Sidebar/SidebarSettings.tsx +++ b/components/Sidebar/SidebarSettings.tsx @@ -54,7 +54,7 @@ export const SidebarSettings: FC = ({ onToggleLightMode(lightMode === 'light' ? 'dark' : 'light') } /> - + ); };