Added LLM providers pref, anthropic, openai, local (#10185)

This commit is contained in:
GabrieleDeri 2026-03-19 17:19:15 +01:00 committed by GitHub
parent 9015774e2b
commit deb4f113e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 162 additions and 20 deletions

View file

@ -338,6 +338,88 @@ if auth.has_capability(auth.capabilities.preferences) then
</form> ]]
end
-- ================================================================================
function printLLMProviders()
create_table()
-- Anthropic
add_section(i18n("prefs.llm_anthropic"))
local default_anthropic_url = "https://api.anthropic.com/v1/"
local default_anthropic_model = "claude-opus-4-5"
local default_openai_url = "https://api.openai.com/v1/"
local default_openai_model = "gpt-4o"
local default_local_llm_url = "http://localhost:11434/v1/"
local default_local_llm_model = "Qwen3.5-9B"
-- Local LLM
add_section(i18n("prefs.llm_local"))
prefsInputFieldPrefs(subpage_active.entries["local_llm_url"].title,
subpage_active.entries["local_llm_url"].description,
"ntopng.prefs.llm", "local_llm_url", default_local_llm_url, "text", true, true, true, {
attributes = { spellcheck = "false", maxlength = 255 }
})
prefsInputFieldPrefs(subpage_active.entries["local_llm_token"].title,
subpage_active.entries["local_llm_token"].description,
"ntopng.prefs.llm", "local_llm_token", "", "password", true, true, false, {
attributes = { spellcheck = "false", maxlength = 255 }
})
prefsInputFieldPrefs(subpage_active.entries["local_llm_model"].title,
subpage_active.entries["local_llm_model"].description,
"ntopng.prefs.llm", "local_llm_model", default_local_llm_model, "text", true, false, false, {
attributes = { spellcheck = "false", maxlength = 128 }
})
-- Anthropic
prefsInputFieldPrefs(subpage_active.entries["anthropic_url"].title,
subpage_active.entries["anthropic_url"].description,
"ntopng.prefs.llm", "anthropic_url", default_anthropic_url, "text", true, true, true, {
attributes = { spellcheck = "false", maxlength = 255 }
})
prefsInputFieldPrefs(subpage_active.entries["anthropic_token"].title,
subpage_active.entries["anthropic_token"].description,
"ntopng.prefs.llm", "anthropic_token", "", "password", true, true, false, {
attributes = { spellcheck = "false", maxlength = 255 }
})
prefsInputFieldPrefs(subpage_active.entries["anthropic_model"].title,
subpage_active.entries["anthropic_model"].description,
"ntopng.prefs.llm", "anthropic_model", default_anthropic_model, "text", true, false, false, {
attributes = { spellcheck = "false", maxlength = 128 }
})
-- OpenAI
add_section(i18n("prefs.llm_openai"))
prefsInputFieldPrefs(subpage_active.entries["openai_url"].title,
subpage_active.entries["openai_url"].description,
"ntopng.prefs.llm", "openai_url", default_openai_url, "text", true, true, true, {
attributes = { spellcheck = "false", maxlength = 255 }
})
prefsInputFieldPrefs(subpage_active.entries["openai_token"].title,
subpage_active.entries["openai_token"].description,
"ntopng.prefs.llm", "openai_token", "", "password", true, true, false, {
attributes = { spellcheck = "false", maxlength = 255 }
})
prefsInputFieldPrefs(subpage_active.entries["openai_model"].title,
subpage_active.entries["openai_model"].description,
"ntopng.prefs.llm", "openai_model", default_openai_model, "text", true, false, false, {
attributes = { spellcheck = "false", maxlength = 128 }
})
end_table()
end
-- ================================================================================
function printActiveMonitoring()
print('<form method="post">')
@ -2815,6 +2897,10 @@ if auth.has_capability(auth.capabilities.preferences) then
printASNModeOptions()
end
if (tab == "llm_providers") then
printLLMProviders()
end
if (tab == "dump_settings") then
printDumpSettings()
end