Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added components/.DS_Store
Binary file not shown.
408 changes: 408 additions & 0 deletions components/agentic/ark/README.md

Large diffs are not rendered by default.

409 changes: 409 additions & 0 deletions components/agentic/ark/README.zh_CN.md

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions components/agentic/ark/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2026 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package ark

const implType = "Ark"

type WebSearchAction string

const (
WebSearchActionSearch WebSearchAction = "search"
)

type ServerToolName string

const (
ServerToolNameWebSearch ServerToolName = "web_search"
)

type TextAnnotationType string

const (
TextAnnotationTypeURLCitation TextAnnotationType = "url_citation"
TextAnnotationTypeDocCitation TextAnnotationType = "doc_citation"
)

type ThinkingType string

const (
ThinkingTypeAuto ThinkingType = "auto"
ThinkingTypeEnabled ThinkingType = "enabled"
ThinkingTypeDisabled ThinkingType = "disabled"
)

type ResponseStatus string

const (
ResponseStatusInProgress ResponseStatus = "in_progress"
ResponseStatusCompleted ResponseStatus = "completed"
ResponseStatusIncomplete ResponseStatus = "incomplete"
ResponseStatusFailed ResponseStatus = "failed"
)

type ServiceTier string

const (
ServiceTierAuto ServiceTier = "auto"
ServiceTierDefault ServiceTier = "default"
)
115 changes: 115 additions & 0 deletions components/agentic/ark/content_block_extra.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright 2026 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package ark

import (
"reflect"

"github.com/cloudwego/eino/schema"
)

type blockExtraItemID string
type blockExtraItemStatus string

const (
videoURLFPS = "ark-user-input-video-url-fps"
itemIDKey = "ark-item-id"
itemStatusKey = "ark-item-status"
)

func SetUserInputVideoFPS(block *schema.UserInputVideo, fps float64) {
setBlockExtraValue(schema.NewContentBlock(block), videoURLFPS, fps)
}

func GetUserInputVideoFPS(block *schema.UserInputVideo) (float64, bool) {
return getBlockExtraValue[float64](schema.NewContentBlock(block), videoURLFPS)
}

func setItemID(block *schema.ContentBlock, itemID string) {
setBlockExtraValue(block, itemIDKey, blockExtraItemID(itemID))
}

func getItemID(block *schema.ContentBlock) (string, bool) {
itemID, ok := getBlockExtraValue[blockExtraItemID](block, itemIDKey)
if !ok {
return "", false
}
return string(itemID), true
}

func setItemStatus(block *schema.ContentBlock, status string) {
setBlockExtraValue(block, itemStatusKey, blockExtraItemStatus(status))
}

func GetItemStatus(block *schema.ContentBlock) (string, bool) {
itemStatus, ok := getBlockExtraValue[blockExtraItemStatus](block, itemStatusKey)
if !ok {
return "", false
}
return string(itemStatus), true
}

func setBlockExtraValue[T any](block *schema.ContentBlock, key string, value T) {
if block == nil {
return
}
if block.Extra == nil {
block.Extra = map[string]any{}
}
block.Extra[key] = value
}

func getBlockExtraValue[T any](block *schema.ContentBlock, key string) (T, bool) {
var zero T
if block == nil {
return zero, false
}
if block.Extra == nil {
return zero, false
}
val, ok := block.Extra[key].(T)
if !ok {
return zero, false
}
return val, true
}

func concatFirstNonZero[T any](chunks []T) (T, error) {
for _, chunk := range chunks {
if !reflect.ValueOf(chunk).IsZero() {
return chunk, nil
}
}
var zero T
return zero, nil
}

func concatFirst[T any](chunks []T) (T, error) {
if len(chunks) == 0 {
var zero T
return zero, nil
}
return chunks[0], nil
}

func concatLast[T any](chunks []T) (T, error) {
if len(chunks) == 0 {
var zero T
return zero, nil
}
return chunks[len(chunks)-1], nil
}
Loading
Loading