diff --git a/background.js b/background.js index 5477edb..348f7df 100644 --- a/background.js +++ b/background.js @@ -28,7 +28,7 @@ async function summarizeContent(content, systemPrompt) { const endpoint = `${ settings.ollamaEndpoint || "http://localhost:11434" }/api/generate`; - const model = settings.ollamaModel || "llama2"; + const model = settings.ollamaModel || "llama3.1:8b"; const tokenLimit = settings.tokenLimit || 4096; const maxContentTokens = tokenLimit - estimateTokenCount(systemPrompt) - 100; // Reserve 100 tokens for safety diff --git a/manifest.json b/manifest.json index 7cb7117..fd7ac3a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,38 +1,31 @@ { - "manifest_version": 2, - "name": "SpaceLLama", - "version": "1.0", - "description": "Summarize web pages using OLLAMA", - "permissions": [ - "activeTab", - "storage", - "", - "tabs" - ], - "browser_action": { - "default_title": "SpaceLLama", - "default_icon": "icon.png" - }, - "sidebar_action": { - "default_title": "SpaceLLama", - "default_panel": "sidebar/sidebar.html", - "default_icon": "icon.png" - }, - "background": { - "scripts": ["background.js"], - "persistent": false - }, - "content_scripts": [ - { - "matches": [""], - "js": ["content_scripts/content.js"] - } - ], - "options_ui": { - "page": "options/options.html", - "open_in_tab": true - }, - "web_accessible_resources": [ - "sidebar/marked.min.js" - ] - } \ No newline at end of file + "manifest_version": 2, + "name": "SpaceLLama", + "version": "1.1", + "description": "Summarize web pages using Ollama. Supports custom models, token limits, system prompts, chunking, and more. See https://github.com/tcsenpai/spacellama for more information.", + "permissions": ["activeTab", "storage", "", "tabs"], + "browser_action": { + "default_title": "SpaceLLama", + "default_icon": "icon.png" + }, + "sidebar_action": { + "default_title": "SpaceLLama", + "default_panel": "sidebar/sidebar.html", + "default_icon": "icon.png" + }, + "background": { + "scripts": ["background.js"], + "persistent": false + }, + "content_scripts": [ + { + "matches": [""], + "js": ["content_scripts/content.js"] + } + ], + "options_ui": { + "page": "options/options.html", + "open_in_tab": true + }, + "web_accessible_resources": ["sidebar/marked.min.js", "model_tokens.json"] +} diff --git a/model_tokens.json b/model_tokens.json new file mode 100644 index 0000000..fe1a3a4 --- /dev/null +++ b/model_tokens.json @@ -0,0 +1,26 @@ +{ + "llama2": 4096, + "llama2:13b": 4096, + "llama2:70b": 4096, + "codellama": 16384, + "codellama:13b": 16384, + "codellama:34b": 16384, + "mistral": 8192, + "mixtral": 32768, + "phi": 2048, + "qwen": 8192, + "qwen:14b": 8192, + "qwen:72b": 8192, + "stablelm": 4096, + "stablelm-zephyr": 4096, + "neural-chat": 8192, + "openhermes": 8192, + "starling-lm": 8192, + "orca2": 4096, + "vicuna": 8192, + "wizardcoder": 16384, + "wizardcoder:python": 16384, + "wizardmath": 8192, + "llama3.1:8b": 128000, + "llama3.1:70b": 128000 + } diff --git a/options/options.js b/options/options.js index b37f286..147edf6 100644 --- a/options/options.js +++ b/options/options.js @@ -58,7 +58,9 @@ async function restoreOptions() { document.getElementById("endpoint").value = endpoint; document.getElementById("model").value = result.ollamaModel || "llama2"; document.getElementById("system-prompt").value = result.systemPrompt || defaultSystemPrompt; - document.getElementById("token-limit").value = result.tokenLimit || 4096; + + await updateTokenLimit(); + const isValid = await validateEndpoint(endpoint); updateEndpointStatus(isValid); } @@ -72,3 +74,21 @@ document.getElementById("endpoint").addEventListener("blur", async (e) => { updateEndpointStatus(isValid); }); +async function loadModelTokens() { + const response = await fetch(browser.runtime.getURL('model_tokens.json')); + return await response.json(); +} + +async function updateTokenLimit() { + const modelTokens = await loadModelTokens(); + const model = document.getElementById("model").value; + const tokenLimitInput = document.getElementById("token-limit"); + + if (model in modelTokens) { + tokenLimitInput.value = modelTokens[model]; + } else { + tokenLimitInput.value = 4096; // Default value + } +} + +document.getElementById("model").addEventListener("change", updateTokenLimit);