mirror of
https://github.com/tcsenpai/spacellama.git
synced 2025-06-08 12:15:34 +00:00
auto model token limits
This commit is contained in:
parent
6a01bb6024
commit
08394baa54
@ -28,7 +28,7 @@ async function summarizeContent(content, systemPrompt) {
|
|||||||
const endpoint = `${
|
const endpoint = `${
|
||||||
settings.ollamaEndpoint || "http://localhost:11434"
|
settings.ollamaEndpoint || "http://localhost:11434"
|
||||||
}/api/generate`;
|
}/api/generate`;
|
||||||
const model = settings.ollamaModel || "llama2";
|
const model = settings.ollamaModel || "llama3.1:8b";
|
||||||
const tokenLimit = settings.tokenLimit || 4096;
|
const tokenLimit = settings.tokenLimit || 4096;
|
||||||
|
|
||||||
const maxContentTokens = tokenLimit - estimateTokenCount(systemPrompt) - 100; // Reserve 100 tokens for safety
|
const maxContentTokens = tokenLimit - estimateTokenCount(systemPrompt) - 100; // Reserve 100 tokens for safety
|
||||||
|
@ -1,38 +1,31 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "SpaceLLama",
|
"name": "SpaceLLama",
|
||||||
"version": "1.0",
|
"version": "1.1",
|
||||||
"description": "Summarize web pages using OLLAMA",
|
"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": [
|
"permissions": ["activeTab", "storage", "<all_urls>", "tabs"],
|
||||||
"activeTab",
|
"browser_action": {
|
||||||
"storage",
|
"default_title": "SpaceLLama",
|
||||||
"<all_urls>",
|
"default_icon": "icon.png"
|
||||||
"tabs"
|
},
|
||||||
],
|
"sidebar_action": {
|
||||||
"browser_action": {
|
"default_title": "SpaceLLama",
|
||||||
"default_title": "SpaceLLama",
|
"default_panel": "sidebar/sidebar.html",
|
||||||
"default_icon": "icon.png"
|
"default_icon": "icon.png"
|
||||||
},
|
},
|
||||||
"sidebar_action": {
|
"background": {
|
||||||
"default_title": "SpaceLLama",
|
"scripts": ["background.js"],
|
||||||
"default_panel": "sidebar/sidebar.html",
|
"persistent": false
|
||||||
"default_icon": "icon.png"
|
},
|
||||||
},
|
"content_scripts": [
|
||||||
"background": {
|
{
|
||||||
"scripts": ["background.js"],
|
"matches": ["<all_urls>"],
|
||||||
"persistent": false
|
"js": ["content_scripts/content.js"]
|
||||||
},
|
}
|
||||||
"content_scripts": [
|
],
|
||||||
{
|
"options_ui": {
|
||||||
"matches": ["<all_urls>"],
|
"page": "options/options.html",
|
||||||
"js": ["content_scripts/content.js"]
|
"open_in_tab": true
|
||||||
}
|
},
|
||||||
],
|
"web_accessible_resources": ["sidebar/marked.min.js", "model_tokens.json"]
|
||||||
"options_ui": {
|
}
|
||||||
"page": "options/options.html",
|
|
||||||
"open_in_tab": true
|
|
||||||
},
|
|
||||||
"web_accessible_resources": [
|
|
||||||
"sidebar/marked.min.js"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
26
model_tokens.json
Normal file
26
model_tokens.json
Normal file
@ -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
|
||||||
|
}
|
@ -58,7 +58,9 @@ async function restoreOptions() {
|
|||||||
document.getElementById("endpoint").value = endpoint;
|
document.getElementById("endpoint").value = endpoint;
|
||||||
document.getElementById("model").value = result.ollamaModel || "llama2";
|
document.getElementById("model").value = result.ollamaModel || "llama2";
|
||||||
document.getElementById("system-prompt").value = result.systemPrompt || defaultSystemPrompt;
|
document.getElementById("system-prompt").value = result.systemPrompt || defaultSystemPrompt;
|
||||||
document.getElementById("token-limit").value = result.tokenLimit || 4096;
|
|
||||||
|
await updateTokenLimit();
|
||||||
|
|
||||||
const isValid = await validateEndpoint(endpoint);
|
const isValid = await validateEndpoint(endpoint);
|
||||||
updateEndpointStatus(isValid);
|
updateEndpointStatus(isValid);
|
||||||
}
|
}
|
||||||
@ -72,3 +74,21 @@ document.getElementById("endpoint").addEventListener("blur", async (e) => {
|
|||||||
updateEndpointStatus(isValid);
|
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user