Commit ab108d61 authored by 金伟强's avatar 金伟强

Merge branch 'feat/universal-chat-fe' into deploy/dev

parents f9072510 71f96123
...@@ -30,14 +30,32 @@ const Thought: FC<IThoughtProps> = ({ ...@@ -30,14 +30,32 @@ const Thought: FC<IThoughtProps> = ({
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [isShowDetail, setIsShowDetail] = React.useState(false) const [isShowDetail, setIsShowDetail] = React.useState(false)
const getThoughtText = (item: ThoughtItem) => {
try {
const input = JSON.parse(item.tool_input)
switch (item.tool) {
case 'dataset':
// debugger
return t('explore.universalChat.thought.res.dataset', { input: input.dataset_id })
case 'web_reader':
return t(`explore.universalChat.thought.res.webReader.${!input.cursor ? 'normal' : 'hasPageInfo'}`).replace('{url}', `<a href="${input.url}" class="text-[#155EEF]">${input.url}</a>`)
default: // google, wikipedia
return t('explore.universalChat.thought.res.search', { query: input.query })
}
}
catch (error) {
console.error(error)
return item
}
}
const renderItem = (item: ThoughtItem) => ( const renderItem = (item: ThoughtItem) => (
<div className='flex space-x-1 py-[3px] leading-[18px]' key={item.id}> <div className='flex space-x-1 py-[3px] leading-[18px]' key={item.id}>
<div className='flex items-center h-[18px] shrink-0'>{getIcon(item.tool)}</div> <div className='flex items-center h-[18px] shrink-0'>{getIcon(item.tool)}</div>
<div dangerouslySetInnerHTML={{ <div dangerouslySetInnerHTML={{
__html: item.thought.replace(urlRegex, (url) => { __html: getThoughtText(item),
return `<a href="${url}" class="text-[#155EEF]">${url}</a>` // item.thought.replace(urlRegex, (url) => {
}), // return `<a href="${url}" class="text-[#155EEF]">${url}</a>`
// }),
}}></div> }}></div>
</div> </div>
) )
......
...@@ -20,6 +20,7 @@ export type ThoughtItem = { ...@@ -20,6 +20,7 @@ export type ThoughtItem = {
id: string id: string
tool: string // plugin or dataset tool: string // plugin or dataset
thought: string thought: string
tool_input: string
} }
export type IChatItem = { export type IChatItem = {
id: string id: string
......
...@@ -506,6 +506,7 @@ const Main: FC<IMainProps> = () => { ...@@ -506,6 +506,7 @@ const Main: FC<IMainProps> = () => {
} }
}, },
onThought(thought) { onThought(thought) {
// debugger
// thought then start to return message // thought then start to return message
(responseItem as any).agent_thoughts.push(thought) (responseItem as any).agent_thoughts.push(thought)
}, },
......
...@@ -60,6 +60,14 @@ const translation = { ...@@ -60,6 +60,14 @@ const translation = {
show: 'Show', show: 'Show',
hide: 'Hide', hide: 'Hide',
processOfThought: ' the process of thinking', processOfThought: ' the process of thinking',
res: {
webReader: {
normal: 'Reading {url}',
hasPageInfo: 'Reading next page of {url}',
},
search: 'Searching {{query}}',
dataset: 'Retrieving dataset {{datasetName}}',
},
}, },
viewConfigDetailTip: 'In conversation, cannot change above settings', viewConfigDetailTip: 'In conversation, cannot change above settings',
}, },
......
...@@ -59,6 +59,14 @@ const translation = { ...@@ -59,6 +59,14 @@ const translation = {
show: '显示', show: '显示',
hide: '隐藏', hide: '隐藏',
processOfThought: '思考过程', processOfThought: '思考过程',
res: {
webReader: {
normal: '解析链接 {url}',
hasPageInfo: '解析链接 {url} 的下一页',
},
search: '搜索 {{query}}',
dataset: '检索数据集 {{dataset}}',
},
}, },
viewConfigDetailTip: '在对话中,无法更改上述设置', viewConfigDetailTip: '在对话中,无法更改上述设置',
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment