8000 chore: Allows BaseAgent in the constructor of InMemoryRunner. · nag763/adk-python@021aadd · GitHub
[go: up one dir, main page]

Skip to content

Commit 021aadd

Browse files
Jacksunweicopybara-github
authored andcommitted
chore: Allows BaseAgent in the constructor of InMemoryRunner.
PiperOrigin-RevId: 759818175
1 parent 74b8841 commit 021aadd

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

contributing/samples/hello_world/main.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
import agent
1919
from dotenv import load_dotenv
20-
from google.adk import Runner
2120
from google.adk.agents.run_config import RunConfig
22-
from google.adk.artifacts import InMemoryArtifactService
2321
from google.adk.cli.utils import logs
24-
from google.adk.sessions import InMemorySessionService
22+
from google.adk.runners import InMemoryRunner
2523
from google.adk.sessions import Session
2624
from google.genai import types
2725

@@ -32,15 +30,11 @@
3230
async def main():
3331
app_name = 'my_app'
3432
user_id_1 = 'user1'
35-
session_service = InMemorySessionService()
36-
artifact_service = InMemoryArtifactService()
37-
runner = Runner(
38-
app_name=app_name,
33+
runner = InMemoryRunner(
3934
agent=agent.root_agent,
40-
artifact_service=artifact_service,
41-
session_service=session_service,
35+
app_name=app_name,
4236
)
43-
session_11 = await session_service.create_session(
37+
session_11 = await runner.session_service.create_session(
4438
app_name=app_name, user_id=user_id_1
4539
)
4640

@@ -85,7 +79,7 @@ async def run_prompt_bytes(session: Session, new_message: str):
8579
await run_prompt(session_11, 'What numbers did I got?')
8680
await run_prompt_bytes(session_11, 'Hi bytes')
8781
print(
88-
await artifact_service.list_artifact_keys(
82+
await runner.artifact_service.list_artifact_keys(
8983
app_name=app_name, user_id=user_id_1, session_id=session_11.id
9084
)
9185
)

src/google/adk/runners.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from typing import Optional
2424
import warnings
2525

26-
from deprecated import deprecated
2726
from google.genai import types
2827

2928
from .agents.active_streaming_tool import ActiveStreamingTool
@@ -33,7 +32,6 @@
3332
from .agents.live_request_queue import LiveRequestQueue
3433
from .agents.llm_agent import LlmAgent
3534
from .agents.run_config import RunConfig
36-
from .agents.run_config import StreamingMode
3735
from .artifacts.base_artifact_service import BaseArtifactService
3836
from .artifacts.in_memory_artifact_service import InMemoryArtifactService
3937
from .events.event import Event
@@ -475,7 +473,7 @@ class InMemoryRunner(Runner):
475473
session service for the runner.
476474
"""
477475

478-
def __init__(self, agent: LlmAgent, *, app_name: str = 'InMemoryRunner'):
476+
def __init__(self, agent: BaseAgent, *, app_name: str = 'InMemoryRunner'):
479477
"""Initializes the InMemoryRunner.
480478
481479
Args:

0 commit comments

Comments
 (0)
0