|
17 | 17 | package com.google.cloud.vertexai.generativeai; |
18 | 18 |
|
19 | 19 | import com.google.cloud.vertexai.api.Candidate; |
20 | | -import com.google.cloud.vertexai.api.Candidate.Builder; |
21 | 20 | import com.google.cloud.vertexai.api.Candidate.FinishReason; |
22 | 21 | import com.google.cloud.vertexai.api.Citation; |
23 | 22 | import com.google.cloud.vertexai.api.CitationMetadata; |
@@ -59,14 +58,10 @@ public static String getText(GenerateContentResponse response) { |
59 | 58 | * |
60 | 59 | * @param response a {@link com.google.cloud.vertexai.api.GenerateContentResponse} instance |
61 | 60 | * @return a list of {@link com.google.cloud.vertexai.api.FunctionCall} in the response |
62 | | - * @throws IllegalArgumentException if the response has 0 or more than 1 candidates, or if the |
63 | | - * response is blocked by safety reason or unauthorized citations |
| 61 | + * @throws IllegalArgumentException if the response has 0 or more than 1 candidates |
64 | 62 | */ |
65 | 63 | public static ImmutableList<FunctionCall> getFunctionCalls(GenerateContentResponse response) { |
66 | | - checkFinishReason(getFinishReason(response)); |
67 | | - if (response.getCandidatesCount() == 0) { |
68 | | - return ImmutableList.of(); |
69 | | - } |
| 64 | + getFinishReason(response); |
70 | 65 | return response.getCandidates(0).getContent().getPartsList().stream() |
71 | 66 | .filter((part) -> part.hasFunctionCall()) |
72 | 67 | .map((part) -> part.getFunctionCall()) |
@@ -162,7 +157,7 @@ static GenerateContentResponse aggregateStreamIntoResponse( |
162 | 157 | List<Candidate> aggregatedCandidates = new ArrayList<>(); |
163 | 158 | candidates.forEach( |
164 | 159 | (index, candidate) -> { |
165 | | - Builder candidateBuilder = candidate.toBuilder(); |
| 160 | + Candidate.Builder candidateBuilder = candidate.toBuilder(); |
166 | 161 | if (aggregatedContentParts.containsKey(index)) { |
167 | 162 | candidateBuilder.setContent( |
168 | 163 | Content.newBuilder() |
|
0 commit comments