code formatted for clarity
This commit is contained in:
parent
944138a0c2
commit
7f9ee613ab
1 changed files with 69 additions and 10 deletions
|
|
@ -60,28 +60,87 @@
|
||||||
async initWorker() {
|
async initWorker() {
|
||||||
switch (this.llm) {
|
switch (this.llm) {
|
||||||
case "chatgpt_api": {
|
case "chatgpt_api": {
|
||||||
let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: '', chatgpt_developer_messages: ''});
|
let prefs_api = await browser.storage.sync.get({
|
||||||
this.worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model, chatgpt_developer_messages: prefs_api.chatgpt_developer_messages, do_debug: this.do_debug, i18nStrings: ''});
|
chatgpt_api_key: '',
|
||||||
|
chatgpt_model: '',
|
||||||
|
chatgpt_developer_messages: ''
|
||||||
|
});
|
||||||
|
this.worker.postMessage({
|
||||||
|
type: 'init',
|
||||||
|
chatgpt_api_key: prefs_api.chatgpt_api_key,
|
||||||
|
chatgpt_model: prefs_api.chatgpt_model,
|
||||||
|
chatgpt_developer_messages: prefs_api.chatgpt_developer_messages,
|
||||||
|
do_debug: this.do_debug,
|
||||||
|
i18nStrings: ''
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "google_gemini_api": {
|
case "google_gemini_api": {
|
||||||
let prefs_api = await browser.storage.sync.get({google_gemini_api_key: '', google_gemini_model: '', google_gemini_system_instruction: ''});
|
let prefs_api = await browser.storage.sync.get({
|
||||||
this.worker.postMessage({ type: 'init', google_gemini_api_key: prefs_api.google_gemini_api_key, google_gemini_model: prefs_api.google_gemini_model, google_gemini_system_instruction: prefs_api.google_gemini_system_instruction, do_debug: this.do_debug, i18nStrings: ''});
|
google_gemini_api_key: '',
|
||||||
|
google_gemini_model: '',
|
||||||
|
google_gemini_system_instruction: ''
|
||||||
|
});
|
||||||
|
this.worker.postMessage({
|
||||||
|
type: 'init',
|
||||||
|
google_gemini_api_key: prefs_api.google_gemini_api_key,
|
||||||
|
google_gemini_model: prefs_api.google_gemini_model,
|
||||||
|
google_gemini_system_instruction: prefs_api.google_gemini_system_instruction,
|
||||||
|
do_debug: this.do_debug,
|
||||||
|
i18nStrings: ''
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "ollama_api": {
|
case "ollama_api": {
|
||||||
let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: ''});
|
let prefs_api = await browser.storage.sync.get({
|
||||||
this.worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, do_debug: this.do_debug, i18nStrings: ''});
|
ollama_host: '',
|
||||||
|
ollama_model: '',
|
||||||
|
});
|
||||||
|
this.worker.postMessage({
|
||||||
|
type: 'init',
|
||||||
|
ollama_host: prefs_api.ollama_host,
|
||||||
|
ollama_model: prefs_api.ollama_model,
|
||||||
|
do_debug: this.do_debug,
|
||||||
|
i18nStrings: ''
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "openai_comp_api": {
|
case "openai_comp_api": {
|
||||||
let prefs_api = await browser.storage.sync.get({openai_comp_host: '', openai_comp_model: '', openai_comp_api_key: '', openai_comp_use_v1: true, openai_comp_chat_name: '', do_debug: false});
|
let prefs_api = await browser.storage.sync.get({
|
||||||
this.worker.postMessage({ type: 'init', openai_comp_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, openai_comp_api_key: prefs_api.openai_comp_api_key, openai_comp_use_v1: prefs_api.openai_comp_use_v1, do_debug: this.do_debug, i18nStrings: ''});
|
openai_comp_host: '',
|
||||||
|
openai_comp_model: '',
|
||||||
|
openai_comp_api_key: '',
|
||||||
|
openai_comp_use_v1: true,
|
||||||
|
openai_comp_chat_name: '',
|
||||||
|
do_debug: false,
|
||||||
|
});
|
||||||
|
this.worker.postMessage({
|
||||||
|
type: 'init',
|
||||||
|
openai_comp_host: prefs_api.openai_comp_host,
|
||||||
|
openai_comp_model: prefs_api.openai_comp_model,
|
||||||
|
openai_comp_api_key: prefs_api.openai_comp_api_key,
|
||||||
|
openai_comp_use_v1: prefs_api.openai_comp_use_v1,
|
||||||
|
do_debug: this.do_debug,
|
||||||
|
i18nStrings: ''
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "anthropic_api": {
|
case "anthropic_api": {
|
||||||
let prefs_api = await browser.storage.sync.get({anthropic_api_key: '', anthropic_model: '', anthropic_version: '2023-06-01', anthropic_max_tokens: 4096});
|
let prefs_api = await browser.storage.sync.get({
|
||||||
this.worker.postMessage({ type: 'init', anthropic_api_key: prefs_api.anthropic_api_key, anthropic_model: prefs_api.anthropic_model, anthropic_version: prefs_api.anthropic_version, anthropic_max_tokens: prefs_api.anthropic_max_tokens, do_debug: this.do_debug, i18nStrings: ''});
|
anthropic_api_key: '',
|
||||||
|
anthropic_model: '',
|
||||||
|
anthropic_version: '2023-06-01',
|
||||||
|
anthropic_max_tokens: 4096,
|
||||||
|
});
|
||||||
|
this.worker.postMessage({
|
||||||
|
type: 'init',
|
||||||
|
anthropic_api_key: prefs_api.anthropic_api_key,
|
||||||
|
anthropic_model: prefs_api.anthropic_model,
|
||||||
|
anthropic_version: prefs_api.anthropic_version,
|
||||||
|
anthropic_max_tokens: prefs_api.anthropic_max_tokens,
|
||||||
|
do_debug: this.do_debug,
|
||||||
|
i18nStrings: ''
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue