Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
ec420d4
feat: middlewareV2
xavidop Mar 29, 2026
af6c77b
fix: code assist feedback
xavidop Mar 29, 2026
ef9de78
fix: use Part instead of ToolResponse
xavidop Apr 13, 2026
26034f2
chore(deps)(deps): bump com.google.cloud:google-cloud-trace
dependabot[bot] Mar 23, 2026
37266f1
chore(deps)(deps): bump aws.sdk.version from 2.42.13 to 2.42.18
dependabot[bot] Mar 23, 2026
8fd5c72
chore(deps)(deps): bump jackson.version from 2.21.1 to 2.21.2
dependabot[bot] Mar 23, 2026
f68a889
chore(deps)(deps): bump spring-boot.version from 4.0.3 to 4.0.4
dependabot[bot] Mar 23, 2026
3883284
chore(deps)(deps): bump com.google.genai:google-genai
dependabot[bot] Mar 23, 2026
3765fee
chore(deps)(deps): bump com.google.cloud:google-cloud-logging
dependabot[bot] Mar 23, 2026
b7cbb84
chore(deps)(deps): bump com.google.cloud:google-cloud-monitoring
dependabot[bot] Mar 23, 2026
dcde400
chore(deps)(deps): bump com.google.genai:google-genai
dependabot[bot] Mar 30, 2026
0a8a296
chore(deps)(deps): bump com.puppycrawl.tools:checkstyle
dependabot[bot] Mar 30, 2026
2d75769
chore(deps)(deps): bump google-cloud-firestore.version
dependabot[bot] Mar 30, 2026
f04958f
chore(deps)(deps): bump aws.sdk.version from 2.42.18 to 2.42.23
dependabot[bot] Mar 30, 2026
15567a4
chore(deps)(deps): bump spring-boot.version from 4.0.4 to 4.0.5
dependabot[bot] Mar 30, 2026
3df5dc9
chore(deps)(deps): bump io.modelcontextprotocol.sdk:mcp
dependabot[bot] Mar 30, 2026
6c9bb8e
feat: new main page
xavidop Mar 30, 2026
6f3572f
fix: build
xavidop Mar 30, 2026
3ecd7c5
fix: more docs fixes
xavidop Mar 30, 2026
f5baf84
feat: add configuration for maven
xavidop Mar 31, 2026
9d55f0c
feat: agent skills
xavidop Apr 2, 2026
2520df3
feat: add google search console
xavidop Apr 2, 2026
b3f41ad
feat: google analytics
xavidop Apr 2, 2026
4d52b40
fix: you dont need to call genkit.init()
xavidop Apr 3, 2026
70ef2cd
fix: update prints with correct paths
xavidop Apr 3, 2026
6a7ceaf
chore(deps): bump defu
dependabot[bot] Apr 4, 2026
7837585
chore(deps)(deps): bump io.pinecone:pinecone-client from 6.1.0 to 6.2.0
dependabot[bot] Apr 6, 2026
dd62f81
chore(deps)(deps): bump aws.sdk.version from 2.42.23 to 2.42.28
dependabot[bot] Apr 6, 2026
e66193e
chore(ci): bump actions/upload-pages-artifact from 3 to 4
dependabot[bot] Apr 6, 2026
bbc30f7
chore(ci): bump actions/setup-node from 4 to 6
dependabot[bot] Apr 6, 2026
cedab1d
chore(ci): bump actions/deploy-pages from 4 to 5
dependabot[bot] Apr 6, 2026
5e5ce64
chore(deps)(deps): bump com.google.genai:google-genai
dependabot[bot] Apr 6, 2026
7bc87e1
chore(ci): bump actions/checkout from 4 to 6
dependabot[bot] Apr 6, 2026
af000c6
chore(ci): bump actions/setup-java from 4 to 5
dependabot[bot] Apr 6, 2026
ccb6188
chore(deps): bump vite
dependabot[bot] Apr 7, 2026
0583a0f
chore(deps)(deps): bump opentelemetry.version from 1.60.1 to 1.61.0
dependabot[bot] Apr 13, 2026
733485f
chore(deps)(deps): bump com.google.genai:google-genai
dependabot[bot] Apr 13, 2026
247120f
chore(deps)(deps): bump aws.sdk.version from 2.42.28 to 2.42.33
dependabot[bot] Apr 13, 2026
de8fb11
chore(deps)(deps): bump com.google.cloud:google-cloud-logging
dependabot[bot] Apr 13, 2026
f0b9b1c
chore(deps)(deps): bump com.google.cloud.functions:functions-framewor…
dependabot[bot] Apr 13, 2026
26893b3
chore(deps)(deps-dev): bump com.google.cloud.functions:function-maven…
dependabot[bot] Apr 13, 2026
e7b1ea5
chore(deps)(deps): bump com.google.cloud:google-cloud-trace
dependabot[bot] Apr 13, 2026
d1722c0
chore(deps)(deps): bump com.google.cloud:google-cloud-monitoring
dependabot[bot] Apr 13, 2026
97cbb24
fix: V2 feedback
xavidop Mar 29, 2026
11d70c3
fix: ffedback and refactored the code to work with both
xavidop Apr 13, 2026
897749a
fix: refleciton v1 fix
xavidop Apr 13, 2026
d95d65c
fix: deps
xavidop Apr 13, 2026
20f1893
fix: license
xavidop Apr 13, 2026
b88a7d4
fix: continue lifecycle after an interrupts
xavidop Apr 13, 2026
63d4181
Merge branch 'main' into xavier/middleware-v2
xavidop Apr 13, 2026
52a9441
feat: udpated docs
xavidop Apr 13, 2026
4aca6fd
refactor: extract GenerateActionOptions and OutputConfig into top-lev…
pavelgj May 7, 2026
db04427
feat: add messageIndex to GenerateParams for conversation position tr…
pavelgj May 7, 2026
a12106a
Merge pull request #170 from genkit-ai/pj/middlware-pr-suggestions
xavidop May 8, 2026
2a654d7
feat: add streaming chunk callback support to generation middleware
pavelgj May 8, 2026
e1316d0
Merge pull request #171 from genkit-ai/pj/middleware-stream-intercept
xavidop May 8, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ node_modules
*.log
hs_err_pid*
samples/google-genai/generated_media/
.astro
130 changes: 1 addition & 129 deletions ai/src/main/java/com/google/genkit/ai/GenerateAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package com.google.genkit.ai;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.genkit.ai.telemetry.ModelTelemetryHelper;
Expand All @@ -39,7 +37,7 @@
* AI models. It's registered at /util/generate and is used by the Dev UI.
*/
public class GenerateAction
implements Action<GenerateAction.GenerateActionOptions, ModelResponse, ModelResponseChunk> {
implements Action<GenerateActionOptions, ModelResponse, ModelResponseChunk> {

private static final Logger logger = LoggerFactory.getLogger(GenerateAction.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
Expand Down Expand Up @@ -457,130 +455,4 @@ private ToolDefinition resolveToolDefinition(String toolName) {
ActionDesc desc = action.getDesc();
return new ToolDefinition(desc.getName(), desc.getDescription(), desc.getInputSchema(), null);
}

/** Options for the generate utility action. */
@JsonIgnoreProperties(ignoreUnknown = true)
public static class GenerateActionOptions {

@JsonProperty("model")
private String model;

@JsonProperty("messages")
private List<Message> messages;

@JsonProperty("tools")
private List<String> tools;

@JsonProperty("resources")
private List<String> resources;

@JsonProperty("toolChoice")
private String toolChoice;

@JsonProperty("config")
private GenerationConfig config;

@JsonProperty("output")
private OutputConfig output;

@JsonProperty("docs")
private List<Document> docs;

@JsonProperty("returnToolRequests")
private Boolean returnToolRequests;

@JsonProperty("maxTurns")
private Integer maxTurns;

@JsonProperty("stepName")
private String stepName;

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public List<Message> getMessages() {
return messages;
}

public void setMessages(List<Message> messages) {
this.messages = messages;
}

public List<String> getTools() {
return tools;
}

public void setTools(List<String> tools) {
this.tools = tools;
}

public List<String> getResources() {
return resources;
}

public void setResources(List<String> resources) {
this.resources = resources;
}

public String getToolChoice() {
return toolChoice;
}

public void setToolChoice(String toolChoice) {
this.toolChoice = toolChoice;
}

public GenerationConfig getConfig() {
return config;
}

public void setConfig(GenerationConfig config) {
this.config = config;
}

public OutputConfig getOutput() {
return output;
}

public void setOutput(OutputConfig output) {
this.output = output;
}

public List<Document> getDocs() {
return docs;
}

public void setDocs(List<Document> docs) {
this.docs = docs;
}

public Boolean getReturnToolRequests() {
return returnToolRequests;
}

public void setReturnToolRequests(Boolean returnToolRequests) {
this.returnToolRequests = returnToolRequests;
}

public Integer getMaxTurns() {
return maxTurns;
}

public void setMaxTurns(Integer maxTurns) {
this.maxTurns = maxTurns;
}

public String getStepName() {
return stepName;
}

public void setStepName(String stepName) {
this.stepName = stepName;
}
}
}
219 changes: 219 additions & 0 deletions ai/src/main/java/com/google/genkit/ai/GenerateActionOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.genkit.ai;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;

/**
* High-level options for the generate action, representing the generate request <em>before</em>
* model and tool resolution. This is the Java equivalent of the JS {@code GenerateActionOptions}
* type.
*
* <p>This type is used by:
*
* <ul>
* <li>The {@code /util/generate} action (Dev UI)
* <li>The {@link com.google.genkit.ai.middleware.GenerationMiddleware#wrapGenerate wrapGenerate}
* middleware hook
* </ul>
*
* <p>Unlike {@link ModelRequest}, which is the low-level <em>resolved</em> request sent to a model,
* this class retains high-level information such as the model name as a string and tool names as
* string references. This allows {@code wrapGenerate} middleware to modify these values before
* resolution occurs (e.g., swapping the model, adding/removing tools by name, changing output
* format).
*
* @see com.google.genkit.ai.middleware.GenerateParams
* @see com.google.genkit.ai.middleware.GenerationMiddleware#wrapGenerate
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class GenerateActionOptions {

@JsonProperty("model")
private String model;

@JsonProperty("messages")
private List<Message> messages;

@JsonProperty("tools")
private List<String> tools;

@JsonProperty("resources")
private List<String> resources;

@JsonProperty("toolChoice")
private String toolChoice;

@JsonProperty("config")
private GenerationConfig config;

@JsonProperty("output")
private OutputConfig output;

@JsonProperty("docs")
private List<Document> docs;

@JsonProperty("returnToolRequests")
private Boolean returnToolRequests;

@JsonProperty("maxTurns")
private Integer maxTurns;

@JsonProperty("stepName")
private String stepName;

/** Default constructor for JSON deserialization. */
public GenerateActionOptions() {}

// =========================================================================
// Copy helpers
// =========================================================================

/**
* Returns a new {@code GenerateActionOptions} with the given messages, preserving all other
* fields. This is used in the tool loop to advance the conversation without mutating the
* original.
*
* @param newMessages the updated message list
* @return a new options instance
*/
public GenerateActionOptions withMessages(List<Message> newMessages) {
GenerateActionOptions copy = new GenerateActionOptions();
copy.model = this.model;
copy.messages = newMessages != null ? new ArrayList<>(newMessages) : null;
copy.tools = this.tools;
copy.resources = this.resources;
copy.toolChoice = this.toolChoice;
copy.config = this.config;
copy.output = this.output;
copy.docs = this.docs;
copy.returnToolRequests = this.returnToolRequests;
copy.maxTurns = this.maxTurns;
copy.stepName = this.stepName;
return copy;
}

/**
* Returns a new {@code GenerateActionOptions} with the given model name, preserving all other
* fields.
*
* @param newModel the model name
* @return a new options instance
*/
public GenerateActionOptions withModel(String newModel) {
GenerateActionOptions copy = withMessages(this.messages);
copy.model = newModel;
return copy;
}

// =========================================================================
// Getters and setters
// =========================================================================

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public List<Message> getMessages() {
return messages;
}

public void setMessages(List<Message> messages) {
this.messages = messages;
}

public List<String> getTools() {
return tools;
}

public void setTools(List<String> tools) {
this.tools = tools;
}

public List<String> getResources() {
return resources;
}

public void setResources(List<String> resources) {
this.resources = resources;
}

public String getToolChoice() {
return toolChoice;
}

public void setToolChoice(String toolChoice) {
this.toolChoice = toolChoice;
}

public GenerationConfig getConfig() {
return config;
}

public void setConfig(GenerationConfig config) {
this.config = config;
}

public OutputConfig getOutput() {
return output;
}

public void setOutput(OutputConfig output) {
this.output = output;
}

public List<Document> getDocs() {
return docs;
}

public void setDocs(List<Document> docs) {
this.docs = docs;
}

public Boolean getReturnToolRequests() {
return returnToolRequests;
}

public void setReturnToolRequests(Boolean returnToolRequests) {
this.returnToolRequests = returnToolRequests;
}

public Integer getMaxTurns() {
return maxTurns;
}

public void setMaxTurns(Integer maxTurns) {
this.maxTurns = maxTurns;
}

public String getStepName() {
return stepName;
}

public void setStepName(String stepName) {
this.stepName = stepName;
}
}
Loading
Loading