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

Function main

contributing/samples/legacy_workflows/workflow_agent_seq/main.py:30–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28
29
30async def main():
31 app_name = 'my_app'
32 user_id_1 = 'user1'
33 runner = InMemoryRunner(
34 app_name=app_name,
35 agent=agent.root_agent,
36 )
37
38 async def run_prompt(session: Session, new_message: str) -> Session:
39 content = types.Content(
40 role='user', parts=[types.Part.from_text(text=new_message)]
41 )
42 print('** User says:', content.model_dump(exclude_none=True))
43 async for event in runner.run_async(
44 user_id=user_id_1,
45 session_id=session.id,
46 new_message=content,
47 ):
48 if not event.content or not event.content.parts:
49 continue
50 if event.content.parts[0].text:
51 print(f'** {event.author}: {event.content.parts[0].text}')
52 elif event.content.parts[0].function_call:
53 print(
54 f'** {event.author}: fc /'
55 f' {event.content.parts[0].function_call.name} /'
56 f' {event.content.parts[0].function_call.args}\n'
57 )
58 elif event.content.parts[0].function_response:
59 print(
60 f'** {event.author}: fr /'
61 f' {event.content.parts[0].function_response.name} /'
62 f' {event.content.parts[0].function_response.response}\n'
63 )
64
65 return cast(
66 Session,
67 await runner.session_service.get_session(
68 app_name=app_name, user_id=user_id_1, session_id=session.id
69 ),
70 )
71
72 session_1 = await runner.session_service.create_session(
73 app_name=app_name, user_id=user_id_1
74 )
75
76 print(f'----Session to create memory: {session_1.id} ----------------------')
77 session_1 = await run_prompt(
78 session_1, 'Write a python function to do quicksort.'
79 )
80 session_1 = await run_prompt(
81 session_1, 'Write another python function to do bubble sort.'
82 )
83 print('-------------------------------------------------------------------')
84
85
86if __name__ == '__main__':

Callers 1

main.pyFile · 0.70

Calls 3

InMemoryRunnerClass · 0.90
run_promptFunction · 0.70
create_sessionMethod · 0.45

Tested by

no test coverage detected