feat(audit): persist message source and token usage

This commit is contained in:
姚章浩
2026-07-15 13:41:41 +08:00
parent 4022040e98
commit 9645de64a1
15 changed files with 385 additions and 23 deletions
+7 -3
View File
@@ -1,5 +1,7 @@
package event
import "github.com/Tencent/WeKnora/internal/types"
// EventData contains common event data structures for different stages
// QueryData represents query-related event data
@@ -142,6 +144,7 @@ type AgentCompleteData struct {
TotalDurationMs int64 `json:"total_duration_ms"`
MessageID string `json:"message_id,omitempty"` // Assistant message ID
RequestID string `json:"request_id,omitempty"`
TokenUsage *types.TokenUsage `json:"token_usage,omitempty"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
@@ -184,9 +187,10 @@ type AgentReferencesData struct {
// AgentFinalAnswerData represents final answer streaming data
type AgentFinalAnswerData struct {
Content string `json:"content"`
Done bool `json:"done"`
IsFallback bool `json:"is_fallback,omitempty"` // True when response is a fallback (no knowledge base match)
Content string `json:"content"`
Done bool `json:"done"`
IsFallback bool `json:"is_fallback,omitempty"` // True when response is a fallback (no knowledge base match)
TokenUsage *types.TokenUsage `json:"token_usage,omitempty"`
}
// AgentReflectionData represents agent reflection data