Commit 83695999 authored by Joel's avatar Joel

feat: conversation support show thought

parent b62e34c6
...@@ -15,6 +15,5 @@ export async function POST(request: NextRequest, { params }: { ...@@ -15,6 +15,5 @@ export async function POST(request: NextRequest, { params }: {
// auto generate name // auto generate name
const { data } = await client.renameConversation(conversationId, name, user, auto_generate) const { data } = await client.renameConversation(conversationId, name, user, auto_generate)
console.log(conversationId, name, user, auto_generate)
return NextResponse.json(data) return NextResponse.json(data)
} }
...@@ -21,6 +21,7 @@ import { replaceVarWithValues, userInputsFormToPromptVariables } from '@/utils/p ...@@ -21,6 +21,7 @@ import { replaceVarWithValues, userInputsFormToPromptVariables } from '@/utils/p
import AppUnavailable from '@/app/components/app-unavailable' import AppUnavailable from '@/app/components/app-unavailable'
import { API_KEY, APP_ID, APP_INFO, isShowPrompt, promptTemplate } from '@/config' import { API_KEY, APP_ID, APP_INFO, isShowPrompt, promptTemplate } from '@/config'
import type { Annotation as AnnotationType } from '@/types/log' import type { Annotation as AnnotationType } from '@/types/log'
import { addFileInfos, sortAgentSorts } from '@/utils/tools'
const Main: FC = () => { const Main: FC = () => {
const { t } = useTranslation() const { t } = useTranslation()
...@@ -130,13 +131,16 @@ const Main: FC = () => { ...@@ -130,13 +131,16 @@ const Main: FC = () => {
id: `question-${item.id}`, id: `question-${item.id}`,
content: item.query, content: item.query,
isAnswer: false, isAnswer: false,
message_files: item.message_files, message_files: item.message_files?.filter((file: any) => file.belongs_to === 'user') || [],
}) })
newChatList.push({ newChatList.push({
id: item.id, id: item.id,
content: item.answer, content: item.answer,
agent_thoughts: addFileInfos(item.agent_thoughts ? sortAgentSorts(item.agent_thoughts) : item.agent_thoughts, item.message_files),
feedback: item.feedback, feedback: item.feedback,
isAnswer: true, isAnswer: true,
message_files: item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [],
}) })
}) })
setChatList(newChatList) setChatList(newChatList)
......
import type { ThoughtItem } from '@/app/components/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
})
}
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