fix: multiple model configuration clear conversation by rerender (#2286)

This commit is contained in:
zxhlyh
2024-01-30 16:06:01 +08:00
committed by GitHub
parent 6f7fd6613a
commit 68406b9906
22 changed files with 816 additions and 712 deletions

View File

@@ -2,23 +2,20 @@
import type { ReactNode } from 'react'
import { createContext, useContext } from 'use-context-selector'
import type {
ChatConfig,
ChatItem,
OnSend,
} from '../types'
import type { Emoji } from '@/app/components/tools/types'
import type { ChatProps } from './index'
export type ChatContextValue = {
config?: ChatConfig
isResponsing?: boolean
chatList: ChatItem[]
showPromptLog?: boolean
questionIcon?: ReactNode
answerIcon?: ReactNode
allToolIcons?: Record<string, string | Emoji>
onSend?: OnSend
}
export type ChatContextValue = Pick<ChatProps, 'config'
| 'isResponsing'
| 'chatList'
| 'showPromptLog'
| 'questionIcon'
| 'answerIcon'
| 'allToolIcons'
| 'onSend'
| 'onAnnotationEdited'
| 'onAnnotationAdded'
| 'onAnnotationRemoved'
>
const ChatContext = createContext<ChatContextValue>({
chatList: [],
@@ -38,6 +35,9 @@ export const ChatContextProvider = ({
answerIcon,
allToolIcons,
onSend,
onAnnotationEdited,
onAnnotationAdded,
onAnnotationRemoved,
}: ChatContextProviderProps) => {
return (
<ChatContext.Provider value={{
@@ -49,6 +49,9 @@ export const ChatContextProvider = ({
answerIcon,
allToolIcons,
onSend,
onAnnotationEdited,
onAnnotationAdded,
onAnnotationRemoved,
}}>
{children}
</ChatContext.Provider>