Skip to content

Commit

Permalink
fix: model selection does not show in api settings page (janhq#1802)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Jan 26, 2024
1 parent 9fa28d2 commit 532a589
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions web/containers/DropdownListSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ import {

export const selectedModelAtom = atom<Model | undefined>(undefined)

const DropdownListSidebar: React.FC = () => {
// TODO: Move all of the unscoped logics outside of the component
const DropdownListSidebar = ({
strictedThread = true,
}: {
strictedThread?: boolean
}) => {
const activeThread = useAtomValue(activeThreadAtom)
const threadStates = useAtomValue(threadStatesAtom)
const [selectedModel, setSelectedModel] = useAtom(selectedModelAtom)
Expand Down Expand Up @@ -152,7 +157,7 @@ const DropdownListSidebar: React.FC = () => {
]
)

if (!activeThread) {
if (strictedThread && !activeThread) {
return null
}

Expand Down
8 changes: 4 additions & 4 deletions web/screens/LocalServer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const portAtom = atom('1337')
const LocalServerScreen = () => {
const [errorRangePort, setErrorRangePort] = useState(false)
const [serverEnabled, setServerEnabled] = useAtom(serverEnabledAtom)
const showing = useAtomValue(showRightSideBarAtom)
const showRightSideBar = useAtomValue(showRightSideBarAtom)
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)

const modelEngineParams = toSettingParams(activeModelParams)
Expand Down Expand Up @@ -117,7 +117,7 @@ const LocalServerScreen = () => {
<Button
block
themes={serverEnabled ? 'danger' : 'primary'}
disabled={stateModel.loading || errorRangePort}
disabled={stateModel.loading || errorRangePort || !selectedModel}
onClick={() => {
if (serverEnabled) {
window.core?.api?.stopServer()
Expand Down Expand Up @@ -347,13 +347,13 @@ const LocalServerScreen = () => {
<div
className={twMerge(
'h-full flex-shrink-0 overflow-x-hidden border-l border-border bg-background transition-all duration-100 dark:bg-background/20',
showing
showRightSideBar
? 'w-80 translate-x-0 opacity-100'
: 'w-0 translate-x-full opacity-0'
)}
>
<div className="px-4 pt-4">
<DropdownListSidebar />
<DropdownListSidebar strictedThread={false} />

{componentDataEngineSetting.filter(
(x) => x.name === 'prompt_template'
Expand Down

0 comments on commit 532a589

Please sign in to comment.