We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
GenerationResponse.text
1 parent f0086df commit bdd4817Copy full SHA for bdd4817
vertexai/generative_models/_generative_models.py
@@ -1404,7 +1404,12 @@ def candidates(self) -> List["Candidate"]:
1404
@property
1405
def text(self) -> str:
1406
if len(self.candidates) > 1:
1407
- raise ValueError("Multiple candidates are not supported")
+ raise ValueError(
1408
+ "The response has multiple candidates."
1409
+ " Use `response.candidate[i].text` to get text of a particular candidate."
1410
+ )
1411
+ if not self.candidates:
1412
+ raise ValueError("Response has no candidates (and no text).")
1413
return self.candidates[0].text
1414
1415
0 commit comments