RAG 聊天
检索增强生成——与文档对话。在 AI 回复旁展示引用、来源与文档上下文。
配合 AgentsKit
import { useChat, ChatContainer, Message, InputBar } from '@agentskit/react'
function RAGChat() {
const chat = useChat({
adapter: myRAGAdapter,
initialMessages: [{
id: 'sys', role: 'system',
content: 'Answer based on the provided documents. Cite sources.',
status: 'complete', createdAt: new Date()
}],
})
return (
<ChatContainer>
{chat.messages.map(msg => (
<Message key={msg.id} message={msg} />
))}
<InputBar chat={chat} placeholder="Ask about your documents..." />
</ChatContainer>
)
}