Merge pull request #1047 from SuanmoSuanyangTechnology/feature/memory_zy
feat(web): memory validation change api params
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 17:09:03
|
* @Date: 2026-02-03 17:09:03
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-04-20 16:59:25
|
* @Last Modified time: 2026-05-06 18:01:59
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Memory Conversation Page
|
* Memory Conversation Page
|
||||||
@@ -62,14 +62,13 @@ export interface TestParams {
|
|||||||
message: string;
|
message: string;
|
||||||
/** Search mode switch (0: deep thinking, 1: normal, 2: quick) */
|
/** Search mode switch (0: deep thinking, 1: normal, 2: quick) */
|
||||||
search_switch: string;
|
search_switch: string;
|
||||||
/** Conversation history */
|
|
||||||
history: { role: string; content: string }[];
|
|
||||||
/** Enable web keyword */
|
/** Enable web keyword */
|
||||||
web_search?: boolean;
|
web_search?: boolean;
|
||||||
/** Enable memory function */
|
/** Enable memory function */
|
||||||
memory?: boolean;
|
memory?: boolean;
|
||||||
/** Conversation ID */
|
/** Conversation ID */
|
||||||
conversation_id?: string;
|
conversation_id?: string;
|
||||||
|
session_id?: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Data item in analysis logs
|
* Data item in analysis logs
|
||||||
@@ -118,6 +117,7 @@ const MemoryConversation: FC = () => {
|
|||||||
const [search_switch, setSearchSwitch] = useState('0')
|
const [search_switch, setSearchSwitch] = useState('0')
|
||||||
const [msg, setMsg] = useState<string>('')
|
const [msg, setMsg] = useState<string>('')
|
||||||
const [expandedLogs, setExpandedLogs] = useState<Record<number, boolean>>({})
|
const [expandedLogs, setExpandedLogs] = useState<Record<number, boolean>>({})
|
||||||
|
const [sessionId, setSessionId] = useState<string | undefined>(undefined)
|
||||||
|
|
||||||
/** Handle message send */
|
/** Handle message send */
|
||||||
const handleSend = () => {
|
const handleSend = () => {
|
||||||
@@ -132,13 +132,14 @@ const MemoryConversation: FC = () => {
|
|||||||
message: msg,
|
message: msg,
|
||||||
end_user_id: userId,
|
end_user_id: userId,
|
||||||
search_switch: search_switch,
|
search_switch: search_switch,
|
||||||
history: [],
|
session_id: sessionId
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const response = res as { answer: string; intermediate_outputs: LogItem[] }
|
const response = res as { answer: string; intermediate_outputs: LogItem[]; session_id?: string; }
|
||||||
setChatData(prev => [...prev, { content: response.answer || '-', created_at: new Date().getTime(), role: 'assistant' }])
|
setChatData(prev => [...prev, { content: response.answer || '-', created_at: new Date().getTime(), role: 'assistant' }])
|
||||||
setLogs(response.intermediate_outputs)
|
setLogs(response.intermediate_outputs)
|
||||||
setExpandedLogs(Object.fromEntries(response.intermediate_outputs.map((_, i) => [i, true])))
|
setExpandedLogs(Object.fromEntries(response.intermediate_outputs.map((_, i) => [i, true])))
|
||||||
|
setSessionId(response.session_id)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@@ -153,6 +154,12 @@ const MemoryConversation: FC = () => {
|
|||||||
if (!file_path) return
|
if (!file_path) return
|
||||||
window.open(file_path, '_blank')
|
window.open(file_path, '_blank')
|
||||||
}
|
}
|
||||||
|
const handleChangeUser = (opt: DefaultOptionType) => {
|
||||||
|
setUserId(opt?.value as string)
|
||||||
|
setSessionId(undefined)
|
||||||
|
setChatData([])
|
||||||
|
setLogs([])
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -169,7 +176,7 @@ const MemoryConversation: FC = () => {
|
|||||||
}))}
|
}))}
|
||||||
placeholder={t('memoryConversation.searchPlaceholder')}
|
placeholder={t('memoryConversation.searchPlaceholder')}
|
||||||
style={{ width: '100%', marginBottom: '16px' }}
|
style={{ width: '100%', marginBottom: '16px' }}
|
||||||
onChange={(opt: DefaultOptionType) => setUserId(opt?.value as string)}
|
onChange={handleChangeUser}
|
||||||
variant="borderless"
|
variant="borderless"
|
||||||
className="rb:bg-white rb:rounded-lg"
|
className="rb:bg-white rb:rounded-lg"
|
||||||
showSearch
|
showSearch
|
||||||
|
|||||||
Reference in New Issue
Block a user