Skip to content

Commit

Permalink
fix stop model first then start model when change on right panel setting
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 17, 2024
1 parent 9fa684e commit 95225c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions web/containers/DropdownListSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function DropdownListSidebar() {
const threadStates = useAtomValue(threadStatesAtom)
const [selectedModel, setSelectedModel] = useAtom(selectedModelAtom)
const setThreadModelParams = useSetAtom(setThreadModelParamsAtom)
const { activeModel, startModel, stateModel } = useActiveModel()
const { activeModel, startModel, stateModel, stopModel } = useActiveModel()
const [serverEnabled, setServerEnabled] = useAtom(serverEnabledAtom)

const { setMainViewState } = useMainViewState()
Expand Down Expand Up @@ -142,12 +142,14 @@ export default function DropdownListSidebar() {
}, [stateModel.loading, loader])

const onValueSelected = useCallback(
(modelId: string) => {
async (modelId: string) => {
const model = downloadedModels.find((m) => m.id === modelId)
setSelectedModel(model)

await stopModel()

if (activeModel?.id !== modelId) {
startModel(modelId)
await startModel(modelId)
}

if (serverEnabled) {
Expand All @@ -168,6 +170,7 @@ export default function DropdownListSidebar() {
downloadedModels,
serverEnabled,
activeThreadId,
activeModel,
setSelectedModel,
setThreadModelParams,
]
Expand All @@ -184,7 +187,7 @@ export default function DropdownListSidebar() {
<div
className={twMerge(
'relative w-full overflow-hidden rounded-md',
stateModel.loading && 'bg-blue-200 text-blue-600'
stateModel.loading && 'pointer-events-none bg-blue-200 text-blue-600'
)}
>
<Select value={selected?.id} onValueChange={onValueSelected}>
Expand Down Expand Up @@ -244,7 +247,9 @@ export default function DropdownListSidebar() {
value={x.id}
className={twMerge(x.id === selected?.id && 'bg-secondary')}
onPointerUp={() => {
startModel(x.id)
if (x.id === selected?.id) {
startModel(x.id)
}
}}
>
<div className="flex w-full justify-between">
Expand Down
2 changes: 1 addition & 1 deletion web/containers/Loader/ModelStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function ModelStart() {

// This is fake loader please fix this when we have realtime percentage when load model
useEffect(() => {
if (stateModel.loading) {
if (stateModel.loading && stateModel.state === 'start') {
if (loader === 24) {
setTimeout(() => {
setLoader(loader + 1)
Expand Down

0 comments on commit 95225c3

Please sign in to comment.