@@ -288,128 +288,6 @@ class Runner(ADKRunner):
288288 This class wraps the parent ``run_async`` at initialization to insert media
289289 upload and post-run handling. If you override the underlying ``run_async``,
290290 ensure it remains compatible with this interception logic.
291-
292- Examples:
293- ### Text-only interaction
294-
295- ```python
296- import asyncio
297-
298- from veadk import Agent, Runner
299-
300- agent = Agent()
301-
302- runner = Runner(agent=agent)
303-
304- response = asyncio.run(runner.run(messages="北京的天气怎么样?"))
305-
306- print(response)
307- ```
308-
309- ### Send multimodal data to agent
310-
311- Currently, VeADK support send multimodal data (i.e., text with images) to agent, and invoke the corresponding model to do tasks.
312-
313- !!! info "Note for multimodal running"
314-
315- When sending multimodal data to agent, the model of agent must support multimodal data processing. For example, `doubao-1-6`.
316-
317- ```python
318- import asyncio
319-
320- from veadk import Agent, Runner
321- from veadk.types import MediaMessage
322-
323- agent = Agent(model_name="doubao-seed-1-6-250615")
324-
325- runner = Runner(agent=agent)
326-
327- message = MediaMessage(
328- text="Describe the image",
329- media="https://...", # <-- replace here with an image from web
330- )
331- response = asyncio.run(runner.run(messages=message))
332-
333- print(response)
334- ```
335-
336- ### Run with run_async
337-
338- 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.
339-
340- ```python
341- import uuid
342-
343- from google.genai import types
344- from veadk import Agent, Runner
345-
346- APP_NAME = "app"
347- USER_ID = "user"
348-
349- agent = Agent()
350-
351- runner = Runner(agent=agent, app_name=APP_NAME)
352-
353-
354- async def main(message: types.Content, session_id: str):
355- # before running, you should create a session first
356- await runner.short_term_memory.create_session(
357- app_name=APP_NAME, user_id=USER_ID, session_id=session_id
358- )
359-
360- async for event in runner.run_async(
361- user_id=USER_ID,
362- session_id=session_id,
363- new_message=message,
364- ):
365- # process event here
366- print(event)
367-
368-
369- if __name__ == "__main__":
370- import asyncio
371-
372- message = types.Content(parts=[types.Part(text="Hello")], role="user")
373- session_id = str(uuid.uuid1())
374- asyncio.run(main(message=message, session_id=session_id))
375- ```
376-
377- ### Custom your message
378-
379- 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.
380-
381- ```python
382- from google.genai import types
383-
384- # build message with a text
385- message = types.Content(parts=[types.Part(text="Hello")], role="user")
386-
387- # build message with a text and an image
388- message = types.Content(
389- parts=[
390- types.Part(text="Hello!"),
391- types.Part(
392- inline_data=types.Blob(display_name="foo.png", data=..., mime_type=...)
393- ),
394- ],
395- role="user",
396- )
397-
398- # build image with several text and several images
399- message = types.Content(
400- parts=[
401- types.Part(text="Hello!"),
402- types.Part(text="Please help me to describe the following images."),
403- types.Part(
404- inline_data=types.Blob(display_name="foo.png", data=..., mime_type=...)
405- ),
406- types.Part(
407- inline_data=types.Blob(display_name="bar.png", data=..., mime_type=...)
408- ),
409- ],
410- role="user",
411- )
412- ```
413291 """
414292
415293 def __init__ (
0 commit comments