:recycle: [Refactor] Remove unused codes for interactive components
Browse files- components/llm_models_loader.js +0 -29
- main.js +0 -50
components/llm_models_loader.js
CHANGED
@@ -83,32 +83,3 @@ export async function setup_temperature_on_select(default_option = null) {
|
|
83 |
}
|
84 |
console.log(`Default temperature: ${select.val()}`);
|
85 |
}
|
86 |
-
|
87 |
-
export function setup_endpoint_and_key() {
|
88 |
-
if (localStorage.getItem("openai_endpoint")) {
|
89 |
-
$("#openai-endpoint").val(localStorage.getItem("openai_endpoint"));
|
90 |
-
console.log("GET: OpenAI Endpoint!");
|
91 |
-
} else {
|
92 |
-
console.log("NULL: OpenAI Endpoint!");
|
93 |
-
$("#openai-endpoint").on("submit", function (event) {
|
94 |
-
event.preventDefault();
|
95 |
-
localStorage.setItem(
|
96 |
-
"openai_endpoint",
|
97 |
-
$("#openai-endpoint").val()
|
98 |
-
);
|
99 |
-
console.log("SET: OpenAI Endpoint!");
|
100 |
-
});
|
101 |
-
}
|
102 |
-
|
103 |
-
if (localStorage.getItem("openai_api_key")) {
|
104 |
-
$("#openai-api-key").val(localStorage.getItem("openai_api_key"));
|
105 |
-
console.log("GET: OpenAI API Key!");
|
106 |
-
} else {
|
107 |
-
console.log("NULL: OpenAI API Key!");
|
108 |
-
$("#openai-api-key").on("submit", function (event) {
|
109 |
-
event.preventDefault();
|
110 |
-
localStorage.setItem("openai_api_key", $("#openai-api-key").val());
|
111 |
-
console.log("SET: OpenAI API Key!");
|
112 |
-
});
|
113 |
-
}
|
114 |
-
}
|
|
|
83 |
}
|
84 |
console.log(`Default temperature: ${select.val()}`);
|
85 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.js
CHANGED
@@ -3,12 +3,6 @@ import {
|
|
3 |
setup_temperature_on_select,
|
4 |
} from "./components/llm_models_loader.js";
|
5 |
import { bind_chat_buttons } from "./components/buttons_binder.js";
|
6 |
-
var user_input_history = [];
|
7 |
-
var user_input_history_idx = 0;
|
8 |
-
|
9 |
-
$("#user-input").on("enter", function () {
|
10 |
-
console.log("enter");
|
11 |
-
});
|
12 |
|
13 |
function auto_resize_user_input() {
|
14 |
// https://stackoverflow.com/questions/37629860/automatically-resizing-textarea-in-bootstrap
|
@@ -35,54 +29,10 @@ function setup_interactive_components() {
|
|
35 |
setup_temperature_on_select();
|
36 |
auto_resize_user_input();
|
37 |
bind_chat_buttons();
|
38 |
-
register_user_input_history_buttons_callbacks();
|
39 |
adjust_messagers_container_max_height();
|
40 |
$(window).on("resize", adjust_messagers_container_max_height);
|
41 |
}
|
42 |
|
43 |
-
function register_user_input_history_buttons_callbacks() {
|
44 |
-
set_user_input_history_buttons_state();
|
45 |
-
$("#prev-user-input").click(function (event) {
|
46 |
-
console.log("prev");
|
47 |
-
user_input_history_idx = Math.max(0, user_input_history_idx - 1);
|
48 |
-
user_input_history_value = user_input_history[user_input_history_idx];
|
49 |
-
$("#user-input").val(user_input_history_value);
|
50 |
-
set_user_input_history_buttons_state();
|
51 |
-
event.preventDefault();
|
52 |
-
});
|
53 |
-
$("#next-user-input").click(function (event) {
|
54 |
-
console.log("next");
|
55 |
-
user_input_history_idx = Math.min(
|
56 |
-
user_input_history.length - 1,
|
57 |
-
user_input_history_idx + 1
|
58 |
-
);
|
59 |
-
user_input_history_value = user_input_history[user_input_history_idx];
|
60 |
-
$("#user-input").val(user_input_history_value);
|
61 |
-
set_user_input_history_buttons_state();
|
62 |
-
event.preventDefault();
|
63 |
-
});
|
64 |
-
}
|
65 |
-
|
66 |
-
function set_user_input_history_buttons_state() {
|
67 |
-
let prev_user_input = $("#prev-user-input");
|
68 |
-
let next_user_input = $("#next-user-input");
|
69 |
-
if (user_input_history.length === 0) {
|
70 |
-
prev_user_input.attr("disabled", true);
|
71 |
-
next_user_input.attr("disabled", true);
|
72 |
-
}
|
73 |
-
if (user_input_history_idx >= user_input_history.length - 1) {
|
74 |
-
next_user_input.attr("disabled", true);
|
75 |
-
} else {
|
76 |
-
next_user_input.attr("disabled", false);
|
77 |
-
}
|
78 |
-
|
79 |
-
if (user_input_history_idx <= 0) {
|
80 |
-
prev_user_input.attr("disabled", true);
|
81 |
-
} else {
|
82 |
-
prev_user_input.attr("disabled", false);
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
function adjust_messagers_container_max_height() {
|
87 |
var user_interaction_height = $("#user-interactions").outerHeight(true);
|
88 |
var page_height = $(window).height();
|
|
|
3 |
setup_temperature_on_select,
|
4 |
} from "./components/llm_models_loader.js";
|
5 |
import { bind_chat_buttons } from "./components/buttons_binder.js";
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
function auto_resize_user_input() {
|
8 |
// https://stackoverflow.com/questions/37629860/automatically-resizing-textarea-in-bootstrap
|
|
|
29 |
setup_temperature_on_select();
|
30 |
auto_resize_user_input();
|
31 |
bind_chat_buttons();
|
|
|
32 |
adjust_messagers_container_max_height();
|
33 |
$(window).on("resize", adjust_messagers_container_max_height);
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
function adjust_messagers_container_max_height() {
|
37 |
var user_interaction_height = $("#user-interactions").outerHeight(true);
|
38 |
var page_height = $(window).height();
|