fix: infinite talking in auto thread titles generators (#2810)
This commit is contained in:
parent
7d4cc67aa1
commit
b4b8c862c0
@ -20,6 +20,8 @@ import { ulid } from 'ulidx'
|
|||||||
|
|
||||||
import { activeModelAtom, stateModelAtom } from '@/hooks/useActiveModel'
|
import { activeModelAtom, stateModelAtom } from '@/hooks/useActiveModel'
|
||||||
|
|
||||||
|
import { toRuntimeParams } from '@/utils/modelParam'
|
||||||
|
|
||||||
import { extensionManager } from '@/extension'
|
import { extensionManager } from '@/extension'
|
||||||
import {
|
import {
|
||||||
getCurrentChatMessagesAtom,
|
getCurrentChatMessagesAtom,
|
||||||
@ -32,6 +34,7 @@ import {
|
|||||||
threadsAtom,
|
threadsAtom,
|
||||||
isGeneratingResponseAtom,
|
isGeneratingResponseAtom,
|
||||||
updateThreadAtom,
|
updateThreadAtom,
|
||||||
|
getActiveThreadModelParamsAtom,
|
||||||
} from '@/helpers/atoms/Thread.atom'
|
} from '@/helpers/atoms/Thread.atom'
|
||||||
|
|
||||||
const maxWordForThreadTitle = 10
|
const maxWordForThreadTitle = 10
|
||||||
@ -54,6 +57,8 @@ export default function EventHandler({ children }: { children: ReactNode }) {
|
|||||||
const updateThread = useSetAtom(updateThreadAtom)
|
const updateThread = useSetAtom(updateThreadAtom)
|
||||||
const messagesRef = useRef(messages)
|
const messagesRef = useRef(messages)
|
||||||
const activeModelRef = useRef(activeModel)
|
const activeModelRef = useRef(activeModel)
|
||||||
|
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)
|
||||||
|
const activeModelParamsRef = useRef(activeModelParams)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
threadsRef.current = threads
|
threadsRef.current = threads
|
||||||
@ -71,6 +76,10 @@ export default function EventHandler({ children }: { children: ReactNode }) {
|
|||||||
activeModelRef.current = activeModel
|
activeModelRef.current = activeModel
|
||||||
}, [activeModel])
|
}, [activeModel])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
activeModelParamsRef.current = activeModelParams
|
||||||
|
}, [activeModelParams])
|
||||||
|
|
||||||
const onNewMessageResponse = useCallback(
|
const onNewMessageResponse = useCallback(
|
||||||
(message: ThreadMessage) => {
|
(message: ThreadMessage) => {
|
||||||
if (message.type === MessageRequestType.Thread) {
|
if (message.type === MessageRequestType.Thread) {
|
||||||
@ -247,6 +256,8 @@ export default function EventHandler({ children }: { children: ReactNode }) {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const runtimeParams = toRuntimeParams(activeModelParamsRef.current)
|
||||||
|
|
||||||
const messageRequest: MessageRequest = {
|
const messageRequest: MessageRequest = {
|
||||||
id: msgId,
|
id: msgId,
|
||||||
threadId: message.thread_id,
|
threadId: message.thread_id,
|
||||||
@ -255,6 +266,7 @@ export default function EventHandler({ children }: { children: ReactNode }) {
|
|||||||
model: {
|
model: {
|
||||||
...activeModelRef.current,
|
...activeModelRef.current,
|
||||||
parameters: {
|
parameters: {
|
||||||
|
...runtimeParams,
|
||||||
stream: false,
|
stream: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user