Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions frontend/src/pages/chatPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import CheckGroup from './components/check-group';
import Inspiration from './components/inspiration';
import PreviewPicture from './components/receive-box/preview-picture';
import './styles/chat-preview.scss';
import store from '@/store/store';
import {setIsCurrentAnswer} from "@/store/chatStore/chatStore";

/**
* 应用聊天对话页面
Expand Down Expand Up @@ -92,6 +94,7 @@ const ChatPreview = (props) => {
const isDebug = useAppSelector((state) => state.commonStore.isDebug);
const isGuest = useAppSelector((state) => state.appStore.isGuest);
const currentAnswer = useAppSelector((state) => state.chatCommonStore.currentAnswer);
const isCurrentAnswer = useAppSelector((state) => state.chatCommonStore.isCurrentAnswer);
const { showElsa } = useContext(AippContext);
const [checkedList, setCheckedList] = useState([]);
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -586,6 +589,7 @@ const ChatPreview = (props) => {
let { content } = currentChatItem;
str = content + msg;
item.content = str;
store.dispatch(setIsCurrentAnswer(true));
if (status === 'ARCHIVED') {
item.finished = true;
}
Expand Down Expand Up @@ -646,8 +650,8 @@ const ChatPreview = (props) => {
// 终止进行中的对话
async function chatRunningStop(params) {
let terminateParams: any = {};
terminateParams.content = params.content ? params.content : currentAnswer ? currentAnswer :
t('conversationTerminated');
terminateParams.content = params.content ? params.content : currentAnswer ?
parseCurrentAnswer(currentAnswer) : t('conversationTerminated');
if (params.logId) {
terminateParams.logId = params.logId;
}
Expand All @@ -671,6 +675,14 @@ const ChatPreview = (props) => {
}
}

function parseCurrentAnswer(currentAnswer) {
if (currentAnswer && currentAnswer.props && currentAnswer.props.dangerouslySetInnerHTML
&& isCurrentAnswer == true) {
store.dispatch(setIsCurrentAnswer(false));
return currentAnswer.props.dangerouslySetInnerHTML.__html;
}
}

// 表单重新对话
function questionClarConfirm(params, instanceId) {
queryInstance(params, 'clar', instanceId);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/store/chatStore/action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export const SET_READ_ONLY = 'SET_READ_ONLY';
export const SET_NO_AUTH = 'SET_NO_AUTH';
export const SET_PLUGIN_LIST = 'SET_PLUGIN_LIST';
export const SET_CURRENT_ANSWER = 'SET_CURRENT_ANSWER';
export const SET_IS_CURRENT_ANSWER = 'SET_IS_CURRENT_ANSWER';
14 changes: 13 additions & 1 deletion frontend/src/store/chatStore/chatStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
SET_NO_AUTH,
SET_USER_ROLE,
SET_PLUGIN_LIST,
SET_CURRENT_ANSWER
SET_CURRENT_ANSWER,
SET_KNOWLEDGE_CONFIG,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image 看起来缺少两个常量

SET_SHOW_CHAT_HISTORY,
SET_IS_CURRENT_ANSWER
} from './action-types';

export const setChatId = (item) => {
Expand Down Expand Up @@ -65,3 +68,12 @@ export const setPluginList = (item) => {
export const setCurrentAnswer = (item) => {
return { type: SET_CURRENT_ANSWER, payload: item }
}
export const setIsCurrentAnswer = (item) => {
return { type: SET_IS_CURRENT_ANSWER, payload: item }
}
export const setKnowledgeConfig = (item) => {
return { type: SET_KNOWLEDGE_CONFIG, payload: item }
}
export const setShowChatHistory = (item) => {
return { type: SET_SHOW_CHAT_HISTORY, payload: item }
}
16 changes: 14 additions & 2 deletions frontend/src/store/chatStore/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
SET_READ_ONLY,
SET_NO_AUTH,
SET_PLUGIN_LIST,
SET_CURRENT_ANSWER
SET_CURRENT_ANSWER,
SET_KNOWLEDGE_CONFIG,
SET_SHOW_CHAT_HISTORY,
SET_IS_CURRENT_ANSWER
} from './action-types';

const initialState = {
Expand All @@ -33,7 +36,10 @@ const initialState = {
readOnly: false,
noAuth: false,
pluginList: [],
currentAnswer: ''
currentAnswer: '',
knowledgeConfig: null,
showChatHistory: false,
isCurrentAnswer: false
}

const chatReducers = (state = initialState, action) => {
Expand Down Expand Up @@ -70,6 +76,12 @@ const chatReducers = (state = initialState, action) => {
return { ...state, pluginList: action.payload };
case SET_CURRENT_ANSWER:
return { ...state, currentAnswer: action.payload };
case SET_IS_CURRENT_ANSWER:
return { ...state, isCurrentAnswer: action.payload };
case SET_KNOWLEDGE_CONFIG:
return { ...state, knowledgeConfig: action.payload };
case SET_SHOW_CHAT_HISTORY:
return { ...state, showChatHistory: action.payload };
default:
return state
}
Expand Down