feat: 完善来源标注徽章功能和配置优化
后端改进: - 改进 addCitationsToResponse 函数,更激进地添加来源标注 - 支持识别所有有实质内容的行(长度>5) - 优化特殊行的识别逻辑,保留'依据引用'、'分析'、'建议'等内容行 - 修复 go.mod 中 lib/pq 的依赖问题 - 优化字符串拼接效率(使用 fmt.Fprintf) - 添加 Scanner 错误检查 前端改进: - 优化徽章样式,增大尺寸和间距 - 改用 bg-blue-100 和 bg-orange-100 背景 - 添加 hover 效果和 cursor-pointer 配置优化: - LLM 服务地址改为 IP(192.168.1.6:18888),支持外部调用 - 本地服务保持 localhost,性能更优 测试: - 新增 6 个单元测试用例,全部通过 - 验证清单项、列表项、陈述句等各种格式的标注 文档: - 添加实现方案文档 - 添加用户使用指南
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/enterprise-ai-platform/server/pkg/dify"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type ChatHandler struct {
|
||||
@@ -132,6 +133,10 @@ func (h *ChatHandler) Chat(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
log.Error().Err(err).Msg("scanner error reading from body")
|
||||
}
|
||||
|
||||
// Record usage asynchronously
|
||||
duration := time.Since(startTime).Milliseconds()
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user