From 80c529455074f9af7cd4273a1fd9429eb2934b0e Mon Sep 17 00:00:00 2001 From: zakahan <53893931+zakahan@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:04:36 +0800 Subject: [PATCH] feat: add hello world example --- examples/hello_world/README.md | 20 +++++++++++++++ examples/hello_world/README.zh.md | 20 +++++++++++++++ examples/hello_world/main.py | 42 +++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 examples/hello_world/README.md create mode 100644 examples/hello_world/README.zh.md create mode 100644 examples/hello_world/main.py diff --git a/examples/hello_world/README.md b/examples/hello_world/README.md new file mode 100644 index 000000000..1f8dcde5b --- /dev/null +++ b/examples/hello_world/README.md @@ -0,0 +1,20 @@ +# Hello World Example + +The simplest possible VeADK example that demonstrates the basic structure of a VeADK application. + +## What it does + +- Creates a simple agent that responds with "Hello World!" +- Uses the `Runner` to execute the agent +- Prints the response to the console + +## How to run + +1. Make sure you have VeADK installed and configured properly +2. Run the example: + +```bash +python main.py +``` + +You should see "Hello World!" printed in the console. diff --git a/examples/hello_world/README.zh.md b/examples/hello_world/README.zh.md new file mode 100644 index 000000000..497305c1f --- /dev/null +++ b/examples/hello_world/README.zh.md @@ -0,0 +1,20 @@ +# Hello World 示例 + +这是最简单的 VeADK 示例,演示了 VeADK 应用程序的基本结构。 + +## 功能说明 + +- 创建一个简单的 agent,返回 "Hello World!" +- 使用 `Runner` 来执行 agent +- 将响应打印到控制台 + +## 运行方式 + +1. 确保你已经正确安装并配置了 VeADK +2. 运行示例: + +```bash +python main.py +``` + +你会在控制台看到 "Hello World!" 的输出。 diff --git a/examples/hello_world/main.py b/examples/hello_world/main.py new file mode 100644 index 000000000..3af54d2da --- /dev/null +++ b/examples/hello_world/main.py @@ -0,0 +1,42 @@ +# 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. + +"""A minimal Hello World example for VeADK. + +This is the simplest possible agent that responds with "Hello World!". +""" + +import asyncio + +from veadk import Agent, Runner + + +async def main() -> None: + agent = Agent( + name="hello_world_agent", + description="A simple agent that says hello world.", + instruction="When asked anything, respond exactly with 'Hello World!'.", + ) + + runner = Runner(agent=agent, app_name="hello_world") + + answer = await runner.run( + messages="Say hello.", + session_id="hello-world-session", + ) + print(answer) + + +if __name__ == "__main__": + asyncio.run(main())