|
import { request_available_models, available_models } from "./llm_requester.js"; |
|
|
|
export async function setup_available_models_on_select(default_option = null) { |
|
var select = $("#available-models-select"); |
|
select.empty(); |
|
await request_available_models(); |
|
const working_models = [ |
|
"bing-precise", |
|
"bing-balanced", |
|
"bing-creative", |
|
|
|
|
|
|
|
|
|
|
|
|
|
"claude-2", |
|
"gpt-3.5-turbo", |
|
"gpt-3.5-turbo-internet", |
|
|
|
|
|
|
|
|
|
|
|
"poe-claude-instant", |
|
"poe-claude-instant-100k", |
|
|
|
|
|
|
|
|
|
"poe-google-palm", |
|
"poe-gpt-3.5-turbo", |
|
|
|
"poe-gpt-3.5-turbo-instruct", |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"poe-saga", |
|
"poe-solar-0-70b", |
|
|
|
|
|
"poe-web-search", |
|
]; |
|
working_models.forEach((value, index) => { |
|
const option = new Option(value, value); |
|
if (available_models.includes(value)) { |
|
select.append(option); |
|
} |
|
}); |
|
let default_model = "gpt-turbo-3.5"; |
|
let local_default_model = localStorage.getItem("default_model"); |
|
if ( |
|
local_default_model && |
|
working_models.includes(local_default_model) && |
|
available_models.includes(local_default_model) |
|
) { |
|
default_model = local_default_model; |
|
} |
|
select.val(default_model); |
|
console.log(`Default model: ${select.val()}`); |
|
} |
|
|
|
export async function setup_temperature_on_select(default_option = null) { |
|
var select = $("#temperature-select"); |
|
select.empty(); |
|
if (default_option === null) { |
|
default_option = "0"; |
|
} |
|
for (let i = 10; i >= 0; i--) { |
|
const value = i / 10; |
|
const option = new Option(value, value); |
|
select.append(option); |
|
if (value === Number(default_option)) { |
|
$(option).prop("selected", true); |
|
} |
|
} |
|
console.log(`Default temperature: ${select.val()}`); |
|
} |
|
|
|
export function setup_endpoint_and_key() { |
|
if (localStorage.getItem("openai_endpoint")) { |
|
$("#openai-endpoint").val(localStorage.getItem("openai_endpoint")); |
|
console.log("GET: OpenAI Endpoint!"); |
|
} else { |
|
console.log("NULL: OpenAI Endpoint!"); |
|
$("#openai-endpoint").on("submit", function (event) { |
|
event.preventDefault(); |
|
localStorage.setItem( |
|
"openai_endpoint", |
|
$("#openai-endpoint").val() |
|
); |
|
console.log("SET: OpenAI Endpoint!"); |
|
}); |
|
} |
|
|
|
if (localStorage.getItem("openai_api_key")) { |
|
$("#openai-api-key").val(localStorage.getItem("openai_api_key")); |
|
console.log("GET: OpenAI API Key!"); |
|
} else { |
|
console.log("NULL: OpenAI API Key!"); |
|
$("#openai-api-key").on("submit", function (event) { |
|
event.preventDefault(); |
|
localStorage.setItem("openai_api_key", $("#openai-api-key").val()); |
|
console.log("SET: OpenAI API Key!"); |
|
}); |
|
} |
|
} |
|
|