workers updated to use the new dynamic settings
This commit is contained in:
parent
5893ee668c
commit
f47b12946a
5 changed files with 45 additions and 41 deletions
|
|
@ -35,15 +35,15 @@ let assistantResponseAccumulator = '';
|
||||||
self.onmessage = async function(event) {
|
self.onmessage = async function(event) {
|
||||||
if (event.data.type === 'init') {
|
if (event.data.type === 'init') {
|
||||||
// console.log(">>>>>>>>>>>>>> event.data: " + JSON.stringify(event.data));
|
// console.log(">>>>>>>>>>>>>> event.data: " + JSON.stringify(event.data));
|
||||||
anthropic = new Anthropic({
|
let config = { stream: true };
|
||||||
apiKey: event.data.anthropic_api_key,
|
for (const key in event.data) {
|
||||||
version: event.data.anthropic_version,
|
if (key.startsWith('anthropic_')) {
|
||||||
model: event.data.anthropic_model,
|
let newKey = key.replace('anthropic_', '');
|
||||||
system_prompt: event.data.anthropic_system_prompt,
|
if (newKey === 'api_key') newKey = 'apiKey';
|
||||||
temperature: event.data.anthropic_temperature,
|
config[newKey] = event.data[key];
|
||||||
max_tokens: event.data.anthropic_max_tokens,
|
}
|
||||||
stream: true
|
}
|
||||||
});
|
anthropic = new Anthropic(config);
|
||||||
do_debug = event.data.do_debug;
|
do_debug = event.data.do_debug;
|
||||||
i18nStrings = event.data.i18nStrings;
|
i18nStrings = event.data.i18nStrings;
|
||||||
taLog = new taLogger('model-worker-anthropic', do_debug);
|
taLog = new taLogger('model-worker-anthropic', do_debug);
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,15 @@ let assistantResponseAccumulator = '';
|
||||||
|
|
||||||
self.onmessage = async function(event) {
|
self.onmessage = async function(event) {
|
||||||
if (event.data.type === 'init') {
|
if (event.data.type === 'init') {
|
||||||
google_gemini = new GoogleGemini({
|
let config = { stream: true };
|
||||||
apiKey: event.data.google_gemini_api_key,
|
for (const key in event.data) {
|
||||||
model: event.data.google_gemini_model,
|
if (key.startsWith('google_gemini_')) {
|
||||||
system_instruction: event.data.google_gemini_system_instruction,
|
let newKey = key.replace('google_gemini_', '');
|
||||||
temperature: event.data.google_gemini_temperature,
|
if (newKey === 'api_key') newKey = 'apiKey';
|
||||||
thinking_budget: event.data.google_gemini_thinking_budget,
|
config[newKey] = event.data[key];
|
||||||
stream: true
|
}
|
||||||
});
|
}
|
||||||
|
google_gemini = new GoogleGemini(config);
|
||||||
do_debug = event.data.do_debug;
|
do_debug = event.data.do_debug;
|
||||||
i18nStrings = event.data.i18nStrings;
|
i18nStrings = event.data.i18nStrings;
|
||||||
taLog = new taLogger('model-worker-google_gemini', do_debug);
|
taLog = new taLogger('model-worker-google_gemini', do_debug);
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ let assistantResponseAccumulator = '';
|
||||||
self.onmessage = async function(event) {
|
self.onmessage = async function(event) {
|
||||||
switch (event.data.type) {
|
switch (event.data.type) {
|
||||||
case 'init':
|
case 'init':
|
||||||
ollama = new Ollama({
|
let config = { stream: true };
|
||||||
host: event.data.ollama_host,
|
for (const key in event.data) {
|
||||||
model: event.data.ollama_model,
|
if (key.startsWith('ollama_')) {
|
||||||
stream: true,
|
let newKey = key.replace('ollama_', '');
|
||||||
num_ctx: event.data.ollama_num_ctx,
|
config[newKey] = event.data[key];
|
||||||
temperature: event.data.ollama_temperature,
|
}
|
||||||
think: event.data.ollama_think
|
}
|
||||||
});
|
ollama = new Ollama(config);
|
||||||
do_debug = event.data.do_debug;
|
do_debug = event.data.do_debug;
|
||||||
i18nStrings = event.data.i18nStrings;
|
i18nStrings = event.data.i18nStrings;
|
||||||
taLog = new taLogger('model-worker-ollama', do_debug);
|
taLog = new taLogger('model-worker-ollama', do_debug);
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,15 @@ let assistantResponseAccumulator = '';
|
||||||
|
|
||||||
self.onmessage = async function(event) {
|
self.onmessage = async function(event) {
|
||||||
if (event.data.type === 'init') {
|
if (event.data.type === 'init') {
|
||||||
openai_comp = new OpenAIComp({
|
let config = { stream: true };
|
||||||
host: event.data.openai_comp_host,
|
for (const key in event.data) {
|
||||||
model: event.data.openai_comp_model,
|
if (key.startsWith('openai_comp_')) {
|
||||||
apiKey: event.data.openai_comp_api_key,
|
let newKey = key.replace('openai_comp_', '');
|
||||||
stream: true,
|
if (newKey === 'api_key') newKey = 'apiKey';
|
||||||
use_v1: event.data.openai_comp_use_v1,
|
config[newKey] = event.data[key];
|
||||||
openai_comp_temperature: event.data.openai_comp_temperature
|
}
|
||||||
});
|
}
|
||||||
|
openai_comp = new OpenAIComp(config);
|
||||||
do_debug = event.data.do_debug;
|
do_debug = event.data.do_debug;
|
||||||
i18nStrings = event.data.i18nStrings;
|
i18nStrings = event.data.i18nStrings;
|
||||||
taLog = new taLogger('model-worker-openai_comp', do_debug);
|
taLog = new taLogger('model-worker-openai_comp', do_debug);
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,16 @@ let previous_response_id = null;
|
||||||
|
|
||||||
self.onmessage = async function(event) {
|
self.onmessage = async function(event) {
|
||||||
if (event.data.type === 'init') {
|
if (event.data.type === 'init') {
|
||||||
openai = new OpenAI({
|
let config = { stream: true };
|
||||||
apiKey: event.data.chatgpt_api_key,
|
for (const key in event.data) {
|
||||||
model: event.data.chatgpt_model,
|
if (key.startsWith('chatgpt_')) {
|
||||||
developer_messages: event.data.chatgpt_developer_messages,
|
if (key.startsWith('chatgpt_web_')) continue; // Exclude chatgpt_web_ prefixed keys
|
||||||
temperature: event.data.chatgpt_api_temperature,
|
let newKey = key.replace('chatgpt_', '');
|
||||||
stream: true,
|
if (newKey === 'api_key') newKey = 'apiKey';
|
||||||
store: event.data.chatgpt_api_store
|
config[newKey] = event.data[key];
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
openai = new OpenAI(config);
|
||||||
do_debug = event.data.do_debug;
|
do_debug = event.data.do_debug;
|
||||||
i18nStrings = event.data.i18nStrings;
|
i18nStrings = event.data.i18nStrings;
|
||||||
taLog = new taLogger('model-worker-openai_responses', do_debug);
|
taLog = new taLogger('model-worker-openai_responses', do_debug);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue