feat: add Timestamp field to Message struct
- Add Timestamp field to Message struct in pkg/providers/types.go - Automatically set timestamp in AddMessage and AddFullMessage methods in pkg/session/manager.go - Timestamp is stored as Unix timestamp (int64)
This commit is contained in:
parent
8807d8254f
commit
15beffc98c
2 changed files with 7 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ type Message struct {
|
|||
Content string `json:"content"`
|
||||
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
||||
ToolCallID string `json:"tool_call_id,omitempty"`
|
||||
Timestamp int64 `json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
type LLMProvider interface {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ func (sm *SessionManager) AddMessage(sessionKey, role, content string) {
|
|||
sm.AddFullMessage(sessionKey, providers.Message{
|
||||
Role: role,
|
||||
Content: content,
|
||||
Timestamp: time.Now().Unix(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +83,11 @@ func (sm *SessionManager) AddFullMessage(sessionKey string, msg providers.Messag
|
|||
sm.sessions[sessionKey] = session
|
||||
}
|
||||
|
||||
// Set timestamp if not already set
|
||||
if msg.Timestamp == 0 {
|
||||
msg.Timestamp = time.Now().Unix()
|
||||
}
|
||||
|
||||
session.Messages = append(session.Messages, msg)
|
||||
session.Updated = time.Now()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue