-
Notifications
You must be signed in to change notification settings - Fork 54k
codebase/introduction-to-embabel-agent-framework [BAEL-9346] #18670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
theangrydev
merged 6 commits into
eugenp:master
from
hardikSinghBehl:codebase/embabel-agent-BAEL-9346
Jul 21, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a853ec6
add quiz generator agent
hardikSinghBehl 29c247d
fix indentation
hardikSinghBehl 30105e4
fix .properties syntax
hardikSinghBehl a2bb3e6
update agent description
hardikSinghBehl 8d700fb
update prompt template
hardikSinghBehl b15737c
update chat model and move to .yaml
hardikSinghBehl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>com.baeldung</groupId> | ||
| <artifactId>embabel-modules</artifactId> | ||
| <version>0.0.1</version> | ||
| <relativePath>../pom.xml</relativePath> | ||
| </parent> | ||
|
|
||
| <groupId>com.baeldung</groupId> | ||
| <artifactId>embabel-quiz-generator</artifactId> | ||
| <version>0.0.1</version> | ||
| <name>embabel-quiz-generator</name> | ||
| <description>Agent capable of generating quizzes from blogs.</description> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.embabel.agent</groupId> | ||
| <artifactId>embabel-agent-starter</artifactId> | ||
| <version>${embabel-agent.version}</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| <properties> | ||
| <java.version>21</java.version> | ||
| <embabel-agent.version>0.1.0-SNAPSHOT</embabel-agent.version> | ||
| </properties> | ||
|
|
||
| <repositories> | ||
| <repository> | ||
| <id>embabel-snapshots</id> | ||
| <url>https://repo.embabel.com/artifactory/libs-snapshot</url> | ||
| <snapshots> | ||
| <enabled>true</enabled> | ||
| </snapshots> | ||
| </repository> | ||
| </repositories> | ||
|
|
||
| </project> |
20 changes: 20 additions & 0 deletions
20
embabel-modules/embabel-quiz-generator/src/main/java/com/baeldung/quizzard/Application.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.baeldung.quizzard; | ||
|
|
||
| import com.embabel.agent.config.annotation.EnableAgentShell; | ||
| import com.embabel.agent.config.annotation.EnableAgents; | ||
| import com.embabel.agent.config.annotation.McpServers; | ||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
|
||
| @EnableAgentShell | ||
| @SpringBootApplication | ||
| @EnableAgents(mcpServers = { | ||
| McpServers.DOCKER_DESKTOP | ||
| }) | ||
| class Application { | ||
|
|
||
| public static void main(String[] args) { | ||
| SpringApplication.run(Application.class, args); | ||
| } | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
embabel-modules/embabel-quiz-generator/src/main/java/com/baeldung/quizzard/Quiz.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.baeldung.quizzard; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| record Quiz(List<QuizQuestion> questions) { | ||
|
|
||
| record QuizQuestion( | ||
| String question, | ||
| List<String> options, | ||
| String correctAnswer | ||
| ) { | ||
| } | ||
|
|
||
| } |
55 changes: 55 additions & 0 deletions
55
...odules/embabel-quiz-generator/src/main/java/com/baeldung/quizzard/QuizGeneratorAgent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package com.baeldung.quizzard; | ||
|
|
||
| import com.embabel.agent.api.annotation.AchievesGoal; | ||
| import com.embabel.agent.api.annotation.Action; | ||
| import com.embabel.agent.api.annotation.Agent; | ||
| import com.embabel.agent.api.common.PromptRunner; | ||
| import com.embabel.agent.core.CoreToolGroups; | ||
| import com.embabel.agent.domain.io.UserInput; | ||
| import com.embabel.agent.domain.library.Blog; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.core.io.Resource; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.charset.Charset; | ||
|
|
||
| @Agent( | ||
| name = "quizzard", | ||
| description = "Generate multiple choice quizzes from blogs" | ||
| ) | ||
| class QuizGeneratorAgent { | ||
|
|
||
| private final Resource promptTemplate; | ||
|
|
||
| QuizGeneratorAgent(@Value("classpath:prompt-templates/quiz-generation.txt") Resource promptTemplate) { | ||
| this.promptTemplate = promptTemplate; | ||
| } | ||
|
|
||
| @Action(toolGroups = CoreToolGroups.WEB) | ||
| Blog fetchBlogContent(UserInput userInput) { | ||
| return PromptRunner | ||
| .usingLlm() | ||
| .createObject( | ||
| "Fetch the blog content from the URL given in the following request: '%s'".formatted(userInput), | ||
| Blog.class | ||
| ); | ||
| } | ||
|
|
||
| @Action | ||
| @AchievesGoal(description = "Quiz has been generated") | ||
| Quiz generateQuiz(Blog blog) throws IOException { | ||
| String prompt = promptTemplate | ||
| .getContentAsString(Charset.defaultCharset()) | ||
| .formatted( | ||
| blog.getTitle(), | ||
| blog.getContent() | ||
| ); | ||
| return PromptRunner | ||
| .usingLlm() | ||
| .createObject( | ||
| prompt, | ||
| Quiz.class | ||
| ); | ||
| } | ||
|
|
||
| } |
3 changes: 3 additions & 0 deletions
3
embabel-modules/embabel-quiz-generator/src/main/resources/application.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| embabel: | ||
| models: | ||
| default-llm: claude-opus-4-20250514 |
13 changes: 13 additions & 0 deletions
13
...el-modules/embabel-quiz-generator/src/main/resources/prompt-templates/quiz-generation.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Generate multiple choice questions based on the following blog content: | ||
|
|
||
| Blog title: %s | ||
| Blog content: %s | ||
|
|
||
| Requirements: | ||
| - Create exactly 5 questions | ||
| - Each question must have exactly 4 options | ||
| - Each question must have only one correct answer | ||
| - The difficulty level of the questions should be intermediate | ||
| - Questions should test understanding of key concepts from the blog | ||
| - Make the incorrect options plausible but clearly wrong | ||
| - Questions should be clear and unambiguous |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <artifactId>embabel-modules</artifactId> | ||
| <version>0.0.1</version> | ||
| <packaging>pom</packaging> | ||
| <name>embabel-modules</name> | ||
|
|
||
| <parent> | ||
| <groupId>com.baeldung</groupId> | ||
| <artifactId>parent-boot-3</artifactId> | ||
| <version>0.0.1-SNAPSHOT</version> | ||
| <relativePath>../parent-boot-3</relativePath> | ||
| </parent> | ||
|
|
||
| <modules> | ||
| <module>embabel-quiz-generator</module> | ||
| </modules> | ||
|
|
||
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂 I can see what you were inspired by