Skip to content

Commit 19be5fa

Browse files
committed
feat: add veadk init command in CLI
1 parent 968a990 commit 19be5fa

File tree

7 files changed

+224
-0
lines changed

7 files changed

+224
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Template project for Vefaas
2+
3+
This is a template project for Vefaas. You can use it as a starting point for your own project.
4+
5+
We implement an minimal agent to report weather in terms of the given city.
6+
7+
## Structure
8+
9+
| File | Illustration |
10+
| - | - |
11+
| `src/app.py` | The entrypoint of VeFaaS server. |
12+
| `src/run.sh` | The launch script of VeFaaS server. |
13+
| `src/requirements.txt` | Dependencies of your project. `VeADK`, `FastAPI`, and `uvicorn` must be included. |
14+
| `src/config.py` | The agent and memory definitions. **You may edit this file.** |
15+
| `config.yaml.example` | Envs for your project (e.g., `api_key`, `token`, ...). **You may edit this file.** |
16+
| `deploy.py` | Local script for deployment. |
17+
18+
You must export your agent and short-term memory in `src/config.py`.
19+
20+
## Deploy
21+
22+
We recommand you deploy this project by the `cloud` module of VeADK.
23+
24+
```bash
25+
python deploy.py
26+
```
27+
28+
You may see output like this:
29+
30+
```bash
31+
Successfully deployed on:
32+
33+
https://....volceapi.com
34+
Message ID: ...
35+
Response from ...: The weather in Beijing is sunny, with a temperature of 25°C.
36+
App ID: ...
37+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
model:
2+
agent:
3+
provider: openai
4+
name: doubao-1-5-pro-256k-250115
5+
api_base: https://ark.cn-beijing.volces.com/api/v3/
6+
api_key:
7+
8+
volcengine:
9+
access_key:
10+
secret_key:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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())
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = 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+
)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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") == "true":
30+
from veadk.tracing.telemetry.exporters.apmplus_exporter import APMPlusExporter
31+
32+
exporters.append(APMPlusExporter())
33+
34+
if os.getenv("VEADK_TRACER_COZELOOP") == "true":
35+
from veadk.tracing.telemetry.exporters.cozeloop_exporter import CozeloopExporter
36+
37+
exporters.append(CozeloopExporter())
38+
39+
if os.getenv("VEADK_TRACER_TLS") == "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
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
git+https://github.com/volcengine/veadk-python.git
2+
uvicorn[standard]
3+
fastapi
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -ex
3+
cd `dirname $0`
4+
5+
# A special check for CLI users (run.sh should be located at the 'root' dir)
6+
if [ -d "output" ]; then
7+
cd ./output/
8+
fi
9+
10+
# Default values for host and port
11+
HOST="0.0.0.0"
12+
PORT=${_FAAS_RUNTIME_PORT:-8000}
13+
TIMEOUT=${_FAAS_FUNC_TIMEOUT}
14+
15+
export SERVER_HOST=$HOST
16+
export SERVER_PORT=$PORT
17+
18+
export PYTHONPATH=$PYTHONPATH:./site-packages
19+
# Parse arguments
20+
while [[ $# -gt 0 ]]; do
21+
case $1 in
22+
--port)
23+
PORT="$2"
24+
shift 2
25+
;;
26+
--host)
27+
HOST="$2"
28+
shift 2
29+
;;
30+
*)
31+
shift
32+
;;
33+
esac
34+
done
35+
36+
# in case of uvicorn and fastapi not installed in user's requirements.txt
37+
python3 -m pip install uvicorn[standard]
38+
39+
python3 -m pip install fastapi
40+
41+
# running
42+
exec python3 -m uvicorn app:app --host $HOST --port $PORT --timeout-graceful-shutdown $TIMEOUT

0 commit comments

Comments
 (0)