Skip to content

Commit

Permalink
fix: #1594 - Model settings - change thread model - go back does not …
Browse files Browse the repository at this point in the history
…see according settings (#1595)
  • Loading branch information
louis-jan committed Jan 15, 2024
1 parent 2691278 commit e3a06aa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions web/hooks/useSetActiveThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import { useAtomValue, useSetAtom } from 'jotai'
import { extensionManager } from '@/extension'
import { setConvoMessagesAtom } from '@/helpers/atoms/ChatMessage.atom'
import {
ModelParams,
getActiveThreadIdAtom,
setActiveThreadIdAtom,
setThreadModelParamsAtom,
} from '@/helpers/atoms/Thread.atom'

export default function useSetActiveThread() {
const activeThreadId = useAtomValue(getActiveThreadIdAtom)
const setActiveThreadId = useSetAtom(setActiveThreadIdAtom)
const setThreadMessage = useSetAtom(setConvoMessagesAtom)
const setThreadModelParams = useSetAtom(setThreadModelParamsAtom)

const setActiveThread = async (thread: Thread) => {
if (activeThreadId === thread.id) {
Expand All @@ -35,6 +38,11 @@ export default function useSetActiveThread() {
setThreadMessage(thread.id, messages ?? [])

setActiveThreadId(thread.id)
const modelParams: ModelParams = {
...thread.assistants[0]?.model?.parameters,
...thread.assistants[0]?.model?.settings,
}
setThreadModelParams(thread.id, modelParams)
}

return { activeThreadId, setActiveThread }
Expand Down

0 comments on commit e3a06aa

Please sign in to comment.