File tree Expand file tree Collapse file tree 8 files changed +180
-0
lines changed
java/com/baeldung/quizzard Expand file tree Collapse file tree 8 files changed +180
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
4
+ <modelVersion >4.0.0</modelVersion >
5
+
6
+ <parent >
7
+ <groupId >com.baeldung</groupId >
8
+ <artifactId >embabel-modules</artifactId >
9
+ <version >0.0.1</version >
10
+ <relativePath >../pom.xml</relativePath >
11
+ </parent >
12
+
13
+ <groupId >com.baeldung</groupId >
14
+ <artifactId >embabel-quiz-generator</artifactId >
15
+ <version >0.0.1</version >
16
+ <name >embabel-quiz-generator</name >
17
+ <description >Agent capable of generating quizzes from blogs.</description >
18
+
19
+ <dependencies >
20
+ <dependency >
21
+ <groupId >com.embabel.agent</groupId >
22
+ <artifactId >embabel-agent-starter</artifactId >
23
+ <version >${embabel-agent.version} </version >
24
+ </dependency >
25
+ </dependencies >
26
+
27
+ <build >
28
+ <plugins >
29
+ <plugin >
30
+ <groupId >org.springframework.boot</groupId >
31
+ <artifactId >spring-boot-maven-plugin</artifactId >
32
+ </plugin >
33
+ </plugins >
34
+ </build >
35
+
36
+ <properties >
37
+ <java .version>21</java .version>
38
+ <embabel-agent .version>0.1.0-SNAPSHOT</embabel-agent .version>
39
+ </properties >
40
+
41
+ <repositories >
42
+ <repository >
43
+ <id >embabel-snapshots</id >
44
+ <url >https://repo.embabel.com/artifactory/libs-snapshot</url >
45
+ <snapshots >
46
+ <enabled >true</enabled >
47
+ </snapshots >
48
+ </repository >
49
+ </repositories >
50
+
51
+ </project >
Original file line number Diff line number Diff line change
1
+ package com .baeldung .quizzard ;
2
+
3
+ import com .embabel .agent .config .annotation .EnableAgentShell ;
4
+ import com .embabel .agent .config .annotation .EnableAgents ;
5
+ import com .embabel .agent .config .annotation .McpServers ;
6
+ import org .springframework .boot .SpringApplication ;
7
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
8
+
9
+ @ EnableAgentShell
10
+ @ SpringBootApplication
11
+ @ EnableAgents (mcpServers = {
12
+ McpServers .DOCKER_DESKTOP
13
+ })
14
+ class Application {
15
+
16
+ public static void main (String [] args ) {
17
+ SpringApplication .run (Application .class , args );
18
+ }
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .quizzard ;
2
+
3
+ import java .util .List ;
4
+
5
+ record Quiz (List <QuizQuestion > questions ) {
6
+
7
+ record QuizQuestion (
8
+ String question ,
9
+ List <String > options ,
10
+ String correctAnswer
11
+ ) {
12
+ }
13
+
14
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .quizzard ;
2
+
3
+ import com .embabel .agent .api .annotation .AchievesGoal ;
4
+ import com .embabel .agent .api .annotation .Action ;
5
+ import com .embabel .agent .api .annotation .Agent ;
6
+ import com .embabel .agent .api .common .PromptRunner ;
7
+ import com .embabel .agent .core .CoreToolGroups ;
8
+ import com .embabel .agent .domain .io .UserInput ;
9
+ import com .embabel .agent .domain .library .Blog ;
10
+ import org .springframework .beans .factory .annotation .Value ;
11
+ import org .springframework .core .io .Resource ;
12
+
13
+ import java .io .IOException ;
14
+ import java .nio .charset .Charset ;
15
+
16
+ @ Agent (
17
+ name = "quizzard" ,
18
+ description = "Generate multiple choice quizzes from blogs"
19
+ )
20
+ class QuizGeneratorAgent {
21
+
22
+ private final Resource promptTemplate ;
23
+
24
+ QuizGeneratorAgent (@ Value ("classpath:prompt-templates/quiz-generation.txt" ) Resource promptTemplate ) {
25
+ this .promptTemplate = promptTemplate ;
26
+ }
27
+
28
+ @ Action (toolGroups = CoreToolGroups .WEB )
29
+ Blog fetchBlogContent (UserInput userInput ) {
30
+ return PromptRunner
31
+ .usingLlm ()
32
+ .createObject (
33
+ "Fetch the blog content from the URL given in the following request: '%s'" .formatted (userInput ),
34
+ Blog .class
35
+ );
36
+ }
37
+
38
+ @ Action
39
+ @ AchievesGoal (description = "Quiz has been generated" )
40
+ Quiz generateQuiz (Blog blog ) throws IOException {
41
+ String prompt = promptTemplate
42
+ .getContentAsString (Charset .defaultCharset ())
43
+ .formatted (
44
+ blog .getTitle (),
45
+ blog .getContent ()
46
+ );
47
+ return PromptRunner
48
+ .usingLlm ()
49
+ .createObject (
50
+ prompt ,
51
+ Quiz .class
52
+ );
53
+ }
54
+
55
+ }
Original file line number Diff line number Diff line change
1
+ embabel :
2
+ models :
3
+ default-llm : claude-opus-4-20250514
Original file line number Diff line number Diff line change
1
+ Generate multiple choice questions based on the following blog content:
2
+
3
+ Blog title: %s
4
+ Blog content: %s
5
+
6
+ Requirements:
7
+ - Create exactly 5 questions
8
+ - Each question must have exactly 4 options
9
+ - Each question must have only one correct answer
10
+ - The difficulty level of the questions should be intermediate
11
+ - Questions should test understanding of key concepts from the blog
12
+ - Make the incorrect options plausible but clearly wrong
13
+ - Questions should be clear and unambiguous
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+ <artifactId >embabel-modules</artifactId >
7
+ <version >0.0.1</version >
8
+ <packaging >pom</packaging >
9
+ <name >embabel-modules</name >
10
+
11
+ <parent >
12
+ <groupId >com.baeldung</groupId >
13
+ <artifactId >parent-boot-3</artifactId >
14
+ <version >0.0.1-SNAPSHOT</version >
15
+ <relativePath >../parent-boot-3</relativePath >
16
+ </parent >
17
+
18
+ <modules >
19
+ <module >embabel-quiz-generator</module >
20
+ </modules >
21
+
22
+ </project >
Original file line number Diff line number Diff line change 649
649
<module >disruptor</module >
650
650
<module >docker-modules</module >
651
651
<module >drools</module >
652
+ <module >embabel-modules</module >
652
653
<module >feign</module >
653
654
<module >gcp-firebase</module >
654
655
<module >geotools</module >
1086
1087
<module >disruptor</module >
1087
1088
<module >docker-modules</module >
1088
1089
<module >drools</module >
1090
+ <module >embabel-modules</module >
1089
1091
<module >feign</module >
1090
1092
<module >gcp-firebase</module >
1091
1093
<module >geotools</module >
You can’t perform that action at this time.
0 commit comments