:boom: [Fix] Switch cors proxy via different source
Browse files
apps/llm_mixer/js/llm_requester.js
CHANGED
@@ -10,6 +10,15 @@ import {
|
|
10 |
get_selected_temperature,
|
11 |
} from "./chat_operator.js";
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
export class ChatCompletionsRequester {
|
14 |
constructor(
|
15 |
prompt,
|
@@ -23,13 +32,18 @@ export class ChatCompletionsRequester {
|
|
23 |
this.temperature =
|
24 |
temperature !== null ? temperature : get_selected_temperature();
|
25 |
this.endpoint = endpoint || localStorage.getItem("openai_endpoint");
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
29 |
} else {
|
30 |
this.cors_proxy = "https://cors-anywhere.herokuapp.com/";
|
31 |
}
|
32 |
-
this.request_endpoint =
|
|
|
|
|
|
|
|
|
33 |
this.controller = new AbortController();
|
34 |
}
|
35 |
construct_request_messages() {
|
|
|
10 |
get_selected_temperature,
|
11 |
} from "./chat_operator.js";
|
12 |
|
13 |
+
function concat_urls(...urls) {
|
14 |
+
let new_url = urls
|
15 |
+
.map((url) => url.replace(/^\/|\/$/g, ""))
|
16 |
+
.filter((url) => url !== "")
|
17 |
+
.join("/");
|
18 |
+
console.log(new_url);
|
19 |
+
return new_url;
|
20 |
+
}
|
21 |
+
|
22 |
export class ChatCompletionsRequester {
|
23 |
constructor(
|
24 |
prompt,
|
|
|
32 |
this.temperature =
|
33 |
temperature !== null ? temperature : get_selected_temperature();
|
34 |
this.endpoint = endpoint || localStorage.getItem("openai_endpoint");
|
35 |
+
if (cors_proxy !== null) {
|
36 |
+
this.cors_proxy = cors_proxy;
|
37 |
+
} else if (window.location.protocol === "https:") {
|
38 |
+
this.cors_proxy = "https://hansimov-cors-anywhere.onrender.com/";
|
39 |
} else {
|
40 |
this.cors_proxy = "https://cors-anywhere.herokuapp.com/";
|
41 |
}
|
42 |
+
this.request_endpoint = concat_urls(
|
43 |
+
this.cors_proxy,
|
44 |
+
this.endpoint,
|
45 |
+
"/chat/completions"
|
46 |
+
);
|
47 |
this.controller = new AbortController();
|
48 |
}
|
49 |
construct_request_messages() {
|