MCPcopy Create free account
hub / github.com/google/adk-python / _get_latest_message_from_user

Function _get_latest_message_from_user

src/google/adk/examples/example_util.py:95–112  ·  view source on GitHub ↗

Gets the latest message from the user. Returns: The latest message from the user. If not found, returns an empty string.

(session: "Session")

Source from the content-addressed store, hash-verified

93
94
95def _get_latest_message_from_user(session: "Session") -> str:
96 """Gets the latest message from the user.
97
98 Returns:
99 The latest message from the user. If not found, returns an empty string.
100 """
101 events = session.events
102 if not events:
103 return ""
104
105 event = events[-1]
106 if event.author == "user" and not event.get_function_responses():
107 if event.content.parts and event.content.parts[0].text:
108 return event.content.parts[0].text
109 else:
110 logger.warning("No message from user for fetching example.")
111
112 return ""
113
114
115def build_example_si(

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected