fix: expand assistant and model settings by default (#2081)
* fix: expand assistant and model settings by default * fix: add proxy enabled toggle
This commit is contained in:
parent
3af0ae1481
commit
780f957b9a
@ -22,6 +22,7 @@ interface Props {
|
|||||||
rightAction?: ReactNode
|
rightAction?: ReactNode
|
||||||
title: string
|
title: string
|
||||||
asChild?: boolean
|
asChild?: boolean
|
||||||
|
isShow?: boolean
|
||||||
hideMoreVerticalAction?: boolean
|
hideMoreVerticalAction?: boolean
|
||||||
}
|
}
|
||||||
export default function CardSidebar({
|
export default function CardSidebar({
|
||||||
@ -30,8 +31,9 @@ export default function CardSidebar({
|
|||||||
asChild,
|
asChild,
|
||||||
rightAction,
|
rightAction,
|
||||||
hideMoreVerticalAction,
|
hideMoreVerticalAction,
|
||||||
|
isShow,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const [show, setShow] = useState(false)
|
const [show, setShow] = useState(isShow ?? false)
|
||||||
const [more, setMore] = useState(false)
|
const [more, setMore] = useState(false)
|
||||||
const [menu, setMenu] = useState<HTMLDivElement | null>(null)
|
const [menu, setMenu] = useState<HTMLDivElement | null>(null)
|
||||||
const [toggle, setToggle] = useState<HTMLDivElement | null>(null)
|
const [toggle, setToggle] = useState<HTMLDivElement | null>(null)
|
||||||
@ -67,8 +69,8 @@ export default function CardSidebar({
|
|||||||
show && 'rotate-180'
|
show && 'rotate-180'
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</button>
|
|
||||||
<span className="font-bold">{title}</span>
|
<span className="font-bold">{title}</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
{rightAction && rightAction}
|
{rightAction && rightAction}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ const OpenAiKeyInput: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-4">
|
<div className="my-4">
|
||||||
<label
|
<label
|
||||||
id="thread-title"
|
id="thread-title"
|
||||||
className="mb-2 inline-block font-bold text-gray-600 dark:text-gray-300"
|
className="mb-2 inline-block font-bold text-gray-600 dark:text-gray-300"
|
||||||
|
|||||||
@ -4,18 +4,22 @@ interface FeatureToggleContextType {
|
|||||||
experimentalFeature: boolean
|
experimentalFeature: boolean
|
||||||
ignoreSSL: boolean
|
ignoreSSL: boolean
|
||||||
proxy: string
|
proxy: string
|
||||||
|
proxyEnabled: boolean
|
||||||
setExperimentalFeature: (on: boolean) => void
|
setExperimentalFeature: (on: boolean) => void
|
||||||
setIgnoreSSL: (on: boolean) => void
|
setIgnoreSSL: (on: boolean) => void
|
||||||
setProxy: (value: string) => void
|
setProxy: (value: string) => void
|
||||||
|
setProxyEnabled: (on: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialContext: FeatureToggleContextType = {
|
const initialContext: FeatureToggleContextType = {
|
||||||
experimentalFeature: false,
|
experimentalFeature: false,
|
||||||
ignoreSSL: false,
|
ignoreSSL: false,
|
||||||
proxy: '',
|
proxy: '',
|
||||||
|
proxyEnabled: false,
|
||||||
setExperimentalFeature: () => {},
|
setExperimentalFeature: () => {},
|
||||||
setIgnoreSSL: () => {},
|
setIgnoreSSL: () => {},
|
||||||
setProxy: () => {},
|
setProxy: () => {},
|
||||||
|
setProxyEnabled: () => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FeatureToggleContext =
|
export const FeatureToggleContext =
|
||||||
@ -29,8 +33,11 @@ export default function FeatureToggleWrapper({
|
|||||||
const EXPERIMENTAL_FEATURE = 'experimentalFeature'
|
const EXPERIMENTAL_FEATURE = 'experimentalFeature'
|
||||||
const IGNORE_SSL = 'ignoreSSLFeature'
|
const IGNORE_SSL = 'ignoreSSLFeature'
|
||||||
const HTTPS_PROXY_FEATURE = 'httpsProxyFeature'
|
const HTTPS_PROXY_FEATURE = 'httpsProxyFeature'
|
||||||
|
const PROXY_FEATURE_ENABLED = 'proxyFeatureEnabled'
|
||||||
|
|
||||||
const [experimentalFeature, directSetExperimentalFeature] =
|
const [experimentalFeature, directSetExperimentalFeature] =
|
||||||
useState<boolean>(false)
|
useState<boolean>(false)
|
||||||
|
const [proxyEnabled, directSetProxyEnabled] = useState<boolean>(false)
|
||||||
const [ignoreSSL, directSetIgnoreSSL] = useState<boolean>(false)
|
const [ignoreSSL, directSetIgnoreSSL] = useState<boolean>(false)
|
||||||
const [proxy, directSetProxy] = useState<string>('')
|
const [proxy, directSetProxy] = useState<string>('')
|
||||||
|
|
||||||
@ -40,6 +47,9 @@ export default function FeatureToggleWrapper({
|
|||||||
)
|
)
|
||||||
directSetIgnoreSSL(localStorage.getItem(IGNORE_SSL) === 'true')
|
directSetIgnoreSSL(localStorage.getItem(IGNORE_SSL) === 'true')
|
||||||
directSetProxy(localStorage.getItem(HTTPS_PROXY_FEATURE) ?? '')
|
directSetProxy(localStorage.getItem(HTTPS_PROXY_FEATURE) ?? '')
|
||||||
|
directSetProxyEnabled(
|
||||||
|
localStorage.getItem(PROXY_FEATURE_ENABLED) === 'true'
|
||||||
|
)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const setExperimentalFeature = (on: boolean) => {
|
const setExperimentalFeature = (on: boolean) => {
|
||||||
@ -57,15 +67,22 @@ export default function FeatureToggleWrapper({
|
|||||||
directSetProxy(proxy)
|
directSetProxy(proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setProxyEnabled = (on: boolean) => {
|
||||||
|
localStorage.setItem(PROXY_FEATURE_ENABLED, on ? 'true' : 'false')
|
||||||
|
directSetProxyEnabled(on)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FeatureToggleContext.Provider
|
<FeatureToggleContext.Provider
|
||||||
value={{
|
value={{
|
||||||
experimentalFeature,
|
experimentalFeature,
|
||||||
ignoreSSL,
|
ignoreSSL,
|
||||||
proxy,
|
proxy,
|
||||||
|
proxyEnabled,
|
||||||
setExperimentalFeature,
|
setExperimentalFeature,
|
||||||
setIgnoreSSL,
|
setIgnoreSSL,
|
||||||
setProxy,
|
setProxy,
|
||||||
|
setProxyEnabled,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import { extensionManager } from '@/extension/ExtensionManager'
|
|||||||
import { addDownloadingModelAtom } from '@/helpers/atoms/Model.atom'
|
import { addDownloadingModelAtom } from '@/helpers/atoms/Model.atom'
|
||||||
|
|
||||||
export default function useDownloadModel() {
|
export default function useDownloadModel() {
|
||||||
const { ignoreSSL, proxy } = useContext(FeatureToggleContext)
|
const { ignoreSSL, proxy, proxyEnabled } = useContext(FeatureToggleContext)
|
||||||
const setDownloadState = useSetAtom(setDownloadStateAtom)
|
const setDownloadState = useSetAtom(setDownloadStateAtom)
|
||||||
const addDownloadingModel = useSetAtom(addDownloadingModelAtom)
|
const addDownloadingModel = useSetAtom(addDownloadingModelAtom)
|
||||||
|
|
||||||
@ -64,9 +64,9 @@ export default function useDownloadModel() {
|
|||||||
|
|
||||||
addDownloadingModel(model)
|
addDownloadingModel(model)
|
||||||
|
|
||||||
await localDownloadModel(model, ignoreSSL, proxy)
|
await localDownloadModel(model, ignoreSSL, proxyEnabled ? proxy : '')
|
||||||
},
|
},
|
||||||
[ignoreSSL, proxy, addDownloadingModel, setDownloadState]
|
[ignoreSSL, proxy, proxyEnabled, addDownloadingModel, setDownloadState]
|
||||||
)
|
)
|
||||||
|
|
||||||
const abortModelDownload = useCallback(async (model: Model) => {
|
const abortModelDownload = useCallback(async (model: Model) => {
|
||||||
|
|||||||
@ -116,7 +116,7 @@ const Sidebar: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CardSidebar title="Assistant">
|
<CardSidebar title="Assistant" isShow={true}>
|
||||||
<div className="flex flex-col space-y-4 p-2">
|
<div className="flex flex-col space-y-4 p-2">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<LogoMark width={24} height={24} />
|
<LogoMark width={24} height={24} />
|
||||||
@ -152,6 +152,47 @@ const Sidebar: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</CardSidebar>
|
</CardSidebar>
|
||||||
|
|
||||||
|
<CardSidebar title="Model" isShow={true}>
|
||||||
|
<div className="px-2 pt-4">
|
||||||
|
<DropdownListSidebar />
|
||||||
|
|
||||||
|
{componentDataRuntimeSetting.length > 0 && (
|
||||||
|
<div className="mt-6">
|
||||||
|
<CardSidebar title="Inference Parameters" asChild>
|
||||||
|
<div className="px-2 py-4">
|
||||||
|
<ModelSetting componentData={componentDataRuntimeSetting} />
|
||||||
|
</div>
|
||||||
|
</CardSidebar>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{componentDataEngineSetting.filter(
|
||||||
|
(x) => x.name === 'prompt_template'
|
||||||
|
).length !== 0 && (
|
||||||
|
<div className="mt-4">
|
||||||
|
<CardSidebar title="Model Parameters" asChild>
|
||||||
|
<div className="px-2 py-4">
|
||||||
|
<SettingComponentBuilder
|
||||||
|
componentData={componentDataEngineSetting}
|
||||||
|
selector={(x: any) => x.name === 'prompt_template'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CardSidebar>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{componentDataEngineSetting.length > 0 && (
|
||||||
|
<div className="my-4">
|
||||||
|
<CardSidebar title="Engine Parameters" asChild>
|
||||||
|
<div className="px-2 py-4">
|
||||||
|
<EngineSetting componentData={componentDataEngineSetting} />
|
||||||
|
</div>
|
||||||
|
</CardSidebar>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</CardSidebar>
|
||||||
|
|
||||||
{experimentalFeature && (
|
{experimentalFeature && (
|
||||||
<div>
|
<div>
|
||||||
{activeThread?.assistants[0]?.tools &&
|
{activeThread?.assistants[0]?.tools &&
|
||||||
@ -312,47 +353,6 @@ const Sidebar: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<CardSidebar title="Model">
|
|
||||||
<div className="px-2 pt-4">
|
|
||||||
<DropdownListSidebar />
|
|
||||||
|
|
||||||
{componentDataRuntimeSetting.length > 0 && (
|
|
||||||
<div className="mt-6">
|
|
||||||
<CardSidebar title="Inference Parameters" asChild>
|
|
||||||
<div className="px-2 py-4">
|
|
||||||
<ModelSetting componentData={componentDataRuntimeSetting} />
|
|
||||||
</div>
|
|
||||||
</CardSidebar>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{componentDataEngineSetting.filter(
|
|
||||||
(x) => x.name === 'prompt_template'
|
|
||||||
).length !== 0 && (
|
|
||||||
<div className="mt-4">
|
|
||||||
<CardSidebar title="Model Parameters" asChild>
|
|
||||||
<div className="px-2 py-4">
|
|
||||||
<SettingComponentBuilder
|
|
||||||
componentData={componentDataEngineSetting}
|
|
||||||
selector={(x: any) => x.name === 'prompt_template'}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</CardSidebar>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{componentDataEngineSetting.length > 0 && (
|
|
||||||
<div className="my-4">
|
|
||||||
<CardSidebar title="Engine Parameters" asChild>
|
|
||||||
<div className="px-2 py-4">
|
|
||||||
<EngineSetting componentData={componentDataEngineSetting} />
|
|
||||||
</div>
|
|
||||||
</CardSidebar>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</CardSidebar>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -56,6 +56,8 @@ const Advanced = () => {
|
|||||||
setIgnoreSSL,
|
setIgnoreSSL,
|
||||||
proxy,
|
proxy,
|
||||||
setProxy,
|
setProxy,
|
||||||
|
proxyEnabled,
|
||||||
|
setProxyEnabled,
|
||||||
} = useContext(FeatureToggleContext)
|
} = useContext(FeatureToggleContext)
|
||||||
const [partialProxy, setPartialProxy] = useState<string>(proxy)
|
const [partialProxy, setPartialProxy] = useState<string>(proxy)
|
||||||
const [gpuEnabled, setGpuEnabled] = useState<boolean>(false)
|
const [gpuEnabled, setGpuEnabled] = useState<boolean>(false)
|
||||||
@ -329,9 +331,13 @@ const Advanced = () => {
|
|||||||
<DataFolder />
|
<DataFolder />
|
||||||
{/* Proxy */}
|
{/* Proxy */}
|
||||||
<div className="flex w-full items-start justify-between border-b border-border py-4 first:pt-0 last:border-none">
|
<div className="flex w-full items-start justify-between border-b border-border py-4 first:pt-0 last:border-none">
|
||||||
<div className="flex-shrink-0 space-y-1.5">
|
<div className="flex-shrink-0 space-y-1.5 w-full">
|
||||||
<div className="flex gap-x-2">
|
<div className="flex gap-x-2 justify-between w-full">
|
||||||
<h6 className="text-sm font-semibold capitalize">HTTPS Proxy</h6>
|
<h6 className="text-sm font-semibold capitalize">HTTPS Proxy</h6>
|
||||||
|
<Switch
|
||||||
|
checked={proxyEnabled}
|
||||||
|
onCheckedChange={(_) => setProxyEnabled(!proxyEnabled)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p className="leading-relaxed">
|
<p className="leading-relaxed">
|
||||||
Specify the HTTPS proxy or leave blank (proxy auto-configuration and
|
Specify the HTTPS proxy or leave blank (proxy auto-configuration and
|
||||||
@ -341,6 +347,7 @@ const Advanced = () => {
|
|||||||
placeholder={'http://<user>:<password>@<domain or IP>:<port>'}
|
placeholder={'http://<user>:<password>@<domain or IP>:<port>'}
|
||||||
value={partialProxy}
|
value={partialProxy}
|
||||||
onChange={onProxyChange}
|
onChange={onProxyChange}
|
||||||
|
className="w-2/3"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user