Skip to content

Commit

Permalink
langchain-google: remove possible trailing newline from content text …
Browse files Browse the repository at this point in the history
…in response candidates (#598)
  • Loading branch information
aaronbriel authored Dec 24, 2024
1 parent 7382d23 commit cb64151
Showing 1 changed file with 3 additions and 0 deletions.
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

0 comments on commit cb64151

Please sign in to comment.