feat(memory): add Tags and Metadata to SessionMessage for frontmatter support
This commit is contained in:
parent
2b75c88428
commit
57eb3fc169
2 changed files with 31 additions and 0 deletions
|
|
@ -6,6 +6,14 @@ import (
|
||||||
"github.com/sipeed/picoclaw/pkg/providers"
|
"github.com/sipeed/picoclaw/pkg/providers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SessionMessage represents a message in a session with optional tags and metadata.
|
||||||
|
type SessionMessage struct {
|
||||||
|
Role string
|
||||||
|
Content string
|
||||||
|
Tags []string
|
||||||
|
Metadata map[string]interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// Store defines an interface for persistent session storage.
|
// Store defines an interface for persistent session storage.
|
||||||
// Each method is an atomic operation — there is no separate Save() call.
|
// Each method is an atomic operation — there is no separate Save() call.
|
||||||
type Store interface {
|
type Store interface {
|
||||||
|
|
|
||||||
23
pkg/memory/store_test.go
Normal file
23
pkg/memory/store_test.go
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSessionMessage_WithFrontmatter(t *testing.T) {
|
||||||
|
msg := SessionMessage{
|
||||||
|
Role: "user",
|
||||||
|
Content: "test content",
|
||||||
|
Tags: []string{"coding", "golang"},
|
||||||
|
Metadata: map[string]interface{}{
|
||||||
|
"session_id": "abc123",
|
||||||
|
"model": "claude-sonnet-4",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if len(msg.Tags) != 2 {
|
||||||
|
t.Errorf("expected 2 tags, got %d", len(msg.Tags))
|
||||||
|
}
|
||||||
|
if msg.Metadata["session_id"] != "abc123" {
|
||||||
|
t.Errorf("expected session_id in metadata")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue