Skip to content

Commit 5d4f5d7

Browse files
Annhiluccopybara-github
authored andcommitted
feat: Add types to support continuous sessions with a sliding window
PiperOrigin-RevId: 745348707
1 parent 4a92461 commit 5d4f5d7

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

types.go

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types_json_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,41 @@ func TestMarshalJSON(t *testing.T) {
557557
wantErr: false,
558558
target: "File",
559559
},
560+
// SlidingWindow tests
561+
{
562+
name: "SlidingWindow empty",
563+
input: &SlidingWindow{},
564+
want: `{}`,
565+
wantErr: false,
566+
target: "SlidingWindow",
567+
},
568+
{
569+
name: "SlidingWindow with all fields",
570+
input: &SlidingWindow{
571+
TargetTokens: 1024,
572+
},
573+
want: `{"targetTokens":"1024"}`,
574+
wantErr: false,
575+
target: "SlidingWindow",
576+
},
577+
// ContextWindowCompressionConfig tests
578+
{
579+
name: "ContextWindowCompressionConfig empty",
580+
input: &ContextWindowCompressionConfig{},
581+
want: `{}`,
582+
wantErr: false,
583+
target: "ContextWindowCompressionConfig",
584+
},
585+
{
586+
name: "ContextWindowCompressionConfig with all fields",
587+
input: &ContextWindowCompressionConfig{
588+
TriggerTokens: 1024,
589+
SlidingWindow: &SlidingWindow{TargetTokens: 1024},
590+
},
591+
want: `{"slidingWindow":{"targetTokens":"1024"},"triggerTokens":"1024"}`,
592+
wantErr: false,
593+
target: "ContextWindowCompressionConfig",
594+
},
560595
}
561596
for _, tt := range tests {
562597
t.Run(tt.name, func(t *testing.T) {
@@ -583,6 +618,10 @@ func TestMarshalJSON(t *testing.T) {
583618
got, err = json.Marshal(tt.input.(*VideoMetadata))
584619
case "File":
585620
got, err = json.Marshal(tt.input.(*File))
621+
case "SlidingWindow":
622+
got, err = json.Marshal(tt.input.(*SlidingWindow))
623+
case "ContextWindowCompressionConfig":
624+
got, err = json.Marshal(tt.input.(*ContextWindowCompressionConfig))
586625
default:
587626
t.Fatalf("unknown target: %s", tt.target)
588627
}

0 commit comments

Comments
 (0)