Skip to content

Commit d081d8f

Browse files
MeinhardZhouinnsd
authored andcommitted
feat: support eino
Signed-off-by: Meinhard Zhou <[email protected]> (cherry picked from commit 74189e52ed6245dcc79fc6e36dba19b5fef66011)
1 parent da4f300 commit d081d8f

File tree

11 files changed

+1515
-32
lines changed

11 files changed

+1515
-32
lines changed

agentkit/toolkit/cli/cli_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def config_command(
102102
--agent_name myGoAgent \\
103103
--entry_point main.go \\
104104
--language Golang \\
105-
--language_version 1.23
105+
--language_version 1.24
106106
107107
\b
108108
# App-level vs Strategy-level environment variables

agentkit/toolkit/config/config.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class CommonConfig(AutoSerializableMixin):
4242
entry_point: str = field(
4343
default="",
4444
metadata={
45-
"description": "Agent application entry file (path allowed), e.g. simple_agent.py",
45+
"description": "Agent application entry file (path allowed), e.g. simple_agent.py or main.go or build.sh",
4646
"icon": "📝",
4747
"validation": {
4848
"required": True,
4949
# allow relative paths with directories and either .py or .go endings
50-
"pattern": r"^[\w\-/\.]+?\.(py)$",
51-
"message": "Must be a Python (.py), containing only letters, numbers, underscore(_), hyphen(-), dot(.) and '/' for directories"
50+
"pattern": r"^[\w\-/\.]+?\.(py|go|sh)$",
51+
"message": "Must be a Python (.py) or Go (.go) file path or shell script (.sh), containing only letters, numbers, underscore(_), hyphen(-), dot(.) and '/' for directories"
5252
}
5353
}
5454
)
@@ -58,7 +58,7 @@ class CommonConfig(AutoSerializableMixin):
5858
"icon": "✏️",
5959
"choices": [
6060
{"value": "Python", "description": "Python"},
61-
# {"value": "Golang", "description": "Go (Golang)"}
61+
{"value": "Golang", "description": "Go (Golang)"}
6262
]
6363
})
6464
language_version: str = field(
@@ -74,17 +74,16 @@ class CommonConfig(AutoSerializableMixin):
7474
"choices": ["3.10", "3.11", "3.12", "3.13"],
7575
"message": "Python version must be 3.10, 3.11, 3.12, or 3.13"
7676
},
77-
# "Golang": {
78-
# "pattern": r"^1\.\d+$",
79-
# "message": "Go 版本格式应为 '1.x' (如 1.21, 1.23)",
80-
# "hint": "[格式: 1.x]"
81-
# }
77+
"Golang": {
78+
"choices": ["1.24"],
79+
"message": "Golang version must be '1.24'",
80+
}
8281
}
8382
}
8483
}
8584
)
8685
agent_type: str = field(default="Basic App", metadata={"description" : "Agent application Type", "icon": "📩", "hidden": True})
87-
dependencies_file: str = field(default="requirements.txt", metadata={"description": "Agent application Dependencies file", "icon": "📦"})
86+
dependencies_file: str = field(default="", metadata={"description": "Agent application Dependencies file", "icon": "📦"})
8887
runtime_envs: Dict[str, str] = field(
8988
default_factory=dict,
9089
metadata={
@@ -119,7 +118,7 @@ def _recommended_for_language(language: str) -> Dict[str, str]:
119118
"""Return recommended language_version and dependencies_file for supported languages."""
120119
mapping = {
121120
"python": {"language_version": "3.12", "dependencies_file": "requirements.txt"},
122-
"golang": {"language_version": "1.23", "dependencies_file": "go.mod"},
121+
"golang": {"language_version": "1.24", "dependencies_file": "go.mod"},
123122
}
124123
return mapping.get((language or "python").lower(), mapping["python"])
125124

@@ -153,7 +152,7 @@ def set_language(self, language: str):
153152
lv = (self.language_version or "").strip()
154153
df = (self.dependencies_file or "").strip()
155154

156-
if not lv or lv in ("3.12", "1.23") or lv.startswith("3.") and language.lower() == "go":
155+
if not lv or lv in ("3.12", "1.24") or lv.startswith("3.") and language.lower() == "go":
157156
self.language_version = rec["language_version"]
158157
if not df or df in ("requirements.txt", "go.mod"):
159158
self.dependencies_file = rec["dependencies_file"]

agentkit/toolkit/config/docker_build_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DockerBuildConfig(AutoSerializableMixin):
3636
Go project with multi-stage build:
3737
>>> docker_build:
3838
>>> base_image:
39-
>>> builder: "golang:1.23-alpine"
39+
>>> builder: "golang:1.24-alpine"
4040
>>> runtime: "alpine:latest"
4141
>>> build_script: "scripts/install_certs.sh"
4242
"""
@@ -48,7 +48,7 @@ class DockerBuildConfig(AutoSerializableMixin):
4848
"detail": (
4949
"For Python projects, use a string like 'python:3.12-alpine'. "
5050
"For Go projects, use a dict with 'builder' and 'runtime' keys, "
51-
"e.g., {'builder': 'golang:1.23-alpine', 'runtime': 'alpine:latest'}"
51+
"e.g., {'builder': 'golang:1.24-alpine', 'runtime': 'alpine:latest'}"
5252
)
5353
}
5454
)

agentkit/toolkit/executors/init_executor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@
6565
"type": "A2A App",
6666
"extra_requirements": ["# google-adk"],
6767
},
68-
# "eino_a2a": {
69-
# "filepath": "eino_a2a",
70-
# "name": "Eino A2A Agent App",
71-
# "language": "Golang",
72-
# "language_version": "1.23",
73-
# "description": "基于Eino框架的A2A应用",
74-
# "type": "A2A App",
75-
# },
68+
"eino_a2a": {
69+
"filepath": "eino_a2a",
70+
"name": "Eino A2A Agent App",
71+
"language": "Golang",
72+
"language_version": "1.24",
73+
"description": "基于Eino框架的A2A应用",
74+
"type": "A2A App",
75+
},
7676
}
7777

7878

@@ -410,7 +410,7 @@ def _create_dependencies_file(
410410
)
411411

412412
elif language.lower() == "golang":
413-
go_ver = language_version or "1.23"
413+
go_ver = language_version or "1.24"
414414
with open(dependencies_file_path, 'w', encoding='utf-8') as gomod:
415415
gomod.write(f"module {project_name}\n\ngo {go_ver}\n")
416416
self.created_files.append(dependencies_file_path.name)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"context"
19+
"fmt"
20+
"os"
21+
22+
"github.com/cloudwego/eino/adk"
23+
"github.com/eino-contrib/agentkit-ve/components/model/chatmodelprovider"
24+
)
25+
26+
func buildSimpleAgent(ctx context.Context) (adk.Agent, error) {
27+
agentName := "{{ agent_name | default('A2ASimpleAgent') }}"
28+
var description string
29+
{% if description %}description = `{{ description }}`{% else %}description = DEFAULT_DESCRIPTION{% endif %}
30+
31+
var instruction string
32+
{% if system_prompt %}instruction = `{{ system_prompt }}`{% else %}instruction = DEFAULT_INSTRUCTION{% endif %}
33+
// // ========================================================
34+
35+
// Resolve BaseURL from env or use default
36+
baseURL := os.Getenv("MODEL_AGENT_BASE_URL")
37+
if baseURL == "" {
38+
baseURL = "https://ark.cn-beijing.volces.com/api/v3"
39+
}
40+
41+
cm, err := chatmodelprovider.NewChatModel(ctx, &chatmodelprovider.Config{
42+
Provider: os.Getenv("MODEL_AGENT_PROVIDER"),
43+
APIKey: os.Getenv("MODEL_AGENT_API_KEY"),
44+
Model: os.Getenv("MODEL_AGENT_NAME"),
45+
BaseURL: os.Getenv("MODEL_AGENT_API_BASE"),
46+
})
47+
if err != nil {
48+
return nil, err
49+
}
50+
51+
a, err := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
52+
Name: agentName,
53+
Description: description,
54+
Instruction: instruction,
55+
Model: cm,
56+
})
57+
58+
if err != nil {
59+
return nil, fmt.Errorf("failed to create chatmodel: %w", err)
60+
}
61+
62+
return a, nil
63+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
# Generic build script for Go projects used inside the builder image.
5+
# Environment variables expected (builder sets BUILD_OUTPUT_DIR, BUILD_BINARY_NAME):
6+
# BUILD_OUTPUT_DIR - where to place the binary (default: /app)
7+
# BUILD_BINARY_NAME - binary name (fallback to current dir name)
8+
# Optional:
9+
# ENTRY - go build target (file, dir or package); default is '.'
10+
11+
OUTPUT_DIR=${BUILD_OUTPUT_DIR:-/app}
12+
BIN_NAME=${BUILD_BINARY_NAME:-${BINARY_NAME:-$(basename "$(pwd)")}}
13+
ENTRY=${ENTRY:-.}
14+
15+
mkdir -p "${OUTPUT_DIR}"
16+
17+
# Prefer module-aware builds if go.mod exists
18+
if [ -f go.mod ]; then
19+
echo "Building module-aware: ENTRY='${ENTRY}' BIN='${BIN_NAME}'"
20+
export GOPROXY=${GOPROXY:-https://goproxy.cn}
21+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o "${OUTPUT_DIR}/${BIN_NAME}" ${ENTRY}
22+
else
23+
echo "No go.mod found, using standard go build: ENTRY='${ENTRY}' BIN='${BIN_NAME}'"
24+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o "${OUTPUT_DIR}/${BIN_NAME}" ${ENTRY}
25+
fi
26+
27+
echo "Built ${OUTPUT_DIR}/${BIN_NAME}"
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
module eino_a2a/simple-agent
2+
3+
go 1.24
4+
5+
require (
6+
github.com/cloudwego/eino v0.7.0
7+
github.com/cloudwego/eino-ext/callbacks/cozeloop v0.1.6
8+
github.com/cloudwego/hertz v0.10.3
9+
github.com/coze-dev/cozeloop-go v0.1.16
10+
github.com/eino-contrib/agentkit-ve/components/model/chatmodelprovider v0.1.3
11+
github.com/eino-contrib/agentkit-ve/server/a2a v0.0.0-20251121055902-c2941b51b5ec
12+
)
13+
14+
require (
15+
cloud.google.com/go v0.123.0 // indirect
16+
cloud.google.com/go/auth v0.17.0 // indirect
17+
cloud.google.com/go/compute/metadata v0.9.0 // indirect
18+
github.com/anthropics/anthropic-sdk-go v1.19.0 // indirect
19+
github.com/aws/aws-sdk-go-v2 v1.40.0 // indirect
20+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 // indirect
21+
github.com/aws/aws-sdk-go-v2/config v1.32.2 // indirect
22+
github.com/aws/aws-sdk-go-v2/credentials v1.19.2 // indirect
23+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.14 // indirect
24+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.14 // indirect
25+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.14 // indirect
26+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
27+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.3 // indirect
28+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.14 // indirect
29+
github.com/aws/aws-sdk-go-v2/service/signin v1.0.2 // indirect
30+
github.com/aws/aws-sdk-go-v2/service/sso v1.30.5 // indirect
31+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.10 // indirect
32+
github.com/aws/aws-sdk-go-v2/service/sts v1.41.2 // indirect
33+
github.com/aws/smithy-go v1.23.2 // indirect
34+
github.com/bahlo/generic-list-go v0.2.0 // indirect
35+
github.com/bluele/gcache v0.0.2 // indirect
36+
github.com/buger/jsonparser v1.1.1 // indirect
37+
github.com/bytedance/gopkg v0.1.3 // indirect
38+
github.com/bytedance/sonic v1.14.2 // indirect
39+
github.com/bytedance/sonic/loader v0.4.0 // indirect
40+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
41+
github.com/cloudwego/base64x v0.1.6 // indirect
42+
github.com/cloudwego/eino-ext/a2a v0.0.1-alpha.8 // indirect
43+
github.com/cloudwego/eino-ext/components/model/ark v0.1.50 // indirect
44+
github.com/cloudwego/eino-ext/components/model/arkbot v0.1.1 // indirect
45+
github.com/cloudwego/eino-ext/components/model/claude v0.1.10 // indirect
46+
github.com/cloudwego/eino-ext/components/model/deepseek v0.0.0-20251125094026-d36991a29748 // indirect
47+
github.com/cloudwego/eino-ext/components/model/gemini v0.1.15 // indirect
48+
github.com/cloudwego/eino-ext/components/model/ollama v0.1.6 // indirect
49+
github.com/cloudwego/eino-ext/components/model/openai v0.1.5 // indirect
50+
github.com/cloudwego/eino-ext/components/model/qwen v0.1.2 // indirect
51+
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.3 // indirect
52+
github.com/cloudwego/gopkg v0.1.7 // indirect
53+
github.com/cloudwego/netpoll v0.7.2 // indirect
54+
github.com/cohesion-org/deepseek-go v1.3.2 // indirect
55+
github.com/coze-dev/cozeloop-go/spec v0.1.6 // indirect
56+
github.com/dustin/go-humanize v1.0.1 // indirect
57+
github.com/eino-contrib/agentkit-ve/libs/veauth v0.1.1 // indirect
58+
github.com/eino-contrib/jsonschema v1.0.2 // indirect
59+
github.com/eino-contrib/ollama v0.1.0 // indirect
60+
github.com/evanphx/json-patch v0.5.2 // indirect
61+
github.com/felixge/httpsnoop v1.0.4 // indirect
62+
github.com/fsnotify/fsnotify v1.9.0 // indirect
63+
github.com/go-logr/logr v1.4.3 // indirect
64+
github.com/go-logr/stdr v1.2.2 // indirect
65+
github.com/go-openapi/jsonpointer v0.22.3 // indirect
66+
github.com/go-openapi/jsonreference v0.21.3 // indirect
67+
github.com/go-openapi/spec v0.22.1 // indirect
68+
github.com/go-openapi/swag/conv v0.25.3 // indirect
69+
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
70+
github.com/go-openapi/swag/jsonutils v0.25.3 // indirect
71+
github.com/go-openapi/swag/loading v0.25.3 // indirect
72+
github.com/go-openapi/swag/stringutils v0.25.3 // indirect
73+
github.com/go-openapi/swag/typeutils v0.25.3 // indirect
74+
github.com/go-openapi/swag/yamlutils v0.25.3 // indirect
75+
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
76+
github.com/google/go-cmp v0.7.0 // indirect
77+
github.com/google/s2a-go v0.1.9 // indirect
78+
github.com/google/uuid v1.6.0 // indirect
79+
github.com/googleapis/enterprise-certificate-proxy v0.3.7 // indirect
80+
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
81+
github.com/goph/emperror v0.17.2 // indirect
82+
github.com/gorilla/websocket v1.5.3 // indirect
83+
github.com/jmespath/go-jmespath v0.4.0 // indirect
84+
github.com/joho/godotenv v1.5.1 // indirect
85+
github.com/json-iterator/go v1.1.12 // indirect
86+
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
87+
github.com/mailru/easyjson v0.9.1 // indirect
88+
github.com/meguminnnnnnnnn/go-openai v0.1.0 // indirect
89+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
90+
github.com/modern-go/reflect2 v1.0.2 // indirect
91+
github.com/nikolalohinski/gonja v1.5.3 // indirect
92+
github.com/nikolalohinski/gonja/v2 v2.4.2 // indirect
93+
github.com/nyaruka/phonenumbers v1.6.7 // indirect
94+
github.com/ollama/ollama v0.13.0 // indirect
95+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
96+
github.com/pkg/errors v0.9.2-0.20201214064552-5dd12d0cfe7f // indirect
97+
github.com/sirupsen/logrus v1.9.3 // indirect
98+
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect
99+
github.com/tidwall/gjson v1.18.0 // indirect
100+
github.com/tidwall/match v1.2.0 // indirect
101+
github.com/tidwall/pretty v1.2.1 // indirect
102+
github.com/tidwall/sjson v1.2.5 // indirect
103+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
104+
github.com/valyala/bytebufferpool v1.0.0 // indirect
105+
github.com/valyala/fasttemplate v1.2.2 // indirect
106+
github.com/volcengine/volc-sdk-golang v1.0.228 // indirect
107+
github.com/volcengine/volcengine-go-sdk v1.1.49 // indirect
108+
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
109+
github.com/yargevad/filepathx v1.0.0 // indirect
110+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
111+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
112+
go.opentelemetry.io/otel v1.38.0 // indirect
113+
go.opentelemetry.io/otel/metric v1.38.0 // indirect
114+
go.opentelemetry.io/otel/trace v1.38.0 // indirect
115+
go.yaml.in/yaml/v3 v3.0.4 // indirect
116+
golang.org/x/arch v0.23.0 // indirect
117+
golang.org/x/crypto v0.45.0 // indirect
118+
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect
119+
golang.org/x/net v0.47.0 // indirect
120+
golang.org/x/sync v0.18.0 // indirect
121+
golang.org/x/sys v0.38.0 // indirect
122+
golang.org/x/text v0.31.0 // indirect
123+
google.golang.org/genai v1.36.0 // indirect
124+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect
125+
google.golang.org/grpc v1.77.0 // indirect
126+
google.golang.org/protobuf v1.36.10 // indirect
127+
gopkg.in/yaml.v2 v2.4.0 // indirect
128+
gopkg.in/yaml.v3 v3.0.1 // indirect
129+
)

0 commit comments

Comments
 (0)