Files
ai-customer-service/internal/store/memory/knowledge_store.go
Your Name cf46b27610 fix: P0-1 RateLimiter并发写安全 + P0-2工单操作错误码区分 + P1 rows.Close修复
P0-1 (limits.go): Allow()方法改为全程使用写锁保护counters map读写,避免RLock写入时的data race
P0-2 (ticket_workflow.go+ticket_handler.go): Assign/Resolve/Close操作先查询ticket存在性和状态,返回明确的CS_TICKET_4001/CS_TKT_4002/CS_TICKET_4092/CS_TICKET_4093错误码,handler根据错误前缀路由HTTP状态码
P1-1 (ticket_store.go): 移除GetStats中3处手动rows.Close(),只保留defer Close()
2026-05-01 20:56:25 +08:00

22 lines
864 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package memory
type KnowledgeStore struct {
answers map[string]string
}
func NewKnowledgeStore() *KnowledgeStore {
return &KnowledgeStore{answers: map[string]string{
"quota": "当前版本暂未接入实时配额查询,建议先在控制台查看配额页;如需人工协助请回复人工客服。",
"token": "当前版本暂未接入实时 Token 统计,建议先查看控制台用量页;如需人工协助请回复人工客服。",
"error": "若您遇到错误,请提供报错时间、请求 ID 和复现步骤,我们会优先协助排查。",
"general": "已收到您的问题。当前系统可处理常见 FAQ若问题复杂或涉及账户安全会自动转人工。",
}}
}
func (s *KnowledgeStore) Answer(intent string) string {
if answer, ok := s.answers[intent]; ok {
return answer
}
return s.answers["general"]
}