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
| // 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; | |
| } |
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
| application { | |
| config { | |
| baseName karaokeScheduler | |
| applicationType monolith | |
| packageName com.karaoke.scheduler | |
| authenticationType jwt | |
| prodDatabaseType postgresql | |
| devDatabaseType h2Disk | |
| buildTool maven | |
| clientFramework angular |
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
| 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); | |
| } |
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
| // 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.") | |
| ); | |
| } |
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
| ChatModel model = OllamaChatModel.builder() | |
| .baseUrl("<http://localhost:11434>") | |
| .modelName("qwen3:8b") | |
| .build(); | |
| var modelCodingAgent = AgenticServices | |
| .agentBuilder(CodingAgent.class) | |
| .chatModel(model) | |
| .build(); |
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
| // 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.") |
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
| // 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: '© <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors', | |
| }).addTo(map); | |
| // Create a layer group, | |
| const linesGroup = L.layerGroup().addTo(map); |
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
| @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) { |
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
| public class SantaResource { | |
| private final SolverFactory<SantaPlan> solverFactory; | |
| // CDI Injected solverFactory | |
| public SantaResource(SolverFactory<SantaPlan> solverFactory) { | |
| this.solverFactory = solverFactory; | |
| } | |
| /** |
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
| @PlanningSolution | |
| public class SantaPlan { | |
| @PlanningEntityProperty | |
| private Santa santa; | |
| @ProblemFactCollectionProperty | |
| @ValueRangeProvider | |
| private List<Visit> visits; | |
| @PlanningScore |
NewerOlder