Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "veadk-python"
version = "0.2.21"
version = "0.2.22"
description = "Volcengine agent development kit, integrations with Volcengine cloud services."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
2 changes: 2 additions & 0 deletions veadk/configs/database_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class RedisConfig(BaseSettings):

port: int = 6379

username: str | None = None

password: str = ""

db: int = 0
Expand Down
1 change: 1 addition & 0 deletions veadk/knowledgebase/backends/redis_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def model_post_init(self, __context: Any) -> None:
host=self.redis_config.host,
port=self.redis_config.port,
db=self.redis_config.db,
username=self.redis_config.username,
password=self.redis_config.password,
)

Expand Down
122 changes: 0 additions & 122 deletions veadk/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,128 +288,6 @@ class Runner(ADKRunner):
This class wraps the parent ``run_async`` at initialization to insert media
upload and post-run handling. If you override the underlying ``run_async``,
ensure it remains compatible with this interception logic.

Examples:
### Text-only interaction

```python
import asyncio

from veadk import Agent, Runner

agent = Agent()

runner = Runner(agent=agent)

response = asyncio.run(runner.run(messages="北京的天气怎么样?"))

print(response)
```

### Send multimodal data to agent

Currently, VeADK support send multimodal data (i.e., text with images) to agent, and invoke the corresponding model to do tasks.

!!! info "Note for multimodal running"

When sending multimodal data to agent, the model of agent must support multimodal data processing. For example, `doubao-1-6`.

```python
import asyncio

from veadk import Agent, Runner
from veadk.types import MediaMessage

agent = Agent(model_name="doubao-seed-1-6-250615")

runner = Runner(agent=agent)

message = MediaMessage(
text="Describe the image",
media="https://...", # <-- replace here with an image from web
)
response = asyncio.run(runner.run(messages=message))

print(response)
```

### Run with run_async

You are recommand that **using `run_async` in production to invoke agent**. During running, the loop will throw out `event`, you can process each `event` according to your requirements.

```python
import uuid

from google.genai import types
from veadk import Agent, Runner

APP_NAME = "app"
USER_ID = "user"

agent = Agent()

runner = Runner(agent=agent, app_name=APP_NAME)


async def main(message: types.Content, session_id: str):
# before running, you should create a session first
await runner.short_term_memory.create_session(
app_name=APP_NAME, user_id=USER_ID, session_id=session_id
)

async for event in runner.run_async(
user_id=USER_ID,
session_id=session_id,
new_message=message,
):
# process event here
print(event)


if __name__ == "__main__":
import asyncio

message = types.Content(parts=[types.Part(text="Hello")], role="user")
session_id = str(uuid.uuid1())
asyncio.run(main(message=message, session_id=session_id))
```

### Custom your message

You can custom your message content, as Google provides some basic types to build and custom agent's input. For example, you can build a message with a text and several images.

```python
from google.genai import types

# build message with a text
message = types.Content(parts=[types.Part(text="Hello")], role="user")

# build message with a text and an image
message = types.Content(
parts=[
types.Part(text="Hello!"),
types.Part(
inline_data=types.Blob(display_name="foo.png", data=..., mime_type=...)
),
],
role="user",
)

# build image with several text and several images
message = types.Content(
parts=[
types.Part(text="Hello!"),
types.Part(text="Please help me to describe the following images."),
types.Part(
inline_data=types.Blob(display_name="foo.png", data=..., mime_type=...)
),
types.Part(
inline_data=types.Blob(display_name="bar.png", data=..., mime_type=...)
),
],
role="user",
)
```
"""

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion veadk/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION = "0.2.21"
VERSION = "0.2.22"