-
Notifications
You must be signed in to change notification settings - Fork 64
feat: add veadk init command in CLI module
#10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import json | ||
|
|
||
| import requests | ||
| from a2a.types import AgentCard | ||
| from google.adk.agents.remote_a2a_agent import RemoteA2aAgent | ||
|
|
||
| AGENT_CARD_WELL_KNOWN_PATH = "/.well-known/agent-card.json" | ||
|
|
||
|
|
||
| class RemoteVeAgent(RemoteA2aAgent): | ||
| def __init__(self, name: str, url: str): | ||
| agent_card_dict = requests.get(url + AGENT_CARD_WELL_KNOWN_PATH).json() | ||
| agent_card_dict["url"] = url | ||
|
|
||
| agent_card_json_str = json.dumps(agent_card_dict, ensure_ascii=False, indent=2) | ||
|
|
||
| agent_card_object = AgentCard.model_validate_json(str(agent_card_json_str)) | ||
|
|
||
| super().__init__( | ||
| name=name, description="weather reporter", agent_card=agent_card_object | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||
| # Template project for Vefaas | ||||||
|
|
||||||
| This is a template project for Vefaas. You can use it as a starting point for your own project. | ||||||
|
|
||||||
| We implement an minimal agent to report weather in terms of the given city. | ||||||
|
|
||||||
| ## Structure | ||||||
|
|
||||||
| | File | Illustration | | ||||||
| | - | - | | ||||||
| | `src/app.py` | The entrypoint of VeFaaS server. | | ||||||
| | `src/run.sh` | The launch script of VeFaaS server. | | ||||||
| | `src/requirements.txt` | Dependencies of your project. `VeADK`, `FastAPI`, and `uvicorn` must be included. | | ||||||
| | `src/config.py` | The agent and memory definitions. **You may edit this file.** | | ||||||
| | `config.yaml.example` | Envs for your project (e.g., `api_key`, `token`, ...). **You may edit this file.** | | ||||||
| | `deploy.py` | Local script for deployment. | | ||||||
|
|
||||||
| You must export your agent and short-term memory in `src/config.py`. | ||||||
|
|
||||||
| ## Deploy | ||||||
|
|
||||||
| We recommand you deploy this project by the `cloud` module of VeADK. | ||||||
|
||||||
| We recommand you deploy this project by the `cloud` module of VeADK. | |
| We recommend you deploy this project by the `cloud` module of VeADK. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| model: | ||
| agent: | ||
| provider: openai | ||
| name: doubao-1-5-pro-256k-250115 | ||
| api_base: https://ark.cn-beijing.volces.com/api/v3/ | ||
| api_key: | ||
|
|
||
| volcengine: | ||
| access_key: | ||
| secret_key: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. | ||
| # | ||
| # 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 | ||
| # | ||
| # http://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. | ||
|
|
||
| import asyncio | ||
| from pathlib import Path | ||
|
|
||
| from veadk.cloud.cloud_agent_engine import CloudAgentEngine | ||
|
|
||
| SESSION_ID = "cloud_app_test_session" | ||
| USER_ID = "cloud_app_test_user" | ||
|
|
||
|
|
||
| async def main(): | ||
| engine = CloudAgentEngine() | ||
| cloud_app = engine.deploy( | ||
| path=str(Path(__file__).parent / "src"), | ||
| name="weather-reporter", | ||
| # gateway_name="", # <--- your gateway instance name if you have | ||
| ) | ||
|
|
||
| response_message = await cloud_app.message_send( | ||
| "How is the weather like in Beijing?", SESSION_ID, USER_ID | ||
| ) | ||
|
|
||
| print(f"Message ID: {response_message.messageId}") | ||
|
|
||
| print(f"Response from {cloud_app.endpoint}: {response_message.parts[0].root.text}") | ||
|
|
||
| print(f"App ID: {cloud_app.app_id}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. | ||
| # | ||
| # 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 | ||
| # | ||
| # http://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. | ||
|
|
||
| import os | ||
|
|
||
| from config import AGENT, APP_NAME, SHORT_TERM_MEMORY, TRACERS | ||
|
|
||
| from veadk.a2a.ve_a2a_server import init_app | ||
|
|
||
| SERVER_HOST = os.getenv("SERVER_HOST") | ||
|
|
||
| AGENT.tracers = TRACERS | ||
|
|
||
| app = init_app( | ||
| server_url=SERVER_HOST, | ||
| app_name=APP_NAME, | ||
| agent=AGENT, | ||
| short_term_memory=SHORT_TERM_MEMORY, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. | ||
| # | ||
| # 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 | ||
| # | ||
| # http://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. | ||
|
|
||
| import os | ||
|
|
||
| from veadk import Agent | ||
| from veadk.memory.short_term_memory import ShortTermMemory | ||
| from veadk.tools.demo_tools import get_city_weather | ||
| from veadk.tracing.base_tracer import BaseTracer | ||
| from veadk.tracing.telemetry.opentelemetry_tracer import OpentelemetryTracer | ||
|
|
||
| # ============= | ||
| # Generated by VeADK, do not edit!!! | ||
| # ============= | ||
| TRACERS: list[BaseTracer] = [] | ||
|
|
||
| exporters = [] | ||
| if os.getenv("VEADK_TRACER_APMPLUS") == "true": | ||
| from veadk.tracing.telemetry.exporters.apmplus_exporter import APMPlusExporter | ||
|
|
||
| exporters.append(APMPlusExporter()) | ||
|
|
||
| if os.getenv("VEADK_TRACER_COZELOOP") == "true": | ||
| from veadk.tracing.telemetry.exporters.cozeloop_exporter import CozeloopExporter | ||
|
|
||
| exporters.append(CozeloopExporter()) | ||
|
|
||
| if os.getenv("VEADK_TRACER_TLS") == "true": | ||
| from veadk.tracing.telemetry.exporters.tls_exporter import TLSExporter | ||
|
|
||
| exporters.append(TLSExporter()) | ||
|
|
||
| TRACERS.append(OpentelemetryTracer(exporters=exporters)) | ||
|
|
||
| # ============= | ||
| # Required [you can edit here] | ||
| # ============= | ||
| APP_NAME: str = "weather-reporter" # <--- export your app name | ||
| AGENT: Agent = Agent(tools=[get_city_weather]) # <--- export your agent | ||
| SHORT_TERM_MEMORY: ShortTermMemory = ( | ||
| ShortTermMemory() | ||
| ) # <--- export your short term memory | ||
|
|
||
| # ============= | ||
| # Optional | ||
| # ============= | ||
| # Other global variables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| git+https://github.com/volcengine/veadk-python.git | ||
| uvicorn[standard] | ||
| fastapi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/bin/bash | ||
| set -ex | ||
| cd `dirname $0` | ||
|
|
||
| # A special check for CLI users (run.sh should be located at the 'root' dir) | ||
| if [ -d "output" ]; then | ||
| cd ./output/ | ||
| fi | ||
|
|
||
| # Default values for host and port | ||
| HOST="0.0.0.0" | ||
| PORT=${_FAAS_RUNTIME_PORT:-8000} | ||
| TIMEOUT=${_FAAS_FUNC_TIMEOUT} | ||
|
|
||
| export SERVER_HOST=$HOST | ||
| export SERVER_PORT=$PORT | ||
|
|
||
| export PYTHONPATH=$PYTHONPATH:./site-packages | ||
| # Parse arguments | ||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| --port) | ||
| PORT="$2" | ||
| shift 2 | ||
| ;; | ||
| --host) | ||
| HOST="$2" | ||
| shift 2 | ||
| ;; | ||
| *) | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # in case of uvicorn and fastapi not installed in user's requirements.txt | ||
| python3 -m pip install uvicorn[standard] | ||
|
|
||
| python3 -m pip install fastapi | ||
|
|
||
| # running | ||
| exec python3 -m uvicorn app:app --host $HOST --port $PORT --timeout-graceful-shutdown $TIMEOUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded description 'weather reporter' should be made configurable or derived from the agent card to make this class more generic and reusable.