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