Skip to content

Commit bf308ae

Browse files
committed
Sync documentation of main branch
1 parent b149fdf commit bf308ae

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

_versions/main/guides/assistant.adoc

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ An extension can define Assistant features without depending on Chappie directly
131131

132132
=== Workspace participation
133133

134-
You can add an assistant function to a workspace item using the same approach as regular https://quarkus.io/guides/dev-ui#workspace[workspace actions], with one key difference: instead of using `.function(...)`, you use `.assistantFunction(...)`.
134+
You can add an assistant function to a workspace item using the same approach as regular xref:dev-ui.adoc#workspace[workspace actions], with one key difference: instead of using `.function(...)`, you use `.assistantFunction(...)`.
135135

136136
[source,java]
137137
----
@@ -152,13 +152,13 @@ You can add an assistant function to a workspace item using the same approach as
152152
.displayType(DisplayType.markdown)
153153
.filter(Patterns.JAVA_SRC));
154154
----
155-
<1> Use `assistantFunction` to receive the `Assistant` instance and https://quarkus.io/guides/dev-ui#input[input] parameters.
155+
<1> Use `assistantFunction` to receive the `Assistant` instance and xref:dev-ui.adoc#input[input] parameters.
156156
<2> Provide an optional *system message* to guide the assistant's behavior.
157157
<3> Provide a *user message* as the primary prompt.
158158

159159
=== Assistant pages
160160

161-
To add a standalone assistant-powered page to the Dev UI, use the https://quarkus.io/guides/dev-ui#card[`CardPageBuildItem`] and `Page.assistantPageBuilder()`:
161+
To add a standalone assistant-powered page to the Dev UI, use the xref:dev-ui.adoc#card[`CardPageBuildItem`] and `Page.assistantPageBuilder()`:
162162

163163
[source,java]
164164
----
@@ -170,11 +170,11 @@ cardPageBuildItem.addPage(Page.assistantPageBuilder() // <1>
170170

171171
=== Communicating to the backend
172172

173-
You can invoke the assistant from backend code using https://quarkus.io/guides/dev-ui#communicating-to-the-backend[standard Dev UI JSON-RPC] patterns — both against the *runtime* and *deployment* classpaths.
173+
You can invoke the assistant from backend code using xref:dev-ui.adoc#communicating-to-the-backend[standard Dev UI JSON-RPC] patterns — both against the *runtime* and *deployment* classpaths.
174174

175175
==== JsonRPC against the Runtime classpath
176176

177-
To use the assistant in a https://quarkus.io/guides/dev-ui#jsonrpc-against-the-runtime-classpath[`JsonRpcService`] on the runtime classpath, inject the `Assistant` like this:
177+
To use the assistant in a xref:dev-ui.adoc#jsonrpc-against-the-runtime-classpath[`JsonRpcService`] on the runtime classpath, inject the `Assistant` like this:
178178

179179
[source,java]
180180
----
@@ -201,27 +201,29 @@ You can now use this assistant in any JsonRPC method, example:
201201

202202
==== JsonRPC against the Deployment classpath
203203

204-
In https://quarkus.io/guides/dev-ui#jsonrpc-against-the-deployment-classpath[deployment-time] code, use the `BuildTimeActionBuildItem` and register assistant actions via `.addAssistantAction(...)`:
204+
In xref:dev-ui.adoc#jsonrpc-against-the-deployment-classpath[deployment-time] code, use the `BuildTimeActionBuildItem` and register assistant actions via `.addAssistantAction(...)`:
205205

206206
[source,java]
207207
----
208208
BuildTimeActionBuildItem bta = new BuildTimeActionBuildItem();
209209
210-
bta.addAssistantAction("getAIJokeInDeployment", (a, p) -> { // <1>
211-
Assistant assistant = (Assistant) a;
210+
bta.actionBuilder()
211+
.methodName("getAIJokeInDeployment")
212+
.assistantFunction((a, p) -> { // <1>
213+
Assistant assistant = (Assistant) a;
212214
213-
return assistant.assistBuilder()
214-
.userMessage(USER_MESSAGE)
215-
.variables(p)
216-
.assist();
217-
});
215+
return assistant.assistBuilder()
216+
.userMessage(USER_MESSAGE)
217+
.variables(p)
218+
.assist();
219+
}).build());
218220
buildTimeActionProducer.produce(bta);
219221
----
220-
<1> Use `addAssistantAction` instead of `addAction` to access the assistant context.
222+
<1> Use `assistantFunction` instead of `function` to access the assistant context.
221223

222224
=== Assistant State in the UI
223225

224-
To conditionally render assistant UI in your Web Component, you can use the https://quarkus.io/guides/dev-ui#assistant-state[assistant state] to
226+
To conditionally render assistant UI in your Web Component, you can use the xref:dev-ui.adoc#assistant-state[assistant state] to
225227
check the state of the assistant. The state can be:
226228

227229
- notAvailable: No assistant implementation (like Chappie) is present.

_versions/main/guides/dev-ui.adoc

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,27 +1037,31 @@ you can just supply the code to be run in a supplier in the deployment module. T
10371037
----
10381038
@BuildStep(onlyIf = IsLocalDevelopment.class)
10391039
BuildTimeActionBuildItem createBuildTimeActions() { //<1>
1040-
BuildTimeActionBuildItem generateManifestActions = new BuildTimeActionBuildItem();//<2>
1041-
generateManifestActions.addAction("generateManifests", params -> { //<3>
1042-
try {
1043-
List<Manifest> manifests = holder.getManifests();
1044-
// Avoid relying on databind.
1045-
Map<String, String> map = new LinkedHashMap<>();
1046-
for (Manifest manifest : manifests) {
1047-
map.put(manifest.getName(), manifest.getContent());
1040+
BuildTimeActionBuildItem generateManifestActions = new BuildTimeActionBuildItem(); //<2>
1041+
1042+
generateManifestActions.actionBuilder()
1043+
.methodName("generateManifests")//<3>
1044+
.function(params -> { //<4>
1045+
try {
1046+
List<Manifest> manifests = holder.getManifests();
1047+
// Avoid relying on databind.
1048+
Map<String, String> map = new LinkedHashMap<>();
1049+
for (Manifest manifest : manifests) {
1050+
map.put(manifest.getName(), manifest.getContent());
1051+
}
1052+
return map;
1053+
} catch (Exception e) {
1054+
throw new RuntimeException(e);
10481055
}
1049-
return map;
1050-
} catch (Exception e) {
1051-
throw new RuntimeException(e);
1052-
}
1053-
});
1056+
}).build();
10541057
10551058
return generateManifestActions;
10561059
}
10571060
----
10581061
<1> Return or use a BuildProducer to create a `BuildTimeActionBuildItem`
10591062
<2> `BuildTimeActionBuildItem` is automatically scoped with your extension namespace
1060-
<3> Here we add an action, that is the same as a request-response method. The method name (that can be called from js in the same way as any json-rpc service) is `generateManifests`. If there are any parameters, those will be available in a map (params)
1063+
<3> The method name (that can be called from js in the same way as any json-rpc service) is `generateManifests`.
1064+
<4> Here we add an function that will execute when this action is requested from the UI. If there are any parameters, those will be available in a map (params)
10611065

10621066
You can also return a `CompletableFuture`/`CompletionStage` as an action, and if you want to stream data you need to use `addSubscription` (rather than `addAction`) and return a `Flow.Publisher`. Here you can not use Uni and Multi as we need to pass data between the deployment and runtime classpaths, so sticking to JDK classes is the safe option.
10631067

@@ -1070,8 +1074,10 @@ Passing recorded data to the UI work the same as the above deployment classpath,
10701074
@BuildStep(onlyIf = IsLocalDevelopment.class)
10711075
BuildTimeActionBuildItem createBuildTimeActions() {
10721076
BuildTimeActionBuildItem actionBuildItem = new BuildTimeActionBuildItem();
1073-
actionBuildItem.addAction("getMyRecordedValue", runtimeValue); // <1>
1074-
1077+
actionBuildItem.actionBuilder()
1078+
.methodName("getMyRecordedValue")
1079+
.runtime(runtimeValue) // <1>
1080+
.build();
10751081
return actionBuildItem;
10761082
}
10771083
----

0 commit comments

Comments
 (0)