ollama options added. see #79

This commit is contained in:
mic 2024-08-20 15:16:48 +02:00
parent 19342cbced
commit 4f7a018f67
8 changed files with 69 additions and 7 deletions

View file

@ -411,7 +411,7 @@
"message": "Fehler beim Abrufen der ChatGPT-Modelle", "message": "Fehler beim Abrufen der ChatGPT-Modelle",
"description": "" "description": ""
}, },
"ChatGPT_Models_Loading": { "Loading": {
"message": "Laden...", "message": "Laden...",
"description": "" "description": ""
}, },

View file

@ -411,7 +411,7 @@
"message": "Error trying to fetch ChatGPT models", "message": "Error trying to fetch ChatGPT models",
"description": "" "description": ""
}, },
"ChatGPT_Models_Loading": { "Loading": {
"message": "Loading...", "message": "Loading...",
"description": "" "description": ""
}, },
@ -442,5 +442,25 @@
"prefs_OptionText_do_debug_info": { "prefs_OptionText_do_debug_info": {
"message": "Activate the debug system", "message": "Activate the debug system",
"description": "" "description": ""
},
"prefs_Connection_type_Ollama_API": {
"message": "Ollama API (Local LLM)",
"description": ""
},
"prefs_Ollama_Host": {
"message": "Host Address",
"description": ""
},
"Ollama_Models": {
"message": "Ollama Models",
"description": ""
},
"Ollama_Models_Fetch": {
"message": "Update Ollama Models list",
"description": ""
},
"Ollama_Models_Error_fetching": {
"message": "Error trying to fetch Ollama models",
"description": ""
} }
} }

View file

@ -411,7 +411,7 @@
"message": "Erreur lors de la récupération des modèles ChatGPT", "message": "Erreur lors de la récupération des modèles ChatGPT",
"description": "" "description": ""
}, },
"ChatGPT_Models_Loading": { "Loading": {
"message": "Chargement...", "message": "Chargement...",
"description": "" "description": ""
}, },

View file

@ -411,7 +411,7 @@
"message": "Errore durante il recupero dei modelli di ChatGPT", "message": "Errore durante il recupero dei modelli di ChatGPT",
"description": "" "description": ""
}, },
"ChatGPT_Models_Loading": { "Loading": {
"message": "Caricamento in corso...", "message": "Caricamento in corso...",
"description": "" "description": ""
}, },

View file

@ -22,7 +22,9 @@ export const prefs_default = {
chatgpt_win_width: 700, chatgpt_win_width: 700,
chatpgt_use_gpt4: false, chatpgt_use_gpt4: false,
default_chatgpt_lang: '', default_chatgpt_lang: '',
connection_type: 'chatgpt_web', //Other values: 'chatgpt_api' connection_type: 'chatgpt_web', //Other values: 'chatgpt_api', 'ollama_api'
chatgpt_api_key: '', chatgpt_api_key: '',
chatgpt_model: '', chatgpt_model: '',
ollama_host: '',
ollama_model: '',
} }

View file

@ -126,6 +126,10 @@ tr.conntype_chatgpt_web, tr.conntype_chatgpt_web2{
background-color: rgb(39, 11, 0); background-color: rgb(39, 11, 0);
} }
tr.conntype_ollama_api, tr.conntype_ollama_api2{
background-color: rgb(7, 58, 0);
}
/* color to be used for a local LLM /* color to be used for a local LLM
.conntype_chatgpt_web,.conntype_local_llm{ .conntype_chatgpt_web,.conntype_local_llm{
background-color: rgb(0, 39, 0); background-color: rgb(0, 39, 0);

View file

@ -70,6 +70,7 @@
<select id="connection_type" name="connection_type" class="option-input"> <select id="connection_type" name="connection_type" class="option-input">
<option value="chatgpt_web">__MSG_prefs_Connection_type_ChatGTP_Web__</option> <option value="chatgpt_web">__MSG_prefs_Connection_type_ChatGTP_Web__</option>
<option value="chatgpt_api">__MSG_prefs_Connection_type_ChatGTP_API__</option> <option value="chatgpt_api">__MSG_prefs_Connection_type_ChatGTP_API__</option>
<option value="ollama_api">__MSG_prefs_Connection_type_Ollama_API__</option>
</select> </select>
</label> </label>
</td> </td>
@ -104,13 +105,38 @@
</label> </label>
</td> </td>
<td> <td>
<button id="btnUpdateChatGPTModels">__MSG_ChatGPT_Models_Fetch__</button> <span id="model_fetch_loading">__MSG_ChatGPT_Models_Loading__</span><br> <button id="btnUpdateChatGPTModels">__MSG_ChatGPT_Models_Fetch__</button> <span id="model_fetch_loading">__MSG_Loading__</span><br>
<label> <label>
<select id="chatgpt_model" name="chatgpt_model" class="option-input"> <select id="chatgpt_model" name="chatgpt_model" class="option-input">
</select> </select>
</label> </label>
</td> </td>
</tr> </tr>
<tr class="conntype_ollama_api">
<td><label>
<span>__MSG_prefs_Ollama_Host__</span>
</label></td>
<td>
<label>
<input type="text" id="ollama_host" name="ollama_host" class="option-input" style="width:28em" />
&nbsp;<span></span>
</label>
</td>
</tr>
<tr class="conntype_ollama_api">
<td>
<label>
<span>__MSG_Ollama_Models__</span>
</label>
</td>
<td>
<button id="btnUpdateChatGPTModels">__MSG_Ollama_Models_Fetch__</button> <span id="model_fetch_loading">__MSG_Loading__</span><br>
<label>
<select id="ollama_model" name="ollama_model" class="option-input">
</select>
</label>
</td>
</tr>
<tr> <tr>
<td><label> <td><label>
<span>__MSG_Debug__</span> <span>__MSG_Debug__</span>

View file

@ -91,10 +91,12 @@ async function restoreOptions() {
function showConnectionOptions() { function showConnectionOptions() {
let chatgpt_web_display = 'table-row'; let chatgpt_web_display = 'table-row';
let chatgpt_api_display = 'none'; let chatgpt_api_display = 'none';
let ollama_api_display = 'none';
let conntype_select = document.getElementById("connection_type"); let conntype_select = document.getElementById("connection_type");
let parent = conntype_select.parentElement.parentElement.parentElement; let parent = conntype_select.parentElement.parentElement.parentElement;
parent.classList.toggle("conntype_chatgpt_web", (conntype_select.value === "chatgpt_web"));
parent.classList.toggle("conntype_chatgpt_api", (conntype_select.value === "chatgpt_api")); parent.classList.toggle("conntype_chatgpt_api", (conntype_select.value === "chatgpt_api"));
parent.classList.toggle("conntype_chatgpt_web", (conntype_select.value === "chatgpt_web")); parent.classList.toggle("conntype_ollama_api", (conntype_select.value === "ollama_api"));
if (conntype_select.value === "chatgpt_web") { if (conntype_select.value === "chatgpt_web") {
chatgpt_web_display = 'table-row'; chatgpt_web_display = 'table-row';
}else{ }else{
@ -105,12 +107,20 @@ function showConnectionOptions() {
}else{ }else{
chatgpt_api_display = 'none'; chatgpt_api_display = 'none';
} }
if (conntype_select.value === "ollama_api") {
ollama_api_display = 'table-row';
}else{
ollama_api_display = 'none';
}
document.querySelectorAll(".conntype_chatgpt_web").forEach(element => { document.querySelectorAll(".conntype_chatgpt_web").forEach(element => {
element.style.display = chatgpt_web_display; element.style.display = chatgpt_web_display;
}); });
document.querySelectorAll(".conntype_chatgpt_api").forEach(element => { document.querySelectorAll(".conntype_chatgpt_api").forEach(element => {
element.style.display = chatgpt_api_display; element.style.display = chatgpt_api_display;
}); });
document.querySelectorAll(".conntype_ollama_api").forEach(element => {
element.style.display = ollama_api_display;
});
} }
function warnAPIKeyEmpty() { function warnAPIKeyEmpty() {