Skip to content

Commit e952458

Browse files
committed
Demonstrate validation
1 parent e6303aa commit e952458

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/com/embabel/template/injected/InjectedDemo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.embabel.template.injected;
22

33
import com.embabel.agent.api.common.Ai;
4+
import jakarta.validation.constraints.Pattern;
45
import org.springframework.stereotype.Component;
56

67
/**
@@ -11,7 +12,14 @@
1112
@Component
1213
public record InjectedDemo(Ai ai) {
1314

14-
public record Animal(String name, String species) {
15+
/**
16+
* Demonstrates use of JSR-380 validation annotations on record fields
17+
* to constrain generated content.
18+
*/
19+
public record Animal(
20+
String name,
21+
@Pattern(regexp = ".*ox.*", message = "Species must contain 'ox'")
22+
String species) {
1523
}
1624

1725
public Animal inventAnimal() {

src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#embabel.models.default-llm=llama3.1:8b
44
#embabel.models.default-embedding-model=nomic-embed-text:latest
55

6+
embabel.agent.platform.llm-operations.data-binding.send_validation_info=true
7+
68
# Llm Roles: Create as many as you want and use with byRole("role-name")
79
#embabel.models.llms.best=llama3.1:8b
810
#embabel.models.llms.cheapest=llama3.1:8b

0 commit comments

Comments
 (0)