|
19 | 19 | import com.alibaba.cloud.ai.example.deepresearch.config.PythonCoderProperties;
|
20 | 20 | import com.alibaba.cloud.ai.example.deepresearch.tool.PlannerTool;
|
21 | 21 | import com.alibaba.cloud.ai.example.deepresearch.tool.PythonReplTool;
|
| 22 | +import com.alibaba.cloud.ai.example.deepresearch.util.ResourceUtil; |
22 | 23 | import com.alibaba.cloud.ai.toolcalling.jinacrawler.JinaCrawlerConstants;
|
23 | 24 | import com.alibaba.cloud.ai.toolcalling.tavily.TavilySearchConstants;
|
24 | 25 | import org.springframework.ai.chat.client.ChatClient;
|
|
32 | 33 | import org.springframework.context.annotation.Configuration;
|
33 | 34 | import org.springframework.core.io.Resource;
|
34 | 35 |
|
35 |
| -import java.io.IOException; |
36 |
| -import java.nio.charset.Charset; |
37 | 36 | import java.util.Arrays;
|
38 | 37 | import java.util.Map;
|
39 | 38 |
|
@@ -77,32 +76,31 @@ private ToolCallback[] getMcpToolCallbacks(String agentName) {
|
77 | 76 |
|
78 | 77 | /**
|
79 | 78 | * Create Research Agent ChatClient Bean
|
80 |
| - * @param chatClientBuilder ChatClientBuilder McpAsyncClient and the locally configure |
81 |
| - * ToolCallbackProviders. |
| 79 | + * @param researchChatClientBuilder ChatClientBuilder McpAsyncClient and the locally |
| 80 | + * configure ToolCallbackProviders. |
82 | 81 | * @return ChatClient
|
83 | 82 | */
|
84 | 83 | @Bean
|
85 |
| - public ChatClient researchAgent(ChatClient.Builder chatClientBuilder) throws IOException { |
| 84 | + public ChatClient researchAgent(ChatClient.Builder researchChatClientBuilder) { |
86 | 85 | ToolCallback[] mcpCallbacks = getMcpToolCallbacks("researchAgent");
|
87 | 86 |
|
88 |
| - return chatClientBuilder.defaultSystem(researcherPrompt.getContentAsString(Charset.defaultCharset())) |
| 87 | + return researchChatClientBuilder.defaultSystem(ResourceUtil.loadResourceAsString(researcherPrompt)) |
89 | 88 | .defaultToolNames(this.getAvailableTools(TavilySearchConstants.TOOL_NAME, JinaCrawlerConstants.TOOL_NAME))
|
90 | 89 | .defaultToolCallbacks(mcpCallbacks)
|
91 | 90 | .build();
|
92 | 91 | }
|
93 | 92 |
|
94 | 93 | /**
|
95 | 94 | * Create Coder Agent ChatClient Bean
|
96 |
| - * @param chatClientBuilder ChatClientBuilder McpAsyncClient and the locally configure |
97 |
| - * ToolCallbackProviders. |
| 95 | + * @param coderChatClientBuilder ChatClientBuilder McpAsyncClient and the locally |
| 96 | + * configure ToolCallbackProviders. |
98 | 97 | * @return ChatClient
|
99 | 98 | */
|
100 | 99 | @Bean
|
101 |
| - public ChatClient coderAgent(ChatClient.Builder chatClientBuilder, PythonCoderProperties coderProperties) |
102 |
| - throws IOException { |
| 100 | + public ChatClient coderAgent(ChatClient.Builder coderChatClientBuilder, PythonCoderProperties coderProperties) { |
103 | 101 | ToolCallback[] mcpCallbacks = getMcpToolCallbacks("coderAgent");
|
104 | 102 |
|
105 |
| - return chatClientBuilder.defaultSystem(coderPrompt.getContentAsString(Charset.defaultCharset())) |
| 103 | + return coderChatClientBuilder.defaultSystem(ResourceUtil.loadResourceAsString(coderPrompt)) |
106 | 104 | .defaultTools(new PythonReplTool(coderProperties))
|
107 | 105 | .defaultToolCallbacks(mcpCallbacks)
|
108 | 106 | .build();
|
|
0 commit comments