博客内容Blog Content
升级网页AI知识库聊天机器人 Upgrade Web AI Knowledge Base Chatbot
使用SpringAI+SSE等技术重构了原来的聊天机器人,实现更快的加载、更准确的回复、以及更合理的架构设计 Refactored the original chatbot using technologies like SpringAI and SSE to achieve faster loading, more accurate responses, and a more reasonable architectural design.
背景 Background
在之前的v1版本中,虽然使用纯SpringBoot原生框架实现了RAG搜索,但仍有以下问题:
调用大模型接口使用同步模式,需要大模型回复完才把内容进行前端加载,看不到中间结果+需要等待时间长
没有上下文记忆功能
不支持markdown格式
不支持联网搜索
手动维护mysql知识库较繁琐
In the previous v1 version, although the RAG search was implemented using the native SpringBoot framework, there were still the following issues:
Calling large model APIs used a synchronous mode, which required the model to finish generating a response before loading it on the frontend. This caused long waiting times without any intermediate output.
No context memory functionality.
No support for Markdown format.
No support for online search.
Manual maintenance of the MySQL knowledge base was cumbersome.
架构优化点 Architecture Optimization Points
本次v2优化,添加了以下功能:
引入了SpringAI,集成了知识库维护、上下文记忆等功能,无需手动实现
引入了SSE(server-sent events)优化前端,使得模型回答途中的流输出得到前端加载,同时支持markdown格式
引入了SearXNG搜索引擎,能支持联网查询,并将相关结果整合到回答中
In this v2 upgrade, the following features were added:
Introduced SpringAI, which integrates features such as knowledge base maintenance and context memory without manual implementation.
Introduced SSE (Server-Sent Events) to optimize the frontend, enabling streaming output of model responses to be loaded in real-time, with Markdown format support.
Integrated the SearXNG search engine to support online queries and incorporate relevant results into answers.
引入MCP进行优化 Introducing MCP for optimaztion
进一步优化,通过引入MCP带来以下好处:
将查询知识库和联网查询改成MCP功能,由LLM自身决定是否调用(更智能、灵活),而不是手动调用知识库和网络查询
提供其他MCP相关支持提高模型能力
We further optimize by introducing MCP to bring more benefits as follows:
Replace querying the knowledge base and online search with MCP functionality, allowing the LLM to decide whether to invoke it on its own. (smarter & more flexible), rather than manually doing knowledge & Internet searches
Provide additional MCP-related support to enhance the model's capabilities.
待支持功能 Features to be supported
待支持相关功能:
提供更多MCP功能获取网页数据:博客信息、可视化数据、新闻总结等
将聊天功能做成弹窗,在每个页面都嵌入支持
实现 会话隔离
Planned features to be supported:
Provide more MCP functions for website's data like: blog information, visualization data and news summaries.
Implement the chat feature as a popup window and embed it on every page for support.