-
Notifications
You must be signed in to change notification settings - Fork 3k
Introduce new assistant module #47756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
phillip-kruger
merged 1 commit into
quarkusio:main
from
phillip-kruger:chappie-extension-enablement
Jun 3, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>quarkus-assistant-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-assistant-deployment-spi</artifactId> | ||
<name>Quarkus - Assistant - Deployment SPI</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-assistant-dev</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-vertx-http-dev-ui-spi</artifactId> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
</project> |
168 changes: 168 additions & 0 deletions
168
...ment-spi/src/main/java/io/quarkus/assistant/deployment/spi/AssistantConsoleBuildItem.java
This file contains hidden or 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,168 @@ | ||
package io.quarkus.assistant.deployment.spi; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
import io.quarkus.assistant.runtime.dev.Assistant; | ||
import io.quarkus.builder.item.MultiBuildItem; | ||
import io.quarkus.deployment.console.ConsoleCommand; | ||
import io.quarkus.deployment.dev.testing.MessageFormat; | ||
|
||
/** | ||
* Add a menu item in the Assistant console menu | ||
* | ||
* Extensions can produce this to add a item under the Assistant heading in the console | ||
* This will only appear in the console if the assistant is available | ||
*/ | ||
public final class AssistantConsoleBuildItem extends MultiBuildItem { | ||
private final ConsoleCommand consoleCommand; | ||
|
||
private final String description; | ||
private final char key; | ||
private final Optional<String> systemMessage; | ||
private final String userMessage; | ||
private final Supplier<String> colorSupplier; | ||
private final Supplier<String> stateSupplier; | ||
private final Map<String, String> variables; | ||
private final Optional<Function<Assistant, CompletionStage<?>>> function; | ||
|
||
public AssistantConsoleBuildItem(ConsoleCommand consoleCommand) { | ||
this.consoleCommand = consoleCommand; | ||
this.function = Optional.empty(); | ||
this.description = consoleCommand.getDescription(); | ||
this.key = consoleCommand.getKey(); | ||
this.systemMessage = Optional.empty(); | ||
this.userMessage = null; | ||
this.colorSupplier = consoleCommand.getHelpState().getColorSupplier(); | ||
this.stateSupplier = consoleCommand.getHelpState().getStateSupplier(); | ||
this.variables = Map.of(); | ||
} | ||
|
||
private AssistantConsoleBuildItem(Builder builder) { | ||
this.description = builder.description; | ||
this.key = builder.key; | ||
this.systemMessage = builder.systemMessage; | ||
this.userMessage = builder.userMessage; | ||
this.colorSupplier = builder.colorSupplier; | ||
this.stateSupplier = builder.stateSupplier; | ||
this.variables = builder.variables; | ||
this.consoleCommand = null; | ||
this.function = builder.function; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private String description; | ||
private char key = Character.MIN_VALUE; | ||
private Optional<String> systemMessage = Optional.empty(); | ||
private String userMessage; | ||
private Supplier<String> colorSupplier = new Supplier<String>() { | ||
@Override | ||
public String get() { | ||
return MessageFormat.RESET; | ||
} | ||
}; | ||
private Supplier<String> stateSupplier = null; | ||
private Map<String, String> variables = Map.of(); | ||
private Optional<Function<Assistant, CompletionStage<?>>> function = Optional.empty(); | ||
|
||
public Builder description(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public Builder key(char key) { | ||
this.key = key; | ||
return this; | ||
} | ||
|
||
public Builder systemMessage(String systemMessage) { | ||
this.systemMessage = Optional.of(systemMessage); | ||
return this; | ||
} | ||
|
||
public Builder userMessage(String userMessage) { | ||
this.userMessage = userMessage; | ||
return this; | ||
} | ||
|
||
public Builder colorSupplier(Supplier<String> colorSupplier) { | ||
this.colorSupplier = colorSupplier; | ||
return this; | ||
} | ||
|
||
public Builder stateSupplier(Supplier<String> stateSupplier) { | ||
this.stateSupplier = stateSupplier; | ||
return this; | ||
} | ||
|
||
public Builder variables(Map<String, String> variables) { | ||
this.variables = variables; | ||
return this; | ||
} | ||
|
||
public Builder function(Function<Assistant, CompletionStage<?>> function) { | ||
this.function = Optional.of(function); | ||
return this; | ||
} | ||
|
||
public AssistantConsoleBuildItem build() { | ||
if (key == Character.MIN_VALUE) { | ||
throw new IllegalStateException( | ||
"You have to specify a key. This is the key the user will press to get to your function"); | ||
} | ||
if (description == null || description.isBlank()) { | ||
throw new IllegalStateException( | ||
"You have to specify a description. This is what the user will see in the console menu"); | ||
} | ||
if (userMessage == null && !function.isPresent()) { | ||
throw new IllegalStateException( | ||
"You have to specify userMessage that will be send to AI, or implement your own using the function"); | ||
} | ||
|
||
return new AssistantConsoleBuildItem(this); | ||
} | ||
} | ||
|
||
public ConsoleCommand getConsoleCommand() { | ||
return consoleCommand; | ||
} | ||
|
||
public String getDescription() { | ||
return consoleCommand != null ? consoleCommand.getDescription() : description; | ||
} | ||
|
||
public char getKey() { | ||
return key; | ||
} | ||
|
||
public Optional<String> getSystemMessage() { | ||
return systemMessage; | ||
} | ||
|
||
public String getUserMessage() { | ||
return userMessage; | ||
} | ||
|
||
public Supplier<String> getColorSupplier() { | ||
return consoleCommand != null ? consoleCommand.getHelpState().getColorSupplier() : colorSupplier; | ||
} | ||
|
||
public Supplier<String> getStateSupplier() { | ||
return consoleCommand != null ? consoleCommand.getHelpState().getStateSupplier() : stateSupplier; | ||
} | ||
|
||
public Map<String, String> getVariables() { | ||
return variables; | ||
} | ||
|
||
public Optional<Function<Assistant, CompletionStage<?>>> getFunction() { | ||
return function; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.