veadk-python 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of veadk-python might be problematic. Click here for more details.
- veadk/__init__.py +31 -0
- veadk/a2a/__init__.py +13 -0
- veadk/a2a/agent_card.py +45 -0
- veadk/a2a/remote_ve_agent.py +19 -0
- veadk/a2a/ve_a2a_server.py +77 -0
- veadk/a2a/ve_agent_executor.py +78 -0
- veadk/a2a/ve_task_store.py +37 -0
- veadk/agent.py +253 -0
- veadk/cli/__init__.py +13 -0
- veadk/cli/main.py +278 -0
- veadk/cli/services/agentpilot/__init__.py +17 -0
- veadk/cli/services/agentpilot/agentpilot.py +77 -0
- veadk/cli/services/veapig/__init__.py +17 -0
- veadk/cli/services/veapig/apig.py +224 -0
- veadk/cli/services/veapig/apig_utils.py +332 -0
- veadk/cli/services/vefaas/__init__.py +17 -0
- veadk/cli/services/vefaas/template/deploy.py +44 -0
- veadk/cli/services/vefaas/template/src/app.py +30 -0
- veadk/cli/services/vefaas/template/src/config.py +58 -0
- veadk/cli/services/vefaas/vefaas.py +346 -0
- veadk/cli/services/vefaas/vefaas_utils.py +408 -0
- veadk/cli/services/vetls/__init__.py +17 -0
- veadk/cli/services/vetls/vetls.py +87 -0
- veadk/cli/studio/__init__.py +13 -0
- veadk/cli/studio/agent_processor.py +247 -0
- veadk/cli/studio/fast_api.py +232 -0
- veadk/cli/studio/model.py +116 -0
- veadk/cloud/__init__.py +13 -0
- veadk/cloud/cloud_agent_engine.py +144 -0
- veadk/cloud/cloud_app.py +123 -0
- veadk/cloud/template/app.py +30 -0
- veadk/cloud/template/config.py +55 -0
- veadk/config.py +131 -0
- veadk/consts.py +17 -0
- veadk/database/__init__.py +17 -0
- veadk/database/base_database.py +45 -0
- veadk/database/database_factory.py +80 -0
- veadk/database/kv/__init__.py +13 -0
- veadk/database/kv/redis_database.py +109 -0
- veadk/database/local_database.py +43 -0
- veadk/database/relational/__init__.py +13 -0
- veadk/database/relational/mysql_database.py +114 -0
- veadk/database/vector/__init__.py +13 -0
- veadk/database/vector/opensearch_vector_database.py +205 -0
- veadk/database/vector/type.py +50 -0
- veadk/database/viking/__init__.py +13 -0
- veadk/database/viking/viking_database.py +378 -0
- veadk/database/viking/viking_memory_db.py +521 -0
- veadk/evaluation/__init__.py +17 -0
- veadk/evaluation/adk_evaluator/__init__.py +13 -0
- veadk/evaluation/adk_evaluator/adk_evaluator.py +291 -0
- veadk/evaluation/base_evaluator.py +242 -0
- veadk/evaluation/deepeval_evaluator/__init__.py +17 -0
- veadk/evaluation/deepeval_evaluator/deepeval_evaluator.py +223 -0
- veadk/evaluation/eval_set_file_loader.py +28 -0
- veadk/evaluation/eval_set_recorder.py +91 -0
- veadk/evaluation/utils/prometheus.py +142 -0
- veadk/knowledgebase/__init__.py +17 -0
- veadk/knowledgebase/knowledgebase.py +83 -0
- veadk/knowledgebase/knowledgebase_database_adapter.py +259 -0
- veadk/memory/__init__.py +13 -0
- veadk/memory/long_term_memory.py +119 -0
- veadk/memory/memory_database_adapter.py +235 -0
- veadk/memory/short_term_memory.py +124 -0
- veadk/memory/short_term_memory_processor.py +90 -0
- veadk/prompts/__init__.py +13 -0
- veadk/prompts/agent_default_prompt.py +30 -0
- veadk/prompts/prompt_evaluator.py +20 -0
- veadk/prompts/prompt_memory_processor.py +55 -0
- veadk/prompts/prompt_optimization.py +158 -0
- veadk/runner.py +252 -0
- veadk/tools/__init__.py +13 -0
- veadk/tools/builtin_tools/__init__.py +13 -0
- veadk/tools/builtin_tools/lark.py +67 -0
- veadk/tools/builtin_tools/las.py +23 -0
- veadk/tools/builtin_tools/vesearch.py +49 -0
- veadk/tools/builtin_tools/web_scraper.py +76 -0
- veadk/tools/builtin_tools/web_search.py +192 -0
- veadk/tools/demo_tools.py +58 -0
- veadk/tools/load_knowledgebase_tool.py +144 -0
- veadk/tools/sandbox/__init__.py +13 -0
- veadk/tools/sandbox/browser_sandbox.py +27 -0
- veadk/tools/sandbox/code_sandbox.py +30 -0
- veadk/tools/sandbox/computer_sandbox.py +27 -0
- veadk/tracing/__init__.py +13 -0
- veadk/tracing/base_tracer.py +172 -0
- veadk/tracing/telemetry/__init__.py +13 -0
- veadk/tracing/telemetry/exporters/__init__.py +13 -0
- veadk/tracing/telemetry/exporters/apiserver_exporter.py +60 -0
- veadk/tracing/telemetry/exporters/apmplus_exporter.py +101 -0
- veadk/tracing/telemetry/exporters/base_exporter.py +28 -0
- veadk/tracing/telemetry/exporters/cozeloop_exporter.py +69 -0
- veadk/tracing/telemetry/exporters/inmemory_exporter.py +88 -0
- veadk/tracing/telemetry/exporters/tls_exporter.py +78 -0
- veadk/tracing/telemetry/metrics/__init__.py +13 -0
- veadk/tracing/telemetry/metrics/opentelemetry_metrics.py +73 -0
- veadk/tracing/telemetry/opentelemetry_tracer.py +167 -0
- veadk/types.py +23 -0
- veadk/utils/__init__.py +13 -0
- veadk/utils/logger.py +59 -0
- veadk/utils/misc.py +33 -0
- veadk/utils/patches.py +85 -0
- veadk/utils/volcengine_sign.py +199 -0
- veadk/version.py +15 -0
- veadk_python-0.1.0.dist-info/METADATA +124 -0
- veadk_python-0.1.0.dist-info/RECORD +110 -0
- veadk_python-0.1.0.dist-info/WHEEL +5 -0
- veadk_python-0.1.0.dist-info/entry_points.txt +2 -0
- veadk_python-0.1.0.dist-info/licenses/LICENSE +201 -0
- veadk_python-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,332 @@
|
|
|
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
|
+
# This file is adapted from https://github.com/volcengine/mcp-server/blob/main/server/mcp_server_veapig/src/mcp_server_veapig/veapig_server.py
|
|
16
|
+
|
|
17
|
+
import datetime
|
|
18
|
+
import hashlib
|
|
19
|
+
import hmac
|
|
20
|
+
import json
|
|
21
|
+
from urllib.parse import quote
|
|
22
|
+
|
|
23
|
+
import requests
|
|
24
|
+
|
|
25
|
+
Service = "apig"
|
|
26
|
+
Version = "2021-03-03"
|
|
27
|
+
Region = "cn-beijing"
|
|
28
|
+
Host = "iam.volcengineapi.com"
|
|
29
|
+
ContentType = "application/json"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def hmac_sha256(key: bytes, content: str):
|
|
33
|
+
return hmac.new(key, content.encode("utf-8"), hashlib.sha256).digest()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def hash_sha256(content: str):
|
|
37
|
+
return hashlib.sha256(content.encode("utf-8")).hexdigest()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def norm_query(params):
|
|
41
|
+
query = ""
|
|
42
|
+
for key in sorted(params.keys()):
|
|
43
|
+
if isinstance(params[key], list):
|
|
44
|
+
for k in params[key]:
|
|
45
|
+
query = (
|
|
46
|
+
query + quote(key, safe="-_.~") + "=" + quote(k, safe="-_.~") + "&"
|
|
47
|
+
)
|
|
48
|
+
else:
|
|
49
|
+
query = (
|
|
50
|
+
query
|
|
51
|
+
+ quote(key, safe="-_.~")
|
|
52
|
+
+ "="
|
|
53
|
+
+ quote(params[key], safe="-_.~")
|
|
54
|
+
+ "&"
|
|
55
|
+
)
|
|
56
|
+
query = query[:-1]
|
|
57
|
+
return query.replace("+", "%20")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def request(method, date, query, header, region, ak, sk, token, action, body):
|
|
61
|
+
# 第三步:创建身份证明。其中的 Service 和 Region 字段是固定的。ak 和 sk 分别代表
|
|
62
|
+
# AccessKeyID 和 SecretAccessKey。同时需要初始化签名结构体。一些签名计算时需要的属性也在这里处理。
|
|
63
|
+
# 初始化身份证明结构体
|
|
64
|
+
|
|
65
|
+
credential = {
|
|
66
|
+
"access_key_id": ak,
|
|
67
|
+
"secret_access_key": sk,
|
|
68
|
+
"service": Service,
|
|
69
|
+
"region": region,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if token is not None:
|
|
73
|
+
credential["session_token"] = token
|
|
74
|
+
|
|
75
|
+
content_type = ContentType
|
|
76
|
+
version = Version
|
|
77
|
+
if action == "CreateRoute" or action == "ListRoutes" or action == "GetRoute":
|
|
78
|
+
version = "2022-11-12"
|
|
79
|
+
|
|
80
|
+
# 初始化签名结构体
|
|
81
|
+
request_param = {
|
|
82
|
+
"body": body,
|
|
83
|
+
"host": Host,
|
|
84
|
+
"path": "/",
|
|
85
|
+
"method": method,
|
|
86
|
+
"content_type": content_type,
|
|
87
|
+
"date": date,
|
|
88
|
+
"query": {"Action": action, "Version": version, **query},
|
|
89
|
+
}
|
|
90
|
+
if body is None:
|
|
91
|
+
request_param["body"] = ""
|
|
92
|
+
# 第四步:接下来开始计算签名。在计算签名前,先准备好用于接收签算结果的 signResult 变量,并设置一些参数。
|
|
93
|
+
# 初始化签名结果的结构体
|
|
94
|
+
x_date = request_param["date"].strftime("%Y%m%dT%H%M%SZ")
|
|
95
|
+
short_x_date = x_date[:8]
|
|
96
|
+
x_content_sha256 = hash_sha256(request_param["body"])
|
|
97
|
+
sign_result = {
|
|
98
|
+
"Host": request_param["host"],
|
|
99
|
+
"X-Content-Sha256": x_content_sha256,
|
|
100
|
+
"X-Date": x_date,
|
|
101
|
+
"Content-Type": request_param["content_type"],
|
|
102
|
+
}
|
|
103
|
+
# 第五步:计算 Signature 签名。
|
|
104
|
+
signed_headers_str = ";".join(
|
|
105
|
+
["content-type", "host", "x-content-sha256", "x-date"]
|
|
106
|
+
)
|
|
107
|
+
# signed_headers_str = signed_headers_str + ";x-security-token"
|
|
108
|
+
canonical_request_str = "\n".join(
|
|
109
|
+
[
|
|
110
|
+
request_param["method"].upper(),
|
|
111
|
+
request_param["path"],
|
|
112
|
+
norm_query(request_param["query"]),
|
|
113
|
+
"\n".join(
|
|
114
|
+
[
|
|
115
|
+
"content-type:" + request_param["content_type"],
|
|
116
|
+
"host:" + request_param["host"],
|
|
117
|
+
"x-content-sha256:" + x_content_sha256,
|
|
118
|
+
"x-date:" + x_date,
|
|
119
|
+
]
|
|
120
|
+
),
|
|
121
|
+
"",
|
|
122
|
+
signed_headers_str,
|
|
123
|
+
x_content_sha256,
|
|
124
|
+
]
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# 打印正规化的请求用于调试比对
|
|
128
|
+
hashed_canonical_request = hash_sha256(canonical_request_str)
|
|
129
|
+
|
|
130
|
+
# 打印hash值用于调试比对
|
|
131
|
+
credential_scope = "/".join(
|
|
132
|
+
[short_x_date, credential["region"], credential["service"], "request"]
|
|
133
|
+
)
|
|
134
|
+
string_to_sign = "\n".join(
|
|
135
|
+
["HMAC-SHA256", x_date, credential_scope, hashed_canonical_request]
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# 打印最终计算的签名字符串用于调试比对
|
|
139
|
+
k_date = hmac_sha256(credential["secret_access_key"].encode("utf-8"), short_x_date)
|
|
140
|
+
k_region = hmac_sha256(k_date, credential["region"])
|
|
141
|
+
k_service = hmac_sha256(k_region, credential["service"])
|
|
142
|
+
k_signing = hmac_sha256(k_service, "request")
|
|
143
|
+
signature = hmac_sha256(k_signing, string_to_sign).hex()
|
|
144
|
+
|
|
145
|
+
sign_result["Authorization"] = (
|
|
146
|
+
"HMAC-SHA256 Credential={}, SignedHeaders={}, Signature={}".format(
|
|
147
|
+
credential["access_key_id"] + "/" + credential_scope,
|
|
148
|
+
signed_headers_str,
|
|
149
|
+
signature,
|
|
150
|
+
)
|
|
151
|
+
)
|
|
152
|
+
header = {"Region": region, **header, **sign_result}
|
|
153
|
+
header = {**header, **{"X-Security-Token": token}}
|
|
154
|
+
# 第六步:将 Signature 签名写入 HTTP Header 中,并发送 HTTP 请求。
|
|
155
|
+
r = requests.request(
|
|
156
|
+
method=method,
|
|
157
|
+
url="https://{}{}".format(request_param["host"], request_param["path"]),
|
|
158
|
+
headers=header,
|
|
159
|
+
params=request_param["query"],
|
|
160
|
+
data=request_param["body"],
|
|
161
|
+
)
|
|
162
|
+
return r.json()
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def validate_and_set_region(region: str = "cn-beijing") -> str:
|
|
166
|
+
"""
|
|
167
|
+
Validates the provided region and returns the default if none is provided.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
region: The region to validate
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
A valid region string
|
|
174
|
+
|
|
175
|
+
Raises:
|
|
176
|
+
ValueError: If the provided region is invalid
|
|
177
|
+
"""
|
|
178
|
+
valid_regions = ["ap-southeast-1", "cn-beijing", "cn-shanghai", "cn-guangzhou"]
|
|
179
|
+
if region:
|
|
180
|
+
if region not in valid_regions:
|
|
181
|
+
raise ValueError(
|
|
182
|
+
f"Invalid region. Must be one of: {', '.join(valid_regions)}"
|
|
183
|
+
)
|
|
184
|
+
else:
|
|
185
|
+
region = "cn-beijing"
|
|
186
|
+
return region
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# Uniformly process requests and send requests
|
|
190
|
+
def handle_request(ak, sk, region, action, body) -> str:
|
|
191
|
+
"""
|
|
192
|
+
Uniformly process and send requests.
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
region(str): The region of the request.
|
|
196
|
+
action (str): The name of the operation to be performed by the request.
|
|
197
|
+
body (dict): The main content of the request, stored in a dictionary.
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
str: The response body of the request.
|
|
201
|
+
"""
|
|
202
|
+
date = datetime.datetime.utcnow()
|
|
203
|
+
|
|
204
|
+
token = ""
|
|
205
|
+
|
|
206
|
+
response_body = request(
|
|
207
|
+
"POST", date, {}, {}, region, ak, sk, token, action, json.dumps(body)
|
|
208
|
+
)
|
|
209
|
+
return response_body
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def create_serverless_gateway(
|
|
213
|
+
ak, sk, name: str = "", region: str = "cn-beijing"
|
|
214
|
+
) -> str:
|
|
215
|
+
"""
|
|
216
|
+
Creates a new VeApig serverless gateway.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
name (str): The name of the serverless gateway. If not provided, a random name will be generated.
|
|
220
|
+
region (str): The region where the serverless gateway will be created. Default is cn-beijing.
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
str: The response body of the request.
|
|
224
|
+
"""
|
|
225
|
+
gateway_name = name
|
|
226
|
+
region = validate_and_set_region(region)
|
|
227
|
+
body = {
|
|
228
|
+
"Name": gateway_name,
|
|
229
|
+
"Region": region,
|
|
230
|
+
"Type": "serverless",
|
|
231
|
+
"ResourceSpec": {
|
|
232
|
+
"Replicas": 2,
|
|
233
|
+
"InstanceSpecCode": "1c2g",
|
|
234
|
+
"CLBSpecCode": "small_1",
|
|
235
|
+
"PublicNetworkBillingType": "traffic",
|
|
236
|
+
"NetworkType": {"EnablePublicNetwork": True, "EnablePrivateNetwork": False},
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
try:
|
|
240
|
+
response = handle_request(ak, sk, region, "CreateGateway", body)
|
|
241
|
+
return response
|
|
242
|
+
except Exception as e:
|
|
243
|
+
return f"Failed to create VeApig serverless gateway with name {gateway_name}: {str(e)}"
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def create_gateway_service(
|
|
247
|
+
ak, sk, gateway_id: str, name: str = "", region: str = "cn-beijing"
|
|
248
|
+
) -> str:
|
|
249
|
+
"""
|
|
250
|
+
Creates a new VeApig serverless gateway service.
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
gateway_id (str): The id of the serverless gateway where the service will be created.
|
|
254
|
+
name (str): The name of the serverless gateway service. If not provided, a random name will be generated.
|
|
255
|
+
region (str): The region where the serverless gateway service will be created. Default is cn-beijing.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
str: The response body of the request.
|
|
259
|
+
"""
|
|
260
|
+
|
|
261
|
+
service_name = name
|
|
262
|
+
region = validate_and_set_region(region)
|
|
263
|
+
body = {
|
|
264
|
+
"ServiceName": service_name,
|
|
265
|
+
"GatewayId": gateway_id,
|
|
266
|
+
"Protocol": ["HTTP", "HTTPS"],
|
|
267
|
+
"AuthSpec": {"Enable": False},
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
try:
|
|
271
|
+
response = handle_request(ak, sk, region, "CreateGatewayService", body)
|
|
272
|
+
return response
|
|
273
|
+
except Exception as e:
|
|
274
|
+
return f"Failed to create VeApig serverless gateway service with name {service_name}: {str(e)}"
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def list_gateways(ak, sk, region: str = "cn-beijing") -> str:
|
|
278
|
+
# Validate region parameter
|
|
279
|
+
region = validate_and_set_region(region)
|
|
280
|
+
|
|
281
|
+
# Construct the request parameter body of the tool in JSON format
|
|
282
|
+
body = {"PageNumber": 1, "PageSize": 100}
|
|
283
|
+
|
|
284
|
+
# Set the action for the request
|
|
285
|
+
action = "ListGateways"
|
|
286
|
+
|
|
287
|
+
# Send the request and return the response body
|
|
288
|
+
response_body = handle_request(ak, sk, region, action, body)
|
|
289
|
+
return response_body
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def list_gateway_services(
|
|
293
|
+
ak, sk, gateway_id: str = "", region: str = "cn-beijing"
|
|
294
|
+
) -> str:
|
|
295
|
+
# Validate region parameter
|
|
296
|
+
region = validate_and_set_region(region)
|
|
297
|
+
|
|
298
|
+
# Construct the request parameter body of the tool in JSON format
|
|
299
|
+
body = {
|
|
300
|
+
"PageNumber": 1,
|
|
301
|
+
"PageSize": 100,
|
|
302
|
+
"GatewayId": gateway_id,
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
# Set the action for the request
|
|
306
|
+
action = "ListGatewayServices"
|
|
307
|
+
|
|
308
|
+
# Send the request and return the response body
|
|
309
|
+
response_body = handle_request(ak, sk, region, action, body)
|
|
310
|
+
return response_body
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def get_gateway_route(ak, sk, route_id: str, region: str = "cn-beijing") -> str:
|
|
314
|
+
"""
|
|
315
|
+
Gets detailed informantion about a specific VeApig route.
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
route_id (str): The id of the route.
|
|
319
|
+
region (str): The region where the route is located.
|
|
320
|
+
|
|
321
|
+
Returns:
|
|
322
|
+
str: The response body of the request.
|
|
323
|
+
"""
|
|
324
|
+
region = validate_and_set_region(region)
|
|
325
|
+
body = {
|
|
326
|
+
"Id": route_id,
|
|
327
|
+
}
|
|
328
|
+
try:
|
|
329
|
+
response = handle_request(ak, sk, region, "GetRoute", body)
|
|
330
|
+
return response
|
|
331
|
+
except Exception as e:
|
|
332
|
+
return f"Failed to get VeApig route with id {route_id}: {str(e)}"
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
from .vefaas import VeFaaS
|
|
16
|
+
|
|
17
|
+
__all__ = ["VeFaaS"]
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
import asyncio
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
from veadk.cloud.cloud_agent_engine import CloudAgentEngine
|
|
19
|
+
|
|
20
|
+
SESSION_ID = "cloud_app_test_session"
|
|
21
|
+
USER_ID = "cloud_app_test_user"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def main():
|
|
25
|
+
engine = CloudAgentEngine()
|
|
26
|
+
cloud_app = engine.deploy(
|
|
27
|
+
path=str(Path(__file__).parent / "src"),
|
|
28
|
+
name="weather-reporter",
|
|
29
|
+
# gateway_name="", # <--- your gateway instance name if you have
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
response_message = await cloud_app.message_send(
|
|
33
|
+
"How is the weather like in Beijing?", SESSION_ID, USER_ID
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
print(f"Message ID: {response_message.messageId}")
|
|
37
|
+
|
|
38
|
+
print(f"Response from {cloud_app.endpoint}: {response_message.parts[0].root.text}")
|
|
39
|
+
|
|
40
|
+
print(f"App ID: {cloud_app.app_id}")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == "__main__":
|
|
44
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
import os
|
|
16
|
+
|
|
17
|
+
from config import AGENT, APP_NAME, SHORT_TERM_MEMORY, TRACERS
|
|
18
|
+
|
|
19
|
+
from veadk.a2a.ve_a2a_server import init_app
|
|
20
|
+
|
|
21
|
+
SERVER_HOST = os.getenv("SERVER_HOST")
|
|
22
|
+
|
|
23
|
+
AGENT.tracers.extend(TRACERS)
|
|
24
|
+
|
|
25
|
+
app = init_app(
|
|
26
|
+
server_url=SERVER_HOST,
|
|
27
|
+
app_name=APP_NAME,
|
|
28
|
+
agent=AGENT,
|
|
29
|
+
short_term_memory=SHORT_TERM_MEMORY,
|
|
30
|
+
)
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
import os
|
|
16
|
+
|
|
17
|
+
from veadk import Agent
|
|
18
|
+
from veadk.memory.short_term_memory import ShortTermMemory
|
|
19
|
+
from veadk.tools.demo_tools import get_city_weather
|
|
20
|
+
from veadk.tracing.base_tracer import BaseTracer
|
|
21
|
+
from veadk.tracing.telemetry.opentelemetry_tracer import OpentelemetryTracer
|
|
22
|
+
|
|
23
|
+
# =============
|
|
24
|
+
# Generated by VeADK, do not edit!!!
|
|
25
|
+
# =============
|
|
26
|
+
TRACERS: list[BaseTracer] = []
|
|
27
|
+
|
|
28
|
+
exporters = []
|
|
29
|
+
if os.getenv("VEADK_TRACER_APMPLUS", "").lower() == "true":
|
|
30
|
+
from veadk.tracing.telemetry.exporters.apmplus_exporter import APMPlusExporter
|
|
31
|
+
|
|
32
|
+
exporters.append(APMPlusExporter())
|
|
33
|
+
|
|
34
|
+
if os.getenv("VEADK_TRACER_COZELOOP", "").lower() == "true":
|
|
35
|
+
from veadk.tracing.telemetry.exporters.cozeloop_exporter import CozeloopExporter
|
|
36
|
+
|
|
37
|
+
exporters.append(CozeloopExporter())
|
|
38
|
+
|
|
39
|
+
if os.getenv("VEADK_TRACER_TLS", "").lower() == "true":
|
|
40
|
+
from veadk.tracing.telemetry.exporters.tls_exporter import TLSExporter
|
|
41
|
+
|
|
42
|
+
exporters.append(TLSExporter())
|
|
43
|
+
|
|
44
|
+
TRACERS.append(OpentelemetryTracer(exporters=exporters))
|
|
45
|
+
|
|
46
|
+
# =============
|
|
47
|
+
# Required [you can edit here]
|
|
48
|
+
# =============
|
|
49
|
+
APP_NAME: str = "weather-reporter" # <--- export your app name
|
|
50
|
+
AGENT: Agent = Agent(tools=[get_city_weather]) # <--- export your agent
|
|
51
|
+
SHORT_TERM_MEMORY: ShortTermMemory = (
|
|
52
|
+
ShortTermMemory()
|
|
53
|
+
) # <--- export your short term memory
|
|
54
|
+
|
|
55
|
+
# =============
|
|
56
|
+
# Optional
|
|
57
|
+
# =============
|
|
58
|
+
# Other global variables
|