Skip to content

Commit

Permalink
chore: GenAI - Validating history in the ChatSession constructor
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 590588154
  • Loading branch information
Ark-kun authored and copybara-github committed Dec 13, 2023
1 parent b647ef9 commit 0dccd83
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vertexai/generative_models/_generative_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ def __init__(
history: Optional[List["Content"]] = None,
raise_on_blocked: bool = True,
):
if history:
if not all(isinstance(item, Content) for item in history):
raise ValueError("history must be a list of Content objects.")

self._model = model
self._history = history or []
self._raise_on_blocked = raise_on_blocked
Expand Down

0 comments on commit 0dccd83

Please sign in to comment.