:gem: [Feature] Enable new chat session button
Browse files
apps/llm_mixer/js/buttons_binder.js
CHANGED
@@ -3,13 +3,21 @@ import {
|
|
3 |
pop_messager,
|
4 |
stop_latest_message_animation,
|
5 |
start_latest_message_animation,
|
|
|
6 |
} from "./chat_operator.js";
|
7 |
|
8 |
-
export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
constructor() {
|
10 |
this.requester = null;
|
11 |
}
|
12 |
-
|
13 |
const button = $("#send-user-input");
|
14 |
button.attr("status", "send").attr("title", "Send");
|
15 |
button.click(async () => {
|
@@ -71,7 +79,15 @@ export class ButtonsBinder {
|
|
71 |
.addClass("fa fa-paper-plane")
|
72 |
.addClass("icon-success");
|
73 |
}
|
|
|
|
|
|
|
|
|
74 |
bind() {
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
}
|
|
|
3 |
pop_messager,
|
4 |
stop_latest_message_animation,
|
5 |
start_latest_message_animation,
|
6 |
+
create_new_chat_session,
|
7 |
} from "./chat_operator.js";
|
8 |
|
9 |
+
export function bind_chat_buttons() {
|
10 |
+
let send_binder = new SendUserInputButtonBinder();
|
11 |
+
send_binder.bind();
|
12 |
+
let new_binder = new NewChatButtonBinder();
|
13 |
+
new_binder.bind();
|
14 |
+
}
|
15 |
+
|
16 |
+
class SendUserInputButtonBinder {
|
17 |
constructor() {
|
18 |
this.requester = null;
|
19 |
}
|
20 |
+
bind() {
|
21 |
const button = $("#send-user-input");
|
22 |
button.attr("status", "send").attr("title", "Send");
|
23 |
button.click(async () => {
|
|
|
79 |
.addClass("fa fa-paper-plane")
|
80 |
.addClass("icon-success");
|
81 |
}
|
82 |
+
}
|
83 |
+
|
84 |
+
class NewChatButtonBinder {
|
85 |
+
constructor() {}
|
86 |
bind() {
|
87 |
+
const button = $("#new-chat-session");
|
88 |
+
button.attr("status", "new").attr("title", "New Chat");
|
89 |
+
button.click(() => {
|
90 |
+
create_new_chat_session();
|
91 |
+
});
|
92 |
}
|
93 |
}
|
apps/llm_mixer/js/chat_operator.js
CHANGED
@@ -1,11 +1,17 @@
|
|
1 |
import { Messager, MessagerList } from "./messager.js";
|
2 |
|
3 |
let messagers_container = $("#messagers-container");
|
4 |
-
let messager_list = new MessagerList(messagers_container);
|
5 |
let available_models_select = $("#available-models-select");
|
6 |
let temperature_select = $("#temperature-select");
|
|
|
|
|
|
|
7 |
let md_to_html_converter = new showdown.Converter();
|
8 |
|
|
|
|
|
|
|
|
|
9 |
export function create_messager(
|
10 |
role,
|
11 |
content = "",
|
@@ -19,7 +25,7 @@ export function create_messager(
|
|
19 |
temperature: temperature,
|
20 |
};
|
21 |
let messager = new Messager(message);
|
22 |
-
|
23 |
}
|
24 |
|
25 |
export function get_selected_llm_model() {
|
@@ -31,7 +37,7 @@ export function get_selected_temperature() {
|
|
31 |
}
|
32 |
|
33 |
export function get_latest_messager_container() {
|
34 |
-
return
|
35 |
}
|
36 |
export function get_latest_message_content_displayer() {
|
37 |
return get_latest_messager_container().find(".content-displayer");
|
@@ -64,11 +70,11 @@ export function stop_latest_message_animation() {
|
|
64 |
}
|
65 |
|
66 |
export function get_request_messages() {
|
67 |
-
return
|
68 |
}
|
69 |
|
70 |
export function pop_messager(n = 2) {
|
71 |
-
return
|
72 |
}
|
73 |
|
74 |
export function update_message(json_chunks, content_displayer = null) {
|
@@ -103,3 +109,9 @@ export function update_message(json_chunks, content_displayer = null) {
|
|
103 |
});
|
104 |
return json_chunks;
|
105 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import { Messager, MessagerList } from "./messager.js";
|
2 |
|
3 |
let messagers_container = $("#messagers-container");
|
|
|
4 |
let available_models_select = $("#available-models-select");
|
5 |
let temperature_select = $("#temperature-select");
|
6 |
+
|
7 |
+
let messager_list = new MessagerList(messagers_container);
|
8 |
+
let chat_history = [messager_list];
|
9 |
let md_to_html_converter = new showdown.Converter();
|
10 |
|
11 |
+
export function get_active_messager_list() {
|
12 |
+
return chat_history[chat_history.length - 1];
|
13 |
+
}
|
14 |
+
|
15 |
export function create_messager(
|
16 |
role,
|
17 |
content = "",
|
|
|
25 |
temperature: temperature,
|
26 |
};
|
27 |
let messager = new Messager(message);
|
28 |
+
get_active_messager_list().push(messager);
|
29 |
}
|
30 |
|
31 |
export function get_selected_llm_model() {
|
|
|
37 |
}
|
38 |
|
39 |
export function get_latest_messager_container() {
|
40 |
+
return get_active_messager_list().messagers_container.children().last();
|
41 |
}
|
42 |
export function get_latest_message_content_displayer() {
|
43 |
return get_latest_messager_container().find(".content-displayer");
|
|
|
70 |
}
|
71 |
|
72 |
export function get_request_messages() {
|
73 |
+
return get_active_messager_list().get_request_messages();
|
74 |
}
|
75 |
|
76 |
export function pop_messager(n = 2) {
|
77 |
+
return get_active_messager_list().pop(n);
|
78 |
}
|
79 |
|
80 |
export function update_message(json_chunks, content_displayer = null) {
|
|
|
109 |
});
|
110 |
return json_chunks;
|
111 |
}
|
112 |
+
|
113 |
+
export function create_new_chat_session() {
|
114 |
+
let new_messager_list = new MessagerList(messagers_container);
|
115 |
+
chat_history.push(new_messager_list);
|
116 |
+
messagers_container.empty();
|
117 |
+
}
|
apps/llm_mixer/js/main.js
CHANGED
@@ -2,7 +2,7 @@ import {
|
|
2 |
setup_available_models_on_select,
|
3 |
setup_temperature_on_select,
|
4 |
} from "./llm_models_loader.js";
|
5 |
-
import {
|
6 |
var user_input_history = [];
|
7 |
var user_input_history_idx = 0;
|
8 |
|
@@ -22,25 +22,10 @@ function auto_resize_user_input() {
|
|
22 |
);
|
23 |
}
|
24 |
|
25 |
-
function
|
26 |
-
// $("#user-input").on("keypress", function (event) {
|
27 |
-
// if (event.key === "Enter" && !event.shiftKey) {
|
28 |
-
// let current_user_input = $(this).val();
|
29 |
-
// user_input_history.push(current_user_input);
|
30 |
-
// $(this).val("");
|
31 |
-
// user_input_history_idx = user_input_history.length;
|
32 |
-
// set_user_input_history_buttons_state();
|
33 |
-
// console.log(user_input_history);
|
34 |
-
// request_llm();
|
35 |
setup_available_models_on_select();
|
36 |
setup_temperature_on_select();
|
37 |
-
|
38 |
-
buttons_binder.bind();
|
39 |
-
|
40 |
-
// request_available_models();
|
41 |
-
// event.preventDefault();
|
42 |
-
// }
|
43 |
-
// });
|
44 |
}
|
45 |
|
46 |
function register_user_input_history_buttons_callbacks() {
|
@@ -98,7 +83,7 @@ function adjust_messagers_container_max_height() {
|
|
98 |
$(document).ready(function () {
|
99 |
// load_available_models();
|
100 |
auto_resize_user_input();
|
101 |
-
|
102 |
register_user_input_history_buttons_callbacks();
|
103 |
adjust_messagers_container_max_height();
|
104 |
$(window).on("resize", adjust_messagers_container_max_height);
|
|
|
2 |
setup_available_models_on_select,
|
3 |
setup_temperature_on_select,
|
4 |
} from "./llm_models_loader.js";
|
5 |
+
import { bind_chat_buttons } from "./buttons_binder.js";
|
6 |
var user_input_history = [];
|
7 |
var user_input_history_idx = 0;
|
8 |
|
|
|
22 |
);
|
23 |
}
|
24 |
|
25 |
+
function setup_interactive_components() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
setup_available_models_on_select();
|
27 |
setup_temperature_on_select();
|
28 |
+
bind_chat_buttons();
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
function register_user_input_history_buttons_callbacks() {
|
|
|
83 |
$(document).ready(function () {
|
84 |
// load_available_models();
|
85 |
auto_resize_user_input();
|
86 |
+
setup_interactive_components();
|
87 |
register_user_input_history_buttons_callbacks();
|
88 |
adjust_messagers_container_max_height();
|
89 |
$(window).on("resize", adjust_messagers_container_max_height);
|