Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
* @author Chris Turchin
* @author Mark Pollack
* @author Soby Chacko
* @author Jihoon Kim
* @since 0.8.1
*/
public class VertexAiGeminiChatModel extends AbstractToolCallSupport implements ChatModel, DisposableBean {
Expand Down Expand Up @@ -304,7 +305,7 @@ public ChatResponse call(Prompt prompt) {

List<Generation> generations = generateContentResponse.getCandidatesList()
.stream()
.map(this::responseCandiateToGeneration)
.map(this::responseCandidateToGeneration)
.flatMap(List::stream)
.toList();

Expand Down Expand Up @@ -352,7 +353,7 @@ public Flux<ChatResponse> stream(Prompt prompt) {

List<Generation> generations = response.getCandidatesList()
.stream()
.map(this::responseCandiateToGeneration)
.map(this::responseCandidateToGeneration)
.flatMap(List::stream)
.toList();

Expand Down Expand Up @@ -380,21 +381,20 @@ public Flux<ChatResponse> stream(Prompt prompt) {
});
}

protected List<Generation> responseCandiateToGeneration(Candidate candidate) {
protected List<Generation> responseCandidateToGeneration(Candidate candidate) {

// TODO - The candidateIndex (e.g. choice must be asigned to the generation).
int candidateIndex = candidate.getIndex();
FinishReason candidateFinishReasonn = candidate.getFinishReason();
FinishReason candidateFinishReason = candidate.getFinishReason();

Map<String, Object> messageMetadata = Map.of("candidateIndex", candidateIndex, "finishReason",
candidateFinishReasonn);
candidateFinishReason);

ChatGenerationMetadata chatGenerationMetadata = ChatGenerationMetadata.from(candidateFinishReasonn.name(),
null);
ChatGenerationMetadata chatGenerationMetadata = ChatGenerationMetadata.from(candidateFinishReason.name(), null);

boolean isFunctinCall = candidate.getContent().getPartsList().stream().allMatch(Part::hasFunctionCall);
boolean isFunctionCall = candidate.getContent().getPartsList().stream().allMatch(Part::hasFunctionCall);

if (isFunctinCall) {
if (isFunctionCall) {
List<AssistantMessage.ToolCall> assistantToolCalls = candidate.getContent()
.getPartsList()
.stream()
Expand Down