diff --git a/src/google/adk/flows/llm_flows/_code_execution.py b/src/google/adk/flows/llm_flows/_code_execution.py index bfa84db69d..05fc00cdfc 100644 --- a/src/google/adk/flows/llm_flows/_code_execution.py +++ b/src/google/adk/flows/llm_flows/_code_execution.py @@ -76,6 +76,14 @@ class DataFileUtil: _DATA_FILE_HELPER_LIB = ''' import pandas as pd +def crop(s: str, max_chars: int = 64) -> str: + """Crops a string to max_chars characters.""" + if len(s) <= max_chars: + return s + if max_chars >= 3: + return s[:max_chars - 3] + '...' + return s[:max_chars] + def explore_df(df: pd.DataFrame) -> None: """Prints some information about a pandas DataFrame."""