Skip to content

Commit 600c04c

Browse files
feat(graph): add schema agent generator (alibaba#2352)
* feat: add AgentProjectGenerator * feat: add AgentDSLAdapter AgentProjectGenerator * feat: add AgentProjectGenerator * feat: add AgentDSLAdapter AgentProjectGenerator * feat: add AgentProvider * feat: add AgentProjectGenerator * fix: add AgentProjectGenerator * fix: merge * fix: AgentDSLAdapter * feat: update schema * feat: schema to agent * feat: Java format * feat: add AbstractAgentTypeProvider * chore: Revert unnecessary modifications * chore: java format * chore: add license * fix: code optimization for schema agent render
1 parent 9ee2a25 commit 600c04c

File tree

18 files changed

+1575
-4
lines changed

18 files changed

+1575
-4
lines changed

spring-ai-alibaba-studio/spring-ai-alibaba-studio-server/spring-ai-alibaba-studio-server-admin/src/main/java/com/alibaba/cloud/ai/studio/admin/generator/format/EclipseJdtFormatProjectContributor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ public void contribute(Path projectRoot) throws IOException {
5353
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, "space");
5454
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
5555

56+
// Line length and wrapping configuration
57+
options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120");
58+
59+
// Method chain formatting - moderate wrapping
60+
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION,
61+
DefaultCodeFormatterConstants.createAlignmentValue(false, // Don't force
62+
// wrapping
63+
DefaultCodeFormatterConstants.WRAP_COMPACT, // Compact wrapping
64+
// when needed
65+
DefaultCodeFormatterConstants.INDENT_DEFAULT));
66+
67+
// Keep simple statements on one line
68+
options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE,
69+
DefaultCodeFormatterConstants.TRUE);
70+
5671
CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
5772

5873
try (Stream<Path> files = Files.walk(javaSrc)) {

spring-ai-alibaba-studio/spring-ai-alibaba-studio-server/spring-ai-alibaba-studio-server-admin/src/main/java/com/alibaba/cloud/ai/studio/admin/generator/model/AppMetadata.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public class AppMetadata {
2121

2222
public static final String WORKFLOW_MODE = "workflow";
2323

24-
public static final String[] SUPPORT_MODES = { CHATBOT_MODE, WORKFLOW_MODE };
24+
public static final String AGENT_MODE = "agent";
25+
26+
public static final String[] SUPPORT_MODES = { CHATBOT_MODE, WORKFLOW_MODE, AGENT_MODE };
2527

2628
private String id;
2729

spring-ai-alibaba-studio/spring-ai-alibaba-studio-server/spring-ai-alibaba-studio-server-admin/src/main/java/com/alibaba/cloud/ai/studio/admin/generator/model/AppModeEnum.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public enum AppModeEnum {
2222

23-
WORKFLOW("workflow");
23+
WORKFLOW("workflow"), AGENT("agent");
2424

2525
private String value;
2626

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/*
2+
* Copyright 2024-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.alibaba.cloud.ai.studio.admin.generator.model.agent;
17+
18+
import java.util.List;
19+
import java.util.Map;
20+
21+
/**
22+
* @author yHong
23+
* @version 1.0
24+
* @since 2025/8/25 17:28
25+
*/
26+
public class Agent {
27+
28+
// 基础属性
29+
private String agentClass; // ReactAgent, SequentialAgent, ParallelAgent.etc
30+
31+
private String name;
32+
33+
private String description;
34+
35+
private String outputKey;
36+
37+
private String inputKey;
38+
39+
// 支持多输入键(与 schema: input_keys 对齐)
40+
private List<String> inputKeys;
41+
42+
// LLM相关配置
43+
private String model;
44+
45+
private String instruction;
46+
47+
private Integer maxIterations;
48+
49+
private Map<String, Object> chatOptions;
50+
51+
// 工具配置
52+
private List<String> tools;
53+
54+
private Map<String, Object> toolConfig;
55+
56+
// 子agent配置
57+
private List<Agent> subAgents;
58+
59+
// 流程控制配置
60+
private Map<String, Object> flowConfig;
61+
62+
// 状态管理配置
63+
private Map<String, String> stateConfig;
64+
65+
// 钩子配置
66+
private Map<String, Object> hooks;
67+
68+
// 动态 handle:原样透传每种 agent type 的专属配置
69+
private Map<String, Object> handle;
70+
71+
public Agent() {
72+
}
73+
74+
public String getAgentClass() {
75+
return agentClass;
76+
}
77+
78+
public void setAgentClass(String agentClass) {
79+
this.agentClass = agentClass;
80+
}
81+
82+
public String getName() {
83+
return name;
84+
}
85+
86+
public void setName(String name) {
87+
this.name = name;
88+
}
89+
90+
public String getDescription() {
91+
return description;
92+
}
93+
94+
public void setDescription(String description) {
95+
this.description = description;
96+
}
97+
98+
public String getOutputKey() {
99+
return outputKey;
100+
}
101+
102+
public void setOutputKey(String outputKey) {
103+
this.outputKey = outputKey;
104+
}
105+
106+
public String getInputKey() {
107+
return inputKey;
108+
}
109+
110+
public void setInputKey(String inputKey) {
111+
this.inputKey = inputKey;
112+
}
113+
114+
public List<String> getInputKeys() {
115+
return inputKeys;
116+
}
117+
118+
public void setInputKeys(List<String> inputKeys) {
119+
this.inputKeys = inputKeys;
120+
}
121+
122+
public String getModel() {
123+
return model;
124+
}
125+
126+
public void setModel(String model) {
127+
this.model = model;
128+
}
129+
130+
public String getInstruction() {
131+
return instruction;
132+
}
133+
134+
public void setInstruction(String instruction) {
135+
this.instruction = instruction;
136+
}
137+
138+
public Integer getMaxIterations() {
139+
return maxIterations;
140+
}
141+
142+
public void setMaxIterations(Integer maxIterations) {
143+
this.maxIterations = maxIterations;
144+
}
145+
146+
public Map<String, Object> getChatOptions() {
147+
return chatOptions;
148+
}
149+
150+
public void setChatOptions(Map<String, Object> chatOptions) {
151+
this.chatOptions = chatOptions;
152+
}
153+
154+
public List<String> getTools() {
155+
return tools;
156+
}
157+
158+
public void setTools(List<String> tools) {
159+
this.tools = tools;
160+
}
161+
162+
public Map<String, Object> getToolConfig() {
163+
return toolConfig;
164+
}
165+
166+
public void setToolConfig(Map<String, Object> toolConfig) {
167+
this.toolConfig = toolConfig;
168+
}
169+
170+
public List<Agent> getSubAgents() {
171+
return subAgents;
172+
}
173+
174+
public void setSubAgents(List<Agent> subAgents) {
175+
this.subAgents = subAgents;
176+
}
177+
178+
public Map<String, Object> getFlowConfig() {
179+
return flowConfig;
180+
}
181+
182+
public void setFlowConfig(Map<String, Object> flowConfig) {
183+
this.flowConfig = flowConfig;
184+
}
185+
186+
public Map<String, String> getStateConfig() {
187+
return stateConfig;
188+
}
189+
190+
public void setStateConfig(Map<String, String> stateConfig) {
191+
this.stateConfig = stateConfig;
192+
}
193+
194+
public Map<String, Object> getHooks() {
195+
return hooks;
196+
}
197+
198+
public void setHooks(Map<String, Object> hooks) {
199+
this.hooks = hooks;
200+
}
201+
202+
public Map<String, Object> getHandle() {
203+
return handle;
204+
}
205+
206+
public void setHandle(Map<String, Object> handle) {
207+
this.handle = handle;
208+
}
209+
210+
}

spring-ai-alibaba-studio/spring-ai-alibaba-studio-server/spring-ai-alibaba-studio-server-admin/src/main/java/com/alibaba/cloud/ai/studio/admin/generator/service/dsl/DSLDialectType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public enum DSLDialectType {
2424

2525
STUDIO("studio", ".json"),
2626

27-
CUSTOM("custom", ".yml");
27+
CUSTOM("custom", ".yml"),
28+
29+
SAA_AGENT("saa-agent", ".yaml");
2830

2931
private final String value;
3032

0 commit comments

Comments
 (0)