Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk committed Jul 12, 2024
1 parent 7aa7db5 commit 54800a5
Showing 1 changed file with 42 additions and 17 deletions.
59 changes: 42 additions & 17 deletions projects/app/src/pages/chat/team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import { useContextSelector } from 'use-context-selector';
import { InitChatResponse } from '@/global/core/chat/api';
import { defaultChatData } from '@/global/core/chat/constants';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import CustomPluginRunBox from './components/CustomPluginRunBox';
import { getNanoid } from '@fastgpt/global/common/string/tools';
import { useChat } from '@/components/core/chat/ChatContainer/useChat';

type Props = { appId: string; chatId: string; teamId: string; teamToken: string };

Expand Down Expand Up @@ -65,6 +68,8 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
onChangeChatId
} = useContextSelector(ChatContext, (v) => v);

const { chatRecords, setChatRecords, variablesForm, pluginRunTab, setPluginRunTab } = useChat();

const startChat = useCallback(
async ({ messages, controller, generatingMessage, variables }: StartChatFnProps) => {
const prompts = messages.slice(-2);
Expand Down Expand Up @@ -241,23 +246,43 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
/>
{/* chat box */}
<Box flex={1}>
<ChatBox
ref={ChatBoxRef}
appAvatar={chatData.app.avatar}
userAvatar={chatData.userAvatar}
chatConfig={chatData.app?.chatConfig}
showFileSelector={checkChatSupportSelectFileByChatModels(chatData.app.chatModels)}
feedbackType={'user'}
onUpdateVariable={(e) => {}}
onStartChat={startChat}
onDelMessage={({ contentId }) =>
delChatRecordById({ contentId, appId: chatData.appId, chatId, teamId, teamToken })
}
appId={chatData.appId}
chatId={chatId}
teamId={teamId}
teamToken={teamToken}
/>
{chatData.app.type === AppTypeEnum.plugin ? (
<CustomPluginRunBox
pluginInputs={chatData.app.pluginInputs}
variablesForm={variablesForm}
histories={chatRecords}
setHistories={setChatRecords}
appId={chatData.appId}
tab={pluginRunTab}
setTab={setPluginRunTab}
onNewChat={() => onChangeChatId(getNanoid())}
onStartChat={startChat}
/>
) : (
<ChatBox
ref={ChatBoxRef}
appAvatar={chatData.app.avatar}
userAvatar={chatData.userAvatar}
chatConfig={chatData.app?.chatConfig}
showFileSelector={checkChatSupportSelectFileByChatModels(chatData.app.chatModels)}
feedbackType={'user'}
onUpdateVariable={(e) => {}}
onStartChat={startChat}
onDelMessage={({ contentId }) =>
delChatRecordById({
contentId,
appId: chatData.appId,
chatId,
teamId,
teamToken
})
}
appId={chatData.appId}
chatId={chatId}
teamId={teamId}
teamToken={teamToken}
/>
)}
</Box>
</Flex>
</Flex>
Expand Down

0 comments on commit 54800a5

Please sign in to comment.