Skip to content

Commit 5b04437

Browse files
committed
feat(agentic_ark): implement AgenticModel
1 parent 4f236f1 commit 5b04437

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+14583
-0
lines changed

components/.DS_Store

6 KB
Binary file not shown.

components/agentic/ark/README.md

Lines changed: 408 additions & 0 deletions
Large diffs are not rendered by default.

components/agentic/ark/README.zh_CN.md

Lines changed: 409 additions & 0 deletions
Large diffs are not rendered by default.

components/agentic/ark/consts.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
* https://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 ark
18+
19+
const implType = "Ark"
20+
21+
type WebSearchAction string
22+
23+
const (
24+
WebSearchActionSearch WebSearchAction = "search"
25+
)
26+
27+
type ServerToolName string
28+
29+
const (
30+
ServerToolNameWebSearch ServerToolName = "web_search"
31+
)
32+
33+
type TextAnnotationType string
34+
35+
const (
36+
TextAnnotationTypeURLCitation TextAnnotationType = "url_citation"
37+
TextAnnotationTypeDocCitation TextAnnotationType = "doc_citation"
38+
)
39+
40+
type ThinkingType string
41+
42+
const (
43+
ThinkingTypeAuto ThinkingType = "auto"
44+
ThinkingTypeEnabled ThinkingType = "enabled"
45+
ThinkingTypeDisabled ThinkingType = "disabled"
46+
)
47+
48+
type ResponseStatus string
49+
50+
const (
51+
ResponseStatusInProgress ResponseStatus = "in_progress"
52+
ResponseStatusCompleted ResponseStatus = "completed"
53+
ResponseStatusIncomplete ResponseStatus = "incomplete"
54+
ResponseStatusFailed ResponseStatus = "failed"
55+
)
56+
57+
type ServiceTier string
58+
59+
const (
60+
ServiceTierAuto ServiceTier = "auto"
61+
ServiceTierDefault ServiceTier = "default"
62+
)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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+
* https://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 ark
18+
19+
import (
20+
"reflect"
21+
22+
"github.com/cloudwego/eino/schema"
23+
)
24+
25+
type blockExtraItemID string
26+
type blockExtraItemStatus string
27+
28+
const (
29+
videoURLFPS = "ark-user-input-video-url-fps"
30+
itemIDKey = "ark-item-id"
31+
itemStatusKey = "ark-item-status"
32+
)
33+
34+
func SetUserInputVideoFPS(block *schema.UserInputVideo, fps float64) {
35+
setBlockExtraValue(schema.NewContentBlock(block), videoURLFPS, fps)
36+
}
37+
38+
func GetUserInputVideoFPS(block *schema.UserInputVideo) (float64, bool) {
39+
return getBlockExtraValue[float64](schema.NewContentBlock(block), videoURLFPS)
40+
}
41+
42+
func setItemID(block *schema.ContentBlock, itemID string) {
43+
setBlockExtraValue(block, itemIDKey, blockExtraItemID(itemID))
44+
}
45+
46+
func getItemID(block *schema.ContentBlock) (string, bool) {
47+
itemID, ok := getBlockExtraValue[blockExtraItemID](block, itemIDKey)
48+
if !ok {
49+
return "", false
50+
}
51+
return string(itemID), true
52+
}
53+
54+
func setItemStatus(block *schema.ContentBlock, status string) {
55+
setBlockExtraValue(block, itemStatusKey, blockExtraItemStatus(status))
56+
}
57+
58+
func GetItemStatus(block *schema.ContentBlock) (string, bool) {
59+
itemStatus, ok := getBlockExtraValue[blockExtraItemStatus](block, itemStatusKey)
60+
if !ok {
61+
return "", false
62+
}
63+
return string(itemStatus), true
64+
}
65+
66+
func setBlockExtraValue[T any](block *schema.ContentBlock, key string, value T) {
67+
if block == nil {
68+
return
69+
}
70+
if block.Extra == nil {
71+
block.Extra = map[string]any{}
72+
}
73+
block.Extra[key] = value
74+
}
75+
76+
func getBlockExtraValue[T any](block *schema.ContentBlock, key string) (T, bool) {
77+
var zero T
78+
if block == nil {
79+
return zero, false
80+
}
81+
if block.Extra == nil {
82+
return zero, false
83+
}
84+
val, ok := block.Extra[key].(T)
85+
if !ok {
86+
return zero, false
87+
}
88+
return val, true
89+
}
90+
91+
func concatFirstNonZero[T any](chunks []T) (T, error) {
92+
for _, chunk := range chunks {
93+
if !reflect.ValueOf(chunk).IsZero() {
94+
return chunk, nil
95+
}
96+
}
97+
var zero T
98+
return zero, nil
99+
}
100+
101+
func concatFirst[T any](chunks []T) (T, error) {
102+
if len(chunks) == 0 {
103+
var zero T
104+
return zero, nil
105+
}
106+
return chunks[0], nil
107+
}
108+
109+
func concatLast[T any](chunks []T) (T, error) {
110+
if len(chunks) == 0 {
111+
var zero T
112+
return zero, nil
113+
}
114+
return chunks[len(chunks)-1], nil
115+
}

0 commit comments

Comments
 (0)