-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Phillip Kruger <[email protected]>
- Loading branch information
1 parent
516cf65
commit 251e187
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.chappiebot.test; | ||
|
||
/** | ||
* Contains the suggested test from AI | ||
* | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
public record SuggestedTest(String explanation, String suggestedTestSource) { | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.chappiebot.test; | ||
|
||
import dev.langchain4j.service.SystemMessage; | ||
import dev.langchain4j.service.UserMessage; | ||
import io.quarkiverse.langchain4j.RegisterAiService; | ||
|
||
@RegisterAiService | ||
@SystemMessage(""" | ||
You are an AI assistant helping to create Unit tests in {programmingLanguage} code from a {product} {version} application. | ||
You will receive the code that needs a test. | ||
Approach this task step-by-step, take your time and do not skip steps. | ||
Respond with a json file, and only a json file, that is valid, and can be parsed in {programmingLanguage}. | ||
You must respond in a valid JSON format. | ||
You must not wrap JSON response in backticks, markdown, or in any other way, but return it as plain text. | ||
The json response must contain the following fields: | ||
- explanation | ||
- suggestedTestSource (this must be the full source code for the test class. Note that this suggested test source should compile) | ||
JSON Structure: | ||
{ | ||
'explanation': 'String', | ||
'suggestedTestSource: 'String' | ||
} | ||
""") | ||
public interface TestAssistant { | ||
|
||
@UserMessage(""" | ||
I have the following {programmingLanguage} class: | ||
``` | ||
{source} | ||
``` | ||
Please provide a test. | ||
""") | ||
public SuggestedTest suggestTest(String programmingLanguage, String product, String version, String source); | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.chappiebot.test; | ||
|
||
import io.quarkiverse.jsonrpc.runtime.api.JsonRPCApi; | ||
import jakarta.inject.Inject; | ||
/** | ||
* The JsonRPC Endpoint for test creation | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
@JsonRPCApi("testing") | ||
public class TestEndpoint { | ||
|
||
@Inject TestAssistant testAssistant; | ||
|
||
public SuggestedTest suggesttest(String programmingLanguage, | ||
String product, | ||
String version, | ||
String source) { | ||
|
||
return testAssistant.suggestTest(programmingLanguage, product, version, source); | ||
} | ||
} |