Skip to content

Commit a74b18b

Browse files
authored
feat(adk): add summarization middleware (#729)
1 parent 6524f7a commit a74b18b

File tree

7 files changed

+1620
-3
lines changed

7 files changed

+1620
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2026 CloudWeGo Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package summarization
18+
19+
const (
20+
extraKeyContentType = "_eino_summarization_content_type"
21+
)
22+
23+
type summarizationContentType string
24+
25+
const (
26+
contentTypeSummary summarizationContentType = "summary"
27+
)
28+
29+
type ActionType string
30+
31+
const (
32+
ActionTypeBeforeSummary ActionType = "before_summary"
33+
ActionTypeAfterSummary ActionType = "after_summary"
34+
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2026 CloudWeGo Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package summarization
18+
19+
import (
20+
"github.com/cloudwego/eino/adk"
21+
)
22+
23+
type CustomizedAction struct {
24+
// Type is the action type.
25+
Type ActionType `json:"type"`
26+
27+
// Before is set when Type is ActionTypeBeforeSummary.
28+
// Emitted after trigger condition is met, before calling model to generate summary.
29+
Before *BeforeSummaryAction `json:"before,omitempty"`
30+
31+
// After is set when Type is ActionTypeAfterSummary.
32+
// Emitted after summary generation, before applying new messages to state.
33+
After *AfterSummaryAction `json:"after,omitempty"`
34+
}
35+
36+
type BeforeSummaryAction struct {
37+
// Messages is the original state messages before summarization.
38+
Messages []adk.Message `json:"messages,omitempty"`
39+
}
40+
41+
type AfterSummaryAction struct {
42+
// Messages is the final state messages after summarization.
43+
Messages []adk.Message `json:"messages,omitempty"`
44+
}

0 commit comments

Comments
 (0)