-
Notifications
You must be signed in to change notification settings - Fork 99
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 #571 from iocanel/jbang-cli-jokes
Refactor jokes jbang bot to be picocli based
- Loading branch information
Showing
2 changed files
with
32 additions
and
19 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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
///usr/bin/env jbang "$0" "$@" ; exit $? | ||
//DEPS io.quarkus.platform:quarkus-bom:3.9.4@pom | ||
//DEPS io.quarkus:quarkus-vertx-http:3.9.4 | ||
//DEPS io.quarkus:quarkus-picocli | ||
//DEPS io.quarkiverse.langchain4j:quarkus-langchain4j-openai:0.14.0 | ||
|
||
//Q:CONFIG quarkus.banner.enabled=false | ||
//Q:CONFIG quarkus.log.level=WARN | ||
import dev.langchain4j.model.chat.ChatLanguageModel; | ||
import io.vertx.ext.web.Router; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
import picocli.CommandLine.Command; | ||
|
||
@Command | ||
public class jokes implements Runnable { | ||
@Inject | ||
private ChatLanguageModel ai; | ||
|
||
public class jokes { | ||
void route(@Observes Router router, ChatLanguageModel ai) { | ||
router.get("/joke").blockingHandler(rc -> rc.end(ai.generate("tell me a joke"))); | ||
@Override | ||
public void run() { | ||
System.out.println(ai.generate("tell me a joke")); | ||
} | ||
} |