diff --git a/pyproject.toml b/pyproject.toml index 57c90c32..009c035a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/veadk/configs/database_configs.py b/veadk/configs/database_configs.py index a886a9b8..6de68036 100644 --- a/veadk/configs/database_configs.py +++ b/veadk/configs/database_configs.py @@ -75,6 +75,8 @@ class RedisConfig(BaseSettings): port: int = 6379 + username: str | None = None + password: str = "" db: int = 0 diff --git a/veadk/knowledgebase/backends/redis_backend.py b/veadk/knowledgebase/backends/redis_backend.py index b990fb0a..400824c2 100644 --- a/veadk/knowledgebase/backends/redis_backend.py +++ b/veadk/knowledgebase/backends/redis_backend.py @@ -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, ) diff --git a/veadk/runner.py b/veadk/runner.py index ebd357a2..1955fd58 100644 --- a/veadk/runner.py +++ b/veadk/runner.py @@ -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__( diff --git a/veadk/version.py b/veadk/version.py index a6961407..763d0b67 100644 --- a/veadk/version.py +++ b/veadk/version.py @@ -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"