Hansimov commited on
Commit
bc9cd50
1 Parent(s): eb28af4

:gem: [Feature] Set and store endpoint and api key in localStorage

Browse files
apps/llm_mixer/index.html CHANGED
@@ -64,7 +64,7 @@
64
  id="user-input"
65
  class="form-control"
66
  rows="1"
67
- placeholder="Typing here ..."
68
  ></textarea>
69
  </div>
70
  <div class="col-auto pr-3 pl-0">
@@ -82,22 +82,32 @@
82
  <span class="fa fa-arrow-right"></span>
83
  </button>
84
  </div>
85
- <form class="col px-1">
86
  <input
87
  id="openai-endpoint"
88
  class="form-control"
89
  rows="1"
90
- placeholder="Endpoint ..."
91
  ></input>
92
- </form>
93
- <form class="col px-1">
 
 
 
 
 
94
  <input
95
  id="openai-api-key"
96
  class="form-control"
97
  rows="1"
98
- placeholder="API Key ..."
99
  ></input>
100
- </form>
 
 
 
 
 
101
  </div>
102
  </div>
103
  </div>
 
64
  id="user-input"
65
  class="form-control"
66
  rows="1"
67
+ placeholder="Typing your prompt here ..."
68
  ></textarea>
69
  </div>
70
  <div class="col-auto pr-3 pl-0">
 
82
  <span class="fa fa-arrow-right"></span>
83
  </button>
84
  </div>
85
+ <div class="col px-0">
86
  <input
87
  id="openai-endpoint"
88
  class="form-control"
89
  rows="1"
90
+ placeholder="Endpoint"
91
  ></input>
92
+ </div>
93
+ <div class="col-auto px-0">
94
+ <button id="openai-endpoint-button" class="btn">
95
+ <i class="fa fa-check"></i>
96
+ </button>
97
+ </div>
98
+ <div class="col px-0">
99
  <input
100
  id="openai-api-key"
101
  class="form-control"
102
  rows="1"
103
+ placeholder="API Key"
104
  ></input>
105
+ </div>
106
+ <div class="col-auto px-0">
107
+ <button id="openai-api-key-button" class="btn">
108
+ <i class="fa fa-check"></i>
109
+ </button>
110
+ </div>
111
  </div>
112
  </div>
113
  </div>
apps/llm_mixer/js/buttons_binder.js CHANGED
@@ -8,10 +8,14 @@ import {
8
  } from "./chat_operator.js";
9
 
10
  export function bind_chat_buttons() {
11
- let send_binder = new SendUserInputButtonBinder();
12
- send_binder.bind();
13
- let new_binder = new NewChatButtonBinder();
14
- new_binder.bind();
 
 
 
 
15
  }
16
 
17
  class SendUserInputButtonBinder {
@@ -94,3 +98,40 @@ class NewChatButtonBinder {
94
  });
95
  }
96
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  } from "./chat_operator.js";
9
 
10
  export function bind_chat_buttons() {
11
+ let send_user_input_binder = new SendUserInputButtonBinder();
12
+ send_user_input_binder.bind();
13
+ let new_chat_binder = new NewChatButtonBinder();
14
+ new_chat_binder.bind();
15
+ let openai_endpoint_binder = new OpenaiEndpointButtonBinder();
16
+ openai_endpoint_binder.bind();
17
+ let openai_api_key_binder = new OpenaiAPIKeyButtonBinder();
18
+ openai_api_key_binder.bind();
19
  }
20
 
21
  class SendUserInputButtonBinder {
 
98
  });
99
  }
100
  }
101
+
102
+ class OpenaiEndpointButtonBinder {
103
+ constructor() {}
104
+ bind() {
105
+ const button = $("#openai-endpoint-button");
106
+ button.attr("title", "Submit OpenAI Endpoint");
107
+ const stored_openai_endpoint = localStorage.getItem("openai_endpoint");
108
+ if (stored_openai_endpoint) {
109
+ $("#openai-endpoint").val(stored_openai_endpoint);
110
+ console.log(`GET OpenAI Endpoint: ${stored_openai_endpoint}`);
111
+ }
112
+ button.click(() => {
113
+ console.log($("#openai-endpoint").val());
114
+ localStorage.setItem(
115
+ "openai_endpoint",
116
+ $("#openai-endpoint").val()
117
+ );
118
+ });
119
+ }
120
+ }
121
+
122
+ class OpenaiAPIKeyButtonBinder {
123
+ constructor() {}
124
+ bind() {
125
+ const button = $("#openai-api-key-button");
126
+ button.attr("title", "Submit OpenAI API Key");
127
+ const stored_openai_api_key = localStorage.getItem("openai_api_key");
128
+ if (stored_openai_api_key) {
129
+ $("#openai-api-key").val(stored_openai_api_key);
130
+ console.log(`GET OpenAI API Key: ${stored_openai_api_key}`);
131
+ }
132
+ button.click(() => {
133
+ console.log($("#openai-api-key").val());
134
+ localStorage.setItem("openai_api_key", $("#openai-api-key").val());
135
+ });
136
+ }
137
+ }
apps/llm_mixer/js/llm_requester.js CHANGED
@@ -2,7 +2,6 @@ import {
2
  jsonize_stream_data,
3
  stringify_stream_bytes,
4
  } from "./stream_jsonizer.js";
5
- // import * as secrets from "./secrets.js";
6
  import {
7
  update_message,
8
  create_messager,
 
2
  jsonize_stream_data,
3
  stringify_stream_bytes,
4
  } from "./stream_jsonizer.js";
 
5
  import {
6
  update_message,
7
  create_messager,
apps/llm_mixer/js/main.js CHANGED
@@ -24,7 +24,6 @@ function auto_resize_user_input() {
24
  }
25
 
26
  function setup_interactive_components() {
27
- setup_endpoint_and_key();
28
  setup_available_models_on_select();
29
  setup_temperature_on_select();
30
  bind_chat_buttons();
 
24
  }
25
 
26
  function setup_interactive_components() {
 
27
  setup_available_models_on_select();
28
  setup_temperature_on_select();
29
  bind_chat_buttons();