Update Anthropic model fetching logic and improve option handling. see #249
This commit is contained in:
parent
85dfb36291
commit
f866dab4c8
1 changed files with 5 additions and 2 deletions
|
|
@ -710,7 +710,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
|
||||||
document.getElementById('btnUpdateAnthropicModels').addEventListener('click', async () => {
|
document.getElementById('btnUpdateAnthropicModels').addEventListener('click', async () => {
|
||||||
document.getElementById('anthropic_model_fetch_loading').style.display = 'inline';
|
document.getElementById('anthropic_model_fetch_loading').style.display = 'inline';
|
||||||
let anthropic = new Anthropic(document.getElementById("anthropic_api_key").value, document.getElementById("anthropic_version").value, '', true);
|
let anthropic = new Anthropic(document.getElementById("anthropic_api_key").value, document.getElementById("anthropic_version").value, '');
|
||||||
anthropic.fetchModels().then((data) => {
|
anthropic.fetchModels().then((data) => {
|
||||||
if(!data.ok){
|
if(!data.ok){
|
||||||
let errorDetail;
|
let errorDetail;
|
||||||
|
|
@ -727,7 +727,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
}
|
}
|
||||||
taLog.log("Anthropic models: " + JSON.stringify(data));
|
taLog.log("Anthropic models: " + JSON.stringify(data));
|
||||||
data.response.forEach(model => {
|
data.response.forEach(model => {
|
||||||
if (!Array.from(select_anthropic_model.options).some(option => option.value === model.id)) {
|
const existingOption = Array.from(select_anthropic_model.options).find(option => option.value === model.id);
|
||||||
|
if (existingOption) {
|
||||||
|
existingOption.text = model.display_name + " (" + model.id + ")";
|
||||||
|
} else {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.value = model.id;
|
option.value = model.id;
|
||||||
option.text = model.display_name + " (" + model.id + ")";
|
option.text = model.display_name + " (" + model.id + ")";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue