Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

langchain-google: remove possible trailing newline from content text in response candidates #598

Merged
merged 10 commits into from
Dec 24, 2024
Merged
3 changes: 3 additions & 0 deletions libs/genai/langchain_google_genai/chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ def _parse_response_candidate(
for part in response_candidate.content.parts:
try:
text: Optional[str] = part.text
# Remove erroneous newline character if present
if text is not None:
text = text.rstrip("\n")
except AttributeError:
text = None

Expand Down
Loading