Skip to content

Commit

Permalink
Merge pull request #13 from phillip-kruger/javadoc
Browse files Browse the repository at this point in the history
Javadoc
  • Loading branch information
phillip-kruger authored Aug 29, 2024
2 parents 7a843bd + c687008 commit fcfebf5
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.13.3</quarkus.platform.version>
<quarkus.platform.version>3.14.1</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.2.5</surefire-plugin.version>

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/org/chappiebot/doc/DocAssistant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.chappiebot.doc;

import dev.langchain4j.service.SystemMessage;
import dev.langchain4j.service.UserMessage;
import io.quarkiverse.langchain4j.RegisterAiService;

@RegisterAiService
@SystemMessage("""
You are an AI assistant helping to add or modify {doc} in {programmingLanguage} code from a {product} {version} application.
You will receive the code that needs the {doc}. Please use that as input when considering the response.
Approach this task step-by-step, take your time and do not skip steps.
Respond with the original input source code, but now enhance with the {doc} on class and method levels.
This response must be valid {programmingLanguage}. Only include the {programmingLanguage} code, no explanation or other text.
You must not wrap {programmingLanguage} response in backticks, markdown, or in any other way, but return it as plain text.
""")
public interface DocAssistant {

@UserMessage("""
I have the following {programmingLanguage} class:
```
{source}
```
{extraContext}
Please add or modify the {doc} to reflect the code.
""")
public String addDoc(String programmingLanguage, String product, String version, String extraContext, String doc, String source);

}
24 changes: 24 additions & 0 deletions src/main/java/org/chappiebot/doc/DocEndpoint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.chappiebot.doc;

import io.quarkiverse.jsonrpc.runtime.api.JsonRPCApi;
import jakarta.inject.Inject;

/**
* The JsonRPC Endpoint for doc creation
* @author Phillip Kruger (phillip.kruger@gmail.com)
*/
@JsonRPCApi("doc")
public class DocEndpoint {

@Inject DocAssistant docAssistant;

public String addDoc(String programmingLanguage,
String product,
String version,
String extraContext,
String doc,
String source) {

return docAssistant.addDoc(programmingLanguage, product, version, extraContext, doc, source);
}
}
3 changes: 1 addition & 2 deletions src/main/java/org/chappiebot/test/TestAssistant.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
@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.
Please use that as input when considering the response.
You will receive the code that needs a test. Please use that as input when considering the response.
Approach this task step-by-step, take your time and do not skip steps.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/chappiebot/test/TestEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.quarkiverse.jsonrpc.runtime.api.JsonRPCApi;
import jakarta.inject.Inject;
import java.util.List;

/**
* The JsonRPC Endpoint for test creation
* @author Phillip Kruger (phillip.kruger@gmail.com)
Expand Down

0 comments on commit fcfebf5

Please sign in to comment.