Skip to content

Commit 48cfb3d

Browse files
Jacksunweicopybara-github
authored andcommitted
chore: Adds an INSTANCE to GoogleSearchTool and LoadArtifactsTool and adds usage example in javadoc
PiperOrigin-RevId: 795552096
1 parent 1a93675 commit 48cfb3d

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

core/src/main/java/com/google/adk/tools/GoogleSearchTool.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,17 @@
3131
*
3232
* <p>This tool operates internally within the model and does not require or perform local code
3333
* execution.
34+
*
35+
* <p>Usage example in an LlmAgent:
36+
*
37+
* <pre>{@code
38+
* LlmAgent agent = LlmAgent.builder()
39+
* .addTool(GoogleSearchTool.INSTANCE)
40+
* .build();
41+
* }</pre>
3442
*/
3543
public final class GoogleSearchTool extends BaseTool {
44+
public static final GoogleSearchTool INSTANCE = new GoogleSearchTool();
3645

3746
public GoogleSearchTool() {
3847
super("google_search", "google_search");

core/src/main/java/com/google/adk/tools/LoadArtifactsTool.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,21 @@
4141
*
4242
* <p>This tool informs the model about available artifacts and provides their content when
4343
* requested by the model through a function call.
44+
*
45+
* <p>The declaration of this tool is consistent with the Python version. Refer to:
46+
* https://github.com/google/adk-python/blob/main/src/google/adk/tools/load_artifacts_tool.py
47+
*
48+
* <p>Usage example in an LlmAgent:
49+
*
50+
* <pre>{@code
51+
* LlmAgent agent = LlmAgent.builder()
52+
* .addTool(LoadArtifactsTool.INSTANCE)
53+
* .build();
54+
* }</pre>
4455
*/
4556
public final class LoadArtifactsTool extends BaseTool {
57+
public static final LoadArtifactsTool INSTANCE = new LoadArtifactsTool();
58+
4659
public LoadArtifactsTool() {
4760
super("load_artifacts", "Loads the artifacts and adds them to the session.");
4861
}

core/src/main/java/com/google/adk/utils/ComponentRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ private void initializePreWiredEntries() {
9696
registerAdkAgentClass(ParallelAgent.class);
9797
registerAdkAgentClass(SequentialAgent.class);
9898

99-
registerAdkToolInstance("google_search", new GoogleSearchTool());
100-
registerAdkToolInstance("load_artifacts", new LoadArtifactsTool());
99+
registerAdkToolInstance("google_search", GoogleSearchTool.INSTANCE);
100+
registerAdkToolInstance("load_artifacts", LoadArtifactsTool.INSTANCE);
101101
registerAdkToolInstance("exit_loop", ExitLoopTool.INSTANCE);
102102

103103
registerAdkToolClass(AgentTool.class);

0 commit comments

Comments
 (0)