:gem: [Feature] Enable animation for message generation and stop
Browse files
apps/llm_mixer/js/buttons_binder.js
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
import { ChatCompletionsRequester } from "./llm_requester.js";
|
2 |
-
import {
|
|
|
|
|
|
|
|
|
3 |
|
4 |
export class ButtonsBinder {
|
5 |
constructor() {
|
@@ -7,7 +11,7 @@ export class ButtonsBinder {
|
|
7 |
}
|
8 |
bind_send_user_input() {
|
9 |
const button = $("#send-user-input");
|
10 |
-
button.attr("status", "send");
|
11 |
button.click(async () => {
|
12 |
await this.handle_user_input(button);
|
13 |
});
|
@@ -49,24 +53,25 @@ export class ButtonsBinder {
|
|
49 |
async send(button) {
|
50 |
console.log("Send");
|
51 |
let button_icon = button.find("i");
|
52 |
-
button.attr("status", "stop");
|
53 |
button_icon
|
54 |
.removeClass()
|
55 |
.addClass("fa fa-circle-pause fa-fade")
|
56 |
.css("color", "orange");
|
|
|
57 |
await this.post_user_input();
|
58 |
-
|
59 |
-
button_icon.removeClass().addClass("fa fa-paper-plane");
|
60 |
}
|
61 |
async stop(button) {
|
62 |
console.log("Stop");
|
63 |
let button_icon = button.find("i");
|
64 |
this.requester.stop();
|
65 |
-
|
|
|
66 |
button_icon
|
67 |
.removeClass()
|
68 |
.addClass("fa fa-paper-plane")
|
69 |
-
.css("color", "
|
70 |
}
|
71 |
bind() {
|
72 |
this.bind_send_user_input();
|
|
|
1 |
import { ChatCompletionsRequester } from "./llm_requester.js";
|
2 |
+
import {
|
3 |
+
pop_messager,
|
4 |
+
stop_latest_message_animation,
|
5 |
+
start_latest_message_animation,
|
6 |
+
} from "./chat_operator.js";
|
7 |
|
8 |
export class ButtonsBinder {
|
9 |
constructor() {
|
|
|
11 |
}
|
12 |
bind_send_user_input() {
|
13 |
const button = $("#send-user-input");
|
14 |
+
button.attr("status", "send").attr("title", "Send");
|
15 |
button.click(async () => {
|
16 |
await this.handle_user_input(button);
|
17 |
});
|
|
|
53 |
async send(button) {
|
54 |
console.log("Send");
|
55 |
let button_icon = button.find("i");
|
56 |
+
button.attr("status", "stop").attr("title", "Stop");
|
57 |
button_icon
|
58 |
.removeClass()
|
59 |
.addClass("fa fa-circle-pause fa-fade")
|
60 |
.css("color", "orange");
|
61 |
+
start_latest_message_animation();
|
62 |
await this.post_user_input();
|
63 |
+
await this.stop(button);
|
|
|
64 |
}
|
65 |
async stop(button) {
|
66 |
console.log("Stop");
|
67 |
let button_icon = button.find("i");
|
68 |
this.requester.stop();
|
69 |
+
stop_latest_message_animation();
|
70 |
+
button.attr("status", "send").attr("title", "Send");
|
71 |
button_icon
|
72 |
.removeClass()
|
73 |
.addClass("fa fa-paper-plane")
|
74 |
+
.css("color", "green");
|
75 |
}
|
76 |
bind() {
|
77 |
this.bind_send_user_input();
|
apps/llm_mixer/js/chat_operator.js
CHANGED
@@ -25,12 +25,31 @@ export function get_selected_llm_model() {
|
|
25 |
return available_models_select.val();
|
26 |
}
|
27 |
|
|
|
|
|
|
|
28 |
export function get_latest_message_content_displayer() {
|
29 |
-
return
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
export function get_request_messages() {
|
35 |
return messager_list.get_request_messages();
|
36 |
}
|
|
|
25 |
return available_models_select.val();
|
26 |
}
|
27 |
|
28 |
+
export function get_latest_messager_container() {
|
29 |
+
return messager_list.messagers_container.children().last();
|
30 |
+
}
|
31 |
export function get_latest_message_content_displayer() {
|
32 |
+
return get_latest_messager_container().find(".content-displayer");
|
33 |
+
}
|
34 |
+
|
35 |
+
export function start_latest_message_animation() {
|
36 |
+
return get_latest_messager_container()
|
37 |
+
.find(".button-group")
|
38 |
+
.find(".regenerate-button")
|
39 |
+
.find("i")
|
40 |
+
.addClass("fa-spin-fast")
|
41 |
+
.css("color", "orange");
|
42 |
}
|
43 |
+
|
44 |
+
export function stop_latest_message_animation() {
|
45 |
+
return get_latest_messager_container()
|
46 |
+
.find(".button-group")
|
47 |
+
.find(".regenerate-button")
|
48 |
+
.find("i")
|
49 |
+
.removeClass("fa-spin-fast")
|
50 |
+
.css("color", "green");
|
51 |
+
}
|
52 |
+
|
53 |
export function get_request_messages() {
|
54 |
return messager_list.get_request_messages();
|
55 |
}
|
apps/llm_mixer/js/default.css
CHANGED
@@ -37,3 +37,8 @@
|
|
37 |
#available-models-select {
|
38 |
max-width: 250px;
|
39 |
}
|
|
|
|
|
|
|
|
|
|
|
|
37 |
#available-models-select {
|
38 |
max-width: 250px;
|
39 |
}
|
40 |
+
|
41 |
+
|
42 |
+
.fa-spin-fast {
|
43 |
+
animation: fa-spin 0.6s infinite linear;
|
44 |
+
}
|