refertor:使用antdX重构dify聊天渲染组件,到处引用文件
This commit is contained in:
@@ -3,7 +3,7 @@ import { useState } from 'react';
|
||||
import type { ChatItem, Feedbacktype } from '~/api/dify-chat';
|
||||
import '../../styles/components/chat-with-llm/chat-message.css';
|
||||
import { parseMessageContent } from '../../utils/message-parser';
|
||||
import Markdown from './markdown';
|
||||
import Markdown, { SourcesPanel } from './markdown';
|
||||
import ThinkingBlock from './thinking-block';
|
||||
import ThoughtProcess from './thought-process';
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function ChatMessage({
|
||||
message.feedback?.rating || null
|
||||
);
|
||||
|
||||
const { id, content, isAnswer, agent_thoughts, message_files, isOpeningStatement, suggestedQuestions, more } = message;
|
||||
const { id, content, isAnswer, agent_thoughts, message_files, isOpeningStatement, suggestedQuestions, more, retriever_resources } = message;
|
||||
const isAgentMode = !!agent_thoughts && agent_thoughts.length > 0;
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,10 @@ export default function ChatMessage({
|
||||
<div key={index}>
|
||||
{thought.thought && (
|
||||
<div className={isResponding && index === agent_thoughts.length - 1 ? 'streaming-text' : ''}>
|
||||
<Markdown content={thought.thought} />
|
||||
<Markdown
|
||||
content={thought.thought}
|
||||
retrieverResources={index === agent_thoughts.length - 1 ? retriever_resources : undefined}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{thought.tool && (
|
||||
@@ -98,7 +101,7 @@ export default function ChatMessage({
|
||||
{/* 实际回复内容 */}
|
||||
{parsed.response && (
|
||||
<div className={isResponding ? 'streaming-text' : ''}>
|
||||
<Markdown content={parsed.response} />
|
||||
<Markdown content={parsed.response} retrieverResources={retriever_resources} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -184,6 +187,12 @@ export default function ChatMessage({
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
{/* 引用来源面板 - 放在气泡外面 */}
|
||||
{isAnswer && retriever_resources && retriever_resources.length > 0 && (
|
||||
<div className="sources-panel-wrapper">
|
||||
<SourcesPanel resources={retriever_resources} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user