Skip to content

Commit

Permalink
fix: prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Jul 10, 2024
1 parent 9ce8f06 commit f67450c
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package ch.xxx.aidoclibchat.usecase.service;

import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

Expand All @@ -35,15 +36,15 @@ public class CodeGenerationService {
You are an assistant to generate spring tests for the class under test.
Generate tests for this class:
%s
{classToTest}
Use these classes as context for the tests:
%s
{contextClasses}
Use this class as test example class:
%s
{testExample}
""";

public CodeGenerationService(GithubClient githubClient, ChatClient chatClient) {
Expand All @@ -55,10 +56,10 @@ public String generateTest(String url) {
var githubSource = this.createTestSources(url, true);
String contextClasses = "";
String testExample = "";
String myPrompt = String.format(this.ollamaPrompt,
githubSource.lines().stream().collect(Collectors.joining(System.getProperty("line.separator"))),
contextClasses, testExample);
var response = chatClient.call(new Prompt(new AssistantMessage(myPrompt)));
String classToTest = githubSource.lines().stream()
.collect(Collectors.joining(System.getProperty("line.separator")));
var response = chatClient.call(new Prompt(new AssistantMessage(this.ollamaPrompt,
Map.of("classToTest", classToTest, "contextClasses", contextClasses, "testExample", testExample))));
return response.getResult().getOutput().getContent();
}

Expand Down

0 comments on commit f67450c

Please sign in to comment.