From 3c307425e04b9f0d47e074160fc703a328a5bfd4 Mon Sep 17 00:00:00 2001 From: Angular2guy Date: Fri, 12 Jul 2024 10:33:24 +0200 Subject: [PATCH] feat: add logging --- .../adapter/controller/CodeGenerationController.java | 2 ++ .../aidoclibchat/usecase/service/CodeGenerationService.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/adapter/controller/CodeGenerationController.java b/backend/src/main/java/ch/xxx/aidoclibchat/adapter/controller/CodeGenerationController.java index 9fef421..5041804 100644 --- a/backend/src/main/java/ch/xxx/aidoclibchat/adapter/controller/CodeGenerationController.java +++ b/backend/src/main/java/ch/xxx/aidoclibchat/adapter/controller/CodeGenerationController.java @@ -35,6 +35,8 @@ public CodeGenerationController(CodeGenerationService codeGenerationService) { this.codeGenerationService = codeGenerationService; } + // http://localhost:8080/rest/code-generation/test?url=https://github.com/Angular2Guy/MovieManager/blob/master/backend/src/main/java/ch/xxx/moviemanager/adapter/controller/ActorController.java&testUrl=https://github.com/Angular2Guy/MovieManager/blob/master/backend/src/test/java/ch/xxx/moviemanager/adapter/controller/MovieControllerTest.java + // http://localhost:8080/rest/code-generation/test?url=https://github.com/Angular2Guy/MovieManager/blob/master/backend/src/main/java/ch/xxx/moviemanager/usecase/service/ActorService.java&testUrl=https://github.com/Angular2Guy/MovieManager/blob/master/backend/src/test/java/ch/xxx/moviemanager/usecase/service/MovieServiceTest.java @GetMapping("/test") public String getGenerateTests(@RequestParam("url") String url, @RequestParam(name = "testUrl", required = false) String testUrl) { diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/CodeGenerationService.java b/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/CodeGenerationService.java index a735b82..523a418 100644 --- a/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/CodeGenerationService.java +++ b/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/CodeGenerationService.java @@ -72,6 +72,9 @@ public String generateTest(String url, Optional testUrlOpt) { Map.of("classToTest", classToTest, "contextClasses", contextClasses, "testExample", testExample)).createMessage().getContent()); var response = chatClient.call(new PromptTemplate(this.ollamaPrompt, Map.of("classToTest", classToTest, "contextClasses", contextClasses, "testExample", testExample)).create()); + LOGGER.info("Prompt tokens: " + response.getMetadata().getUsage().getPromptTokens()); + LOGGER.info("Generation tokens: " + response.getMetadata().getUsage().getGenerationTokens()); + LOGGER.info("Total tokens: " + response.getMetadata().getUsage().getTotalTokens()); return response.getResult().getOutput().getContent(); }