MCPcopy Index your code
hub / github.com/google/adk-python / run_input_file

Function run_input_file

src/google/adk/cli/cli.py:67–104  ·  view source on GitHub ↗
(
    app_name: str,
    user_id: str,
    agent_or_app: Union[LlmAgent, App],
    artifact_service: BaseArtifactService,
    session_service: BaseSessionService,
    credential_service: BaseCredentialService,
    input_path: str,
    memory_service: Optional[BaseMemoryService] = None,
)

Source from the content-addressed store, hash-verified

65
66
67async def run_input_file(
68 app_name: str,
69 user_id: str,
70 agent_or_app: Union[LlmAgent, App],
71 artifact_service: BaseArtifactService,
72 session_service: BaseSessionService,
73 credential_service: BaseCredentialService,
74 input_path: str,
75 memory_service: Optional[BaseMemoryService] = None,
76) -> Session:
77 app = _to_app(agent_or_app, app_name)
78 runner = Runner(
79 app=app,
80 artifact_service=artifact_service,
81 session_service=session_service,
82 memory_service=memory_service,
83 credential_service=credential_service,
84 )
85 with open(input_path, 'r', encoding='utf-8') as f:
86 input_file = InputFile.model_validate_json(f.read())
87 input_file.state['_time'] = datetime.now().isoformat()
88
89 session = await session_service.create_session(
90 app_name=app_name, user_id=user_id, state=input_file.state
91 )
92 for query in input_file.queries:
93 click.echo(f'[user]: {query}')
94 content = types.Content(role='user', parts=[types.Part(text=query)])
95 async with Aclosing(
96 runner.run_async(
97 user_id=session.user_id, session_id=session.id, new_message=content
98 )
99 ) as agen:
100 async for event in agen:
101 if event.content and event.content.parts:
102 if text := ''.join(part.text or '' for part in event.content.parts):
103 click.echo(f'[{event.author}]: {text}')
104 return session
105
106
107_REQUEST_INPUT = 'adk_request_input'

Callers 1

run_cliFunction · 0.85

Calls 7

run_asyncMethod · 0.95
_to_appFunction · 0.85
RunnerClass · 0.85
openFunction · 0.85
readMethod · 0.45
create_sessionMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected