Skip to content

Commit efd5a72

Browse files
Ark-kuncopybara-github
authored andcommitted
feat: GenAI - Added the GenerationResponse.prompt_feedback property
PiperOrigin-RevId: 625506526
1 parent 423c764 commit efd5a72

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tests/unit/vertexai/test_generative_models.py

+2
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ def test_chat_send_message_response_blocked_errors(
500500
chat.send_message("Please block with block_reason=OTHER.")
501501

502502
assert e.match("Blocked for testing")
503+
# Checking that the original response and the block reason are accessible.
504+
assert e.value.responses[0].prompt_feedback.block_reason.name == "OTHER"
503505
# Checking that history did not get updated
504506
assert len(chat.history) == 2
505507

vertexai/generative_models/_generative_models.py

+6
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,12 @@ def text(self) -> str:
16421642
raise ValueError("Response has no candidates (and no text).")
16431643
return self.candidates[0].text
16441644

1645+
@property
1646+
def prompt_feedback(
1647+
self,
1648+
) -> gapic_prediction_service_types.GenerateContentResponse.PromptFeedback:
1649+
return self._raw_response.prompt_feedback
1650+
16451651

16461652
class Candidate:
16471653
"""A response candidate generated by the model."""

0 commit comments

Comments
 (0)