diff --git a/google/generativeai/types/generation_types.py b/google/generativeai/types/generation_types.py index e7b912678..d4bed8b86 100644 --- a/google/generativeai/types/generation_types.py +++ b/google/generativeai/types/generation_types.py @@ -449,7 +449,7 @@ def text(self): language = "" else: language = f" {language}" - texts.extend([f"```{language}", part.executable_code.code, "```"]) + texts.extend([f"```{language}", part.executable_code.code.lstrip("\n"), "```"]) continue if "code_execution_result" in part: outcome_result = part.code_execution_result.outcome.name.lower().replace(