Skip to content
Draft
Show file tree
Hide file tree
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
18 changes: 12 additions & 6 deletions java/dev/enola/ai/dotagent/AgentsLoaderIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import static dev.enola.ai.iri.GoogleModelProvider.*;

import com.google.adk.agents.BaseAgent;
import com.google.adk.models.BaseLlm;

import dev.enola.ai.adk.iri.GoogleLlmProvider;
import dev.enola.ai.adk.test.AgentTester;
import dev.enola.ai.adk.tool.Tools;
import dev.enola.ai.iri.Provider;
import dev.enola.common.context.testlib.SingletonRule;
import dev.enola.common.io.mediatype.MediaTypeProviders;
import dev.enola.common.io.mediatype.StandardMediaTypes;
Expand All @@ -50,15 +52,20 @@ public class AgentsLoaderIntegrationTest {
SingletonRule.$(MediaTypeProviders.set(new YamlMediaType(), new StandardMediaTypes()));

final SecretManager secretManager = new TestSecretManager();
final Provider<BaseLlm> llmProvider = new GoogleLlmProvider(secretManager);
final ResourceProvider rp = new ClasspathResource.Provider("agents");

@Test
public void optimisticChefYAML_() throws IOException {
var yamlTester = new AgentsTester(rp, FLASH_LITE, llmProvider, Tools.none());
yamlTester.test("chef-optimist.agent.yaml");
}

@Test
public void optimisticChefYAML() throws IOException {
if (secretManager.getOptional(GOOGLE_AI_API_KEY_SECRET_NAME).isEmpty()) return;
// We must create the AgentsLoader AFTER we know that the API secret is available:
var loader =
new AgentsLoader(
rp, FLASH_LITE, new GoogleLlmProvider(secretManager), Tools.none());
var loader = new AgentsLoader(rp, FLASH_LITE, llmProvider, Tools.none());
var agent = load(loader, "chef-optimist.agent.yaml");
var agentTester = new AgentTester(agent);

Expand All @@ -81,7 +88,7 @@ public void clock() throws IOException {
var tools = Tools.builtin(testInstantSource);

if (secretManager.getOptional(GOOGLE_AI_API_KEY_SECRET_NAME).isEmpty()) return;
var loader = new AgentsLoader(rp, FLASH_LITE, new GoogleLlmProvider(secretManager), tools);
var loader = new AgentsLoader(rp, FLASH_LITE, llmProvider, tools);
var agent = load(loader, "clock.agent.yaml");
var agentTester = new AgentTester(agent);

Expand All @@ -96,8 +103,7 @@ public void clock() throws IOException {
@Test
public void person() throws IOException {
if (secretManager.getOptional(GOOGLE_AI_API_KEY_SECRET_NAME).isEmpty()) return;
var loader =
new AgentsLoader(rp, FLASH, new GoogleLlmProvider(secretManager), Tools.none());
var loader = new AgentsLoader(rp, FLASH, llmProvider, Tools.none());
var agent = load(loader, "person.agent.yaml");
var agentTester = new AgentTester(agent);
agentTester.assertJsonResponseEquals(
Expand Down
43 changes: 43 additions & 0 deletions java/dev/enola/ai/dotagent/AgentsTester.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2025 The Enola <https://enola.dev> Authors
*
* 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
*
* https://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.
*/
package dev.enola.ai.dotagent;

import com.google.adk.models.BaseLlm;

import dev.enola.ai.adk.tool.ToolsetProvider;
import dev.enola.ai.iri.Provider;
import dev.enola.common.io.resource.ResourceProvider;

import java.io.IOException;
import java.net.URI;
import java.util.stream.Stream;

public class AgentsTester {

public AgentsTester(
ResourceProvider resourceProvider,
URI defaultLLM,
Provider<BaseLlm> llmProvider,
ToolsetProvider toolsProvider) {}

public void test(String url) throws IOException {
test(Stream.of(URI.create(url)));
}

public void test(Stream<URI> urls) throws IOException {}
}
3 changes: 3 additions & 0 deletions test/agents/chef-optimist.agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ instruction:
every dish as a masterpiece in the making. Describe the cooking process with exaggerated enthusiasm,
using lavish, fancy culinary terms even for the most basic steps. Every step is a celebration, and
every flavor is a revelation. Your tone should be bright, inspiring, and utterly joyful.
tests:
- prompt: How to make scrambled eggs?
replyContainsAny: [darling, epiphany, odyssey, sunshine, symphony, precious, jewels, bliss]