|
26 | 26 | public class JavaAPIAgentBuilderJavaTest { |
27 | 27 |
|
28 | 28 | private static AIAgentConfig baseConfig() { |
29 | | - return new AIAgentConfig( |
30 | | - Prompt.builder("id") |
31 | | - .system("system") |
32 | | - .user("user") |
33 | | - .assistant("assistant") |
34 | | - .user("user") |
35 | | - .assistant("assistant") |
36 | | - .toolCall("id-1", "tool-1", "args-1") |
37 | | - .toolResult("id-1", "tool-1", "result-1") |
38 | | - .toolCall("id-2", "tool-2", "args-2") |
39 | | - .toolResult("id-2", "tool-2", "result-2") |
40 | | - .build(), |
41 | | - OpenAIModels.Chat.GPT4_1, |
42 | | - 100, |
43 | | - Executors.newSingleThreadExecutor(), |
44 | | - Executors.newSingleThreadExecutor() |
45 | | - ); |
| 29 | + return AIAgentConfig.builder(OpenAIModels.Chat.GPT4_1) |
| 30 | + .prompt( |
| 31 | + Prompt.builder("id") |
| 32 | + .system("system") |
| 33 | + .user("user") |
| 34 | + .assistant("assistant") |
| 35 | + .user("user") |
| 36 | + .assistant("assistant") |
| 37 | + .toolCall("id-1", "tool-1", "args-1") |
| 38 | + .toolResult("id-1", "tool-1", "result-1") |
| 39 | + .toolCall("id-2", "tool-2", "args-2") |
| 40 | + .toolResult("id-2", "tool-2", "result-2") |
| 41 | + .build() |
| 42 | + ) |
| 43 | + .maxAgentIterations(100) |
| 44 | + .llmRequestExecutorService(Executors.newSingleThreadExecutor()) |
| 45 | + .strategyExecutorService(Executors.newSingleThreadExecutor()) |
| 46 | + .build(); |
46 | 47 | } |
47 | 48 |
|
48 | 49 | @Test |
@@ -80,7 +81,12 @@ public void testFunctionalStrategyWithLambda() { |
80 | 81 |
|
81 | 82 | var agent = AIAgent.builder() |
82 | 83 | .promptExecutor(executor) |
83 | | - .agentConfig(new AIAgentConfig(Prompt.builder("p").user("hi").build(), OpenAIModels.Chat.GPT4o, 3)) |
| 84 | + .agentConfig( |
| 85 | + AIAgentConfig.builder(OpenAIModels.Chat.GPT4o) |
| 86 | + .prompt(Prompt.builder("p").user("hi").build()) |
| 87 | + .maxAgentIterations(3) |
| 88 | + .build() |
| 89 | + ) |
84 | 90 | .functionalStrategy("myStrategy", (AIAgentFunctionalContext context, String userInput) -> { |
85 | 91 | // just echo last LLM answer to ensure the pipeline works |
86 | 92 | Message.Response resp = context.requestLLM(userInput); |
@@ -124,7 +130,12 @@ public void testFunctionalStrategyWithClass() { |
124 | 130 |
|
125 | 131 | var agent = AIAgent.builder() |
126 | 132 | .promptExecutor(executor) |
127 | | - .agentConfig(new AIAgentConfig(Prompt.builder("p").user("hi").build(), OpenAIModels.Chat.GPT4o, 3)) |
| 133 | + .agentConfig( |
| 134 | + AIAgentConfig.builder(OpenAIModels.Chat.GPT4o) |
| 135 | + .prompt(Prompt.builder("p").user("hi").build()) |
| 136 | + .maxAgentIterations(3) |
| 137 | + .build() |
| 138 | + ) |
128 | 139 | .functionalStrategy(new MyJavaStrategy()) |
129 | 140 | .build(); |
130 | 141 |
|
|
0 commit comments