-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathChatboxController.java
More file actions
36 lines (29 loc) · 968 Bytes
/
ChatboxController.java
File metadata and controls
36 lines (29 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.example.gui;
import javafx.concurrent.Task;
import javafx.scene.layout.Region;
public class ChatboxController {
private final ChatboxViewBuilder viewBuilder;
private final ChatboxInteractor interactor;
public ChatboxController() {
ChatboxModel model = new ChatboxModel();
interactor = new ChatboxInteractor(model);
viewBuilder = new ChatboxViewBuilder(model, this::runInference);
}
private void runInference(Runnable postRunAction) {
Task<Void> inferenceTask = new Task<>() {
@Override
protected Void call() {
interactor.runLlamaTornado();
return null;
}
};
inferenceTask.setOnSucceeded(evt -> {
postRunAction.run();
});
Thread inferenceThread = new Thread(inferenceTask);
inferenceThread.start();
}
public Region getView() {
return viewBuilder.build();
}
}