(session: Session, new_message: str)
| 37 | ) |
| 38 | |
| 39 | async def run_prompt(session: Session, new_message: str) -> Session: |
| 40 | content = types.Content( |
| 41 | role='user', parts=[types.Part.from_text(text=new_message)] |
| 42 | ) |
| 43 | print('** User says:', content.model_dump(exclude_none=True)) |
| 44 | async for event in runner.run_async( |
| 45 | user_id=user_id_1, |
| 46 | session_id=session.id, |
| 47 | new_message=content, |
| 48 | ): |
| 49 | if not event.content or not event.content.parts: |
| 50 | continue |
| 51 | if event.content.parts[0].text: |
| 52 | print(f'** {event.author}: {event.content.parts[0].text}') |
| 53 | elif event.content.parts[0].function_call: |
| 54 | print( |
| 55 | f'** {event.author}: fc /' |
| 56 | f' {event.content.parts[0].function_call.name} /' |
| 57 | f' {event.content.parts[0].function_call.args}\n' |
| 58 | ) |
| 59 | elif event.content.parts[0].function_response: |
| 60 | print( |
| 61 | f'** {event.author}: fr /' |
| 62 | f' {event.content.parts[0].function_response.name} /' |
| 63 | f' {event.content.parts[0].function_response.response}\n' |
| 64 | ) |
| 65 | |
| 66 | return cast( |
| 67 | Session, |
| 68 | await runner.session_service.get_session( |
| 69 | app_name=app_name, user_id=user_id_1, session_id=session.id |
| 70 | ), |
| 71 | ) |
| 72 | |
| 73 | session_1 = await runner.session_service.create_session( |
| 74 | app_name=app_name, user_id=user_id_1 |
no test coverage detected