mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-14 20:41:21 +08:00
7bbe12b2bd
Co-authored-by: StyleZhang <jasonapring2015@outlook.com>
27 lines
735 B
TypeScript
27 lines
735 B
TypeScript
import type { ThoughtItem } from '../../app/chat/type'
|
|
import type { VisionFile } from '@/types/app'
|
|
|
|
export const sortAgentSorts = (list: ThoughtItem[]) => {
|
|
if (!list)
|
|
return list
|
|
if (list.some(item => item.position === undefined))
|
|
return list
|
|
const temp = [...list]
|
|
temp.sort((a, b) => a.position - b.position)
|
|
return temp
|
|
}
|
|
|
|
export const addFileInfos = (list: ThoughtItem[], messageFiles: VisionFile[]) => {
|
|
if (!list || !messageFiles)
|
|
return list
|
|
return list.map((item) => {
|
|
if (item.files && item.files?.length > 0) {
|
|
return {
|
|
...item,
|
|
message_files: item.files.map(fileId => messageFiles.find(file => file.id === fileId)) as VisionFile[],
|
|
}
|
|
}
|
|
return item
|
|
})
|
|
}
|