feat: 添加 AI 记账服务

This commit is contained in:
2026-01-30 00:10:00 +08:00
parent 177f4e5b14
commit 8bae0df1b6

View File

@@ -986,7 +986,8 @@ func (s *AIBookkeepingService) ProcessChat(ctx context.Context, userID uint, ses
}
// 4. 处理消费建议意图
if isSpendingAdvice && session.Params.Amount != nil {
// 即使没有金额,如果用户是在寻求建议(如“吃什么”),也应该进入建议流程
if isSpendingAdvice {
response.Intent = "spending_advice"
advice := s.generateSpendingAdvice(ctx, message, session.Params, fc)
if advice != "" {
@@ -1158,7 +1159,7 @@ func (s *AIBookkeepingService) callLLM(ctx context.Context, messages []ChatMessa
// isSpendingAdviceIntent 检测是否为消费建议意图
func (s *AIBookkeepingService) isSpendingAdviceIntent(message string) bool {
keywords := []string{"想吃", "想喝", "想买", "想花", "打算买", "准备买", "要不要", "可以买", "能买", "想要"}
keywords := []string{"想吃", "想喝", "想买", "想花", "打算买", "准备买", "要不要", "可以买", "能买", "想要", "推荐", "吃什么", "喝什么", "买什么"}
for _, kw := range keywords {
if strings.Contains(message, kw) {
return true