Skip to content

Instantly share code, notes, and snippets.

View TomCools's full-sized avatar

Tom Cools TomCools

View GitHub Profile
// This file is an example of AI generated code with Ollama Qwen3:8b
// Comments tell you more about what is wrong about it. Do not try to copy this ;)
// Not how you implement constraints in Timefold
public class NoConsecutiveSameSingerOrArtistConstraint implements HardConstraint {
@Override //None existing type
public ConstraintMatchType getConstraintMatchType() {
return ConstraintMatchType.HARD;
}
@TomCools
TomCools / model.jdl
Last active November 27, 2025 19:11
JDL
application {
  config {
    baseName karaokeScheduler
    applicationType monolith
    packageName com.karaoke.scheduler
    authenticationType jwt
    prodDatabaseType postgresql
    devDatabaseType h2Disk
    buildTool maven
    clientFramework angular
@TomCools
TomCools / ContentRetriever.java
Last active November 27, 2025 19:08
ContentRetriever
private ContentRetriever createContentRetriever(String subdir) {
URL resource = ClassLoaderUtils.getResource("./docs/" + subdir);
var documents = loadDocuments(resource.getPath());
InMemoryEmbeddingStore<TextSegment> embeddingStore = new InMemoryEmbeddingStore<>();
EmbeddingStoreIngestor.ingest(documents, embeddingStore);
return EmbeddingStoreContentRetriever.from(embeddingStore);
}
@TomCools
TomCools / CompilerTool.java
Last active November 27, 2025 19:08
Compiler Tool Agentic
// Truncated compiler code 
@Tool("Compiles the given Java source code and returns whether it is OK or NOT_OK, including compiler errors.")
public CompilationResult compileJavaCode(String code) {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
return new CompilationResult(
false,
List.of("No system Java compiler found. Make sure you're running on a JDK, not a JRE.")
);
}
@TomCools
TomCools / ModelConfig.java
Last active November 27, 2025 19:09
OllamaModel
ChatModel model = OllamaChatModel.builder()
            .baseUrl("<http://localhost:11434>")
            .modelName("qwen3:8b")
            .build();
var modelCodingAgent = AgenticServices
                .agentBuilder(CodingAgent.class)
                .chatModel(model)
                .build();
@TomCools
TomCools / CodingAgent.java
Last active November 27, 2025 19:09
CodingAgent
// in CodingAgent.java
@SystemMessage("""
You are a Timefold constraint optimization problem coder, expert in Java.
You create Java classes only.
""")
@UserMessage("""
Please create the the Java domain classes and constraint methods for the following optimization problem
The problem statement: {{problemStatement}}.
""")
@Agent(outputName = "code", value = "Creates the relevant Java domain classes for the following problem statement.")
// Prepare a custom icon, since default one is not "Christmas" enough.
const treeIcon = L.icon({iconUrl: 'tree-marker.png', iconSize: [20, 20]})
const map = L.map('map', {doubleClickZoom: false}).setView([66.5039, 25.7294], 4);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
}).addTo(map);
// Create a layer group,
const linesGroup = L.layerGroup().addTo(map);
@Path("santa")
public class SantaResource {
// Fields and constructor excluded
@POST
@Path("plan")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public SantaPlan solve(List<Visit> visits) {
public class SantaResource {
private final SolverFactory<SantaPlan> solverFactory;
// CDI Injected solverFactory
public SantaResource(SolverFactory<SantaPlan> solverFactory) {
this.solverFactory = solverFactory;
}
/**
@PlanningSolution
public class SantaPlan {
@PlanningEntityProperty
private Santa santa;
@ProblemFactCollectionProperty
@ValueRangeProvider
private List<Visit> visits;
@PlanningScore