mirror of
https://github.com/tcsenpai/spacellama.git
synced 2025-06-07 03:35:31 +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 = `${
|
||||
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
|
||||
|
@ -1,38 +1,31 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "SpaceLLama",
|
||||
"version": "1.0",
|
||||
"description": "Summarize web pages using OLLAMA",
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"storage",
|
||||
"<all_urls>",
|
||||
"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": ["<all_urls>"],
|
||||
"js": ["content_scripts/content.js"]
|
||||
}
|
||||
],
|
||||
"options_ui": {
|
||||
"page": "options/options.html",
|
||||
"open_in_tab": true
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
"sidebar/marked.min.js"
|
||||
]
|
||||
}
|
||||
"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", "<all_urls>", "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": ["<all_urls>"],
|
||||
"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"]
|
||||
}
|
||||
|
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("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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user