|
45 | 45 | import com.google.adk.agents.ConfigAgentUtils.ConfigurationException; |
46 | 46 | import com.google.adk.codeexecutors.BaseCodeExecutor; |
47 | 47 | import com.google.adk.events.Event; |
48 | | -import com.google.adk.examples.BaseExampleProvider; |
49 | | -import com.google.adk.examples.Example; |
50 | 48 | import com.google.adk.flows.llmflows.AutoFlow; |
51 | 49 | import com.google.adk.flows.llmflows.BaseLlmFlow; |
52 | 50 | import com.google.adk.flows.llmflows.SingleFlow; |
@@ -97,8 +95,6 @@ public enum IncludeContents { |
97 | 95 | private final List<Object> toolsUnion; |
98 | 96 | private final ImmutableList<BaseToolset> toolsets; |
99 | 97 | private final Optional<GenerateContentConfig> generateContentConfig; |
100 | | - // TODO: Remove exampleProvider field - examples should only be provided via ExampleTool |
101 | | - private final Optional<BaseExampleProvider> exampleProvider; |
102 | 98 | private final IncludeContents includeContents; |
103 | 99 |
|
104 | 100 | private final boolean planning; |
@@ -132,7 +128,6 @@ protected LlmAgent(Builder builder) { |
132 | 128 | this.globalInstruction = |
133 | 129 | requireNonNullElse(builder.globalInstruction, new Instruction.Static("")); |
134 | 130 | this.generateContentConfig = Optional.ofNullable(builder.generateContentConfig); |
135 | | - this.exampleProvider = Optional.ofNullable(builder.exampleProvider); |
136 | 131 | this.includeContents = requireNonNullElse(builder.includeContents, IncludeContents.DEFAULT); |
137 | 132 | this.planning = builder.planning != null && builder.planning; |
138 | 133 | this.maxSteps = Optional.ofNullable(builder.maxSteps); |
@@ -180,7 +175,6 @@ public static class Builder extends BaseAgent.Builder<Builder> { |
180 | 175 | private Instruction globalInstruction; |
181 | 176 | private ImmutableList<Object> toolsUnion; |
182 | 177 | private GenerateContentConfig generateContentConfig; |
183 | | - private BaseExampleProvider exampleProvider; |
184 | 178 | private IncludeContents includeContents; |
185 | 179 | private Boolean planning; |
186 | 180 | private Integer maxSteps; |
@@ -253,26 +247,6 @@ public Builder generateContentConfig(GenerateContentConfig generateContentConfig |
253 | 247 | return this; |
254 | 248 | } |
255 | 249 |
|
256 | | - // TODO: Remove these example provider methods and only use ExampleTool for providing examples. |
257 | | - // Direct example methods should be deprecated in favor of using ExampleTool consistently. |
258 | | - @CanIgnoreReturnValue |
259 | | - public Builder exampleProvider(BaseExampleProvider exampleProvider) { |
260 | | - this.exampleProvider = exampleProvider; |
261 | | - return this; |
262 | | - } |
263 | | - |
264 | | - @CanIgnoreReturnValue |
265 | | - public Builder exampleProvider(List<Example> examples) { |
266 | | - this.exampleProvider = (unused) -> examples; |
267 | | - return this; |
268 | | - } |
269 | | - |
270 | | - @CanIgnoreReturnValue |
271 | | - public Builder exampleProvider(Example... examples) { |
272 | | - this.exampleProvider = (unused) -> ImmutableList.copyOf(examples); |
273 | | - return this; |
274 | | - } |
275 | | - |
276 | 250 | @CanIgnoreReturnValue |
277 | 251 | public Builder includeContents(IncludeContents includeContents) { |
278 | 252 | this.includeContents = includeContents; |
@@ -640,10 +614,24 @@ protected void validate() { |
640 | 614 | + " transfer."); |
641 | 615 | } |
642 | 616 | if (this.toolsUnion != null && !this.toolsUnion.isEmpty()) { |
643 | | - throw new IllegalArgumentException( |
644 | | - "Invalid config for agent " |
645 | | - + this.name |
646 | | - + ": if outputSchema is set, tools must be empty."); |
| 617 | + boolean hasOtherTools = |
| 618 | + this.toolsUnion.stream() |
| 619 | + .anyMatch( |
| 620 | + tool -> { |
| 621 | + if (tool instanceof BaseToolset) { |
| 622 | + return true; |
| 623 | + } |
| 624 | + if (tool instanceof BaseTool) { |
| 625 | + return !((BaseTool) tool).name().equals("example_tool"); |
| 626 | + } |
| 627 | + return true; |
| 628 | + }); |
| 629 | + if (hasOtherTools) { |
| 630 | + throw new IllegalArgumentException( |
| 631 | + "Invalid config for agent " |
| 632 | + + this.name |
| 633 | + + ": if outputSchema is set, tools must be empty."); |
| 634 | + } |
647 | 635 | } |
648 | 636 | } |
649 | 637 | } |
@@ -812,11 +800,6 @@ public Optional<GenerateContentConfig> generateContentConfig() { |
812 | 800 | return generateContentConfig; |
813 | 801 | } |
814 | 802 |
|
815 | | - // TODO: Remove this getter - examples should only be provided via ExampleTool |
816 | | - public Optional<BaseExampleProvider> exampleProvider() { |
817 | | - return exampleProvider; |
818 | | - } |
819 | | - |
820 | 803 | public IncludeContents includeContents() { |
821 | 804 | return includeContents; |
822 | 805 | } |
|
0 commit comments