-
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.
Merge pull request #17 from phillip-kruger/main
Replace json-rpc with REST
- Loading branch information
Showing
21 changed files
with
161 additions
and
76 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 was deleted.
Oops, something went wrong.
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,8 @@ | ||
package org.chappiebot; | ||
|
||
public record CommonInput(String programmingLanguage, | ||
String programmingLanguageVersion, | ||
String product, | ||
String productVersion) { | ||
|
||
} |
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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
package org.chappiebot.doc; | ||
|
||
import io.quarkiverse.jsonrpc.runtime.api.JsonRPCApi; | ||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.mutiny.infrastructure.Infrastructure; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
|
||
/** | ||
* The JsonRPC Endpoint for doc creation | ||
* The Endpoint for doc creation | ||
* @author Phillip Kruger (phillip.kruger@gmail.com) | ||
*/ | ||
@JsonRPCApi("doc") | ||
@Path("/api/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); | ||
@POST | ||
public Uni<DocOutput> addDoc(DocInput docInput) { | ||
return Uni.createFrom().item(() -> docAssistant.addDoc(docInput.commonInput().programmingLanguage(), | ||
docInput.commonInput().programmingLanguageVersion(), | ||
docInput.commonInput().product(), | ||
docInput.commonInput().productVersion(), | ||
docInput.extraContext().orElse(""), | ||
docInput.doc(), docInput.source())) | ||
.runSubscriptionOn(Infrastructure.getDefaultWorkerPool()); | ||
} | ||
|
||
} |
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,10 @@ | ||
package org.chappiebot.doc; | ||
|
||
import java.util.Optional; | ||
import org.chappiebot.CommonInput; | ||
|
||
public record DocInput(CommonInput commonInput, | ||
Optional<String> extraContext, | ||
String doc, | ||
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,4 @@ | ||
package org.chappiebot.doc; | ||
|
||
public record DocOutput(String sourceWithDoc){ | ||
} |
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
28 changes: 18 additions & 10 deletions
28
src/main/java/org/chappiebot/exception/ExceptionEndpoint.java
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 |
---|---|---|
@@ -1,23 +1,31 @@ | ||
package org.chappiebot.exception; | ||
|
||
import io.quarkiverse.jsonrpc.runtime.api.JsonRPCApi; | ||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.mutiny.infrastructure.Infrastructure; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
|
||
/** | ||
* The JsonRPC Endpoint for exceptions | ||
* The Endpoint for exceptions | ||
* @author Phillip Kruger (phillip.kruger@gmail.com) | ||
*/ | ||
@JsonRPCApi("exception") | ||
@Path("/api/exception") | ||
public class ExceptionEndpoint { | ||
|
||
@Inject ExceptionAssistant exceptionAssistant; | ||
|
||
public SuggestedFix suggestfix(String programmingLanguage, | ||
String product, | ||
String version, | ||
String extraContext, | ||
String stacktrace, | ||
String source) { | ||
@POST | ||
public Uni<ExceptionOutput> suggestfix(ExceptionInput exceptionInput) { | ||
|
||
return exceptionAssistant.suggestFix(programmingLanguage, product, version, extraContext, stacktrace, source); | ||
return Uni.createFrom().item(() -> exceptionAssistant.suggestFix( | ||
exceptionInput.commonInput().programmingLanguage(), | ||
exceptionInput.commonInput().programmingLanguageVersion(), | ||
exceptionInput.commonInput().product(), | ||
exceptionInput.commonInput().productVersion(), | ||
exceptionInput.extraContext().orElse(""), | ||
exceptionInput.stacktrace(), | ||
exceptionInput.source())) | ||
.runSubscriptionOn(Infrastructure.getDefaultWorkerPool()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/org/chappiebot/exception/ExceptionInput.java
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,10 @@ | ||
package org.chappiebot.exception; | ||
|
||
import org.chappiebot.CommonInput; | ||
import java.util.Optional; | ||
|
||
public record ExceptionInput(CommonInput commonInput, | ||
Optional<String> extraContext, | ||
String stacktrace, | ||
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
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
27 changes: 17 additions & 10 deletions
27
src/main/java/org/chappiebot/explain/ExplainEndpoint.java
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 |
---|---|---|
@@ -1,23 +1,30 @@ | ||
package org.chappiebot.explain; | ||
|
||
import dev.langchain4j.service.V; | ||
import io.quarkiverse.jsonrpc.runtime.api.JsonRPCApi; | ||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.mutiny.infrastructure.Infrastructure; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
|
||
/** | ||
* The JsonRPC Endpoint for explanation | ||
* The Endpoint for explanation | ||
* @author Phillip Kruger (phillip.kruger@gmail.com) | ||
*/ | ||
@JsonRPCApi("explanation") | ||
@Path("/api/explanation") | ||
public class ExplainEndpoint { | ||
|
||
@Inject ExplainAssistant explainAssistant; | ||
|
||
public String explain(@V("programmingLanguage")String programmingLanguage, | ||
@V("product")String product, | ||
@V("version")String version, | ||
@V("extraContext")String extraContext, | ||
@V("source")String source) { | ||
@POST | ||
public Uni<ExplainOutput> explain(ExplainInput explainInput) { | ||
|
||
return explainAssistant.explain(programmingLanguage, product, version, extraContext, source); | ||
return Uni.createFrom().item(() -> explainAssistant.explain( | ||
explainInput.commonInput().programmingLanguage(), | ||
explainInput.commonInput().programmingLanguageVersion(), | ||
explainInput.commonInput().product(), | ||
explainInput.commonInput().productVersion(), | ||
explainInput.extraContext().orElse(""), | ||
explainInput.source())) | ||
.runSubscriptionOn(Infrastructure.getDefaultWorkerPool()); | ||
} | ||
} |
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.explain; | ||
|
||
import java.util.Optional; | ||
import org.chappiebot.CommonInput; | ||
|
||
public record ExplainInput(CommonInput commonInput, | ||
Optional<String> extraContext, | ||
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,4 @@ | ||
package org.chappiebot.explain; | ||
|
||
public record ExplainOutput(String explanation){ | ||
} |
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
Oops, something went wrong.