temperature added to the Claude API. see #573
This commit is contained in:
parent
f95fbeb00e
commit
c2d99076b2
5 changed files with 60 additions and 14 deletions
|
|
@ -59,6 +59,10 @@
|
||||||
"message": "More info",
|
"message": "More info",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
"prompt_string":{
|
||||||
|
"message": "Prompt",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
"customPrompts_managePrompts_info_default": {
|
"customPrompts_managePrompts_info_default": {
|
||||||
"message": "The default prompts are not editable. You can disable them, then copy the prompt text and paste it into a new one to create a modified version.",
|
"message": "The default prompts are not editable. You can disable them, then copy the prompt text and paste it into a new one to create a modified version.",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
|
@ -1496,7 +1500,7 @@
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"prefs_OptionText_anthropic_max_tokens": {
|
"prefs_OptionText_anthropic_max_tokens": {
|
||||||
"message": "Claude Max Tokens",
|
"message": "Max Tokens",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"prefs_OptionText_anthropic_max_tokens_Info": {
|
"prefs_OptionText_anthropic_max_tokens_Info": {
|
||||||
|
|
@ -1709,6 +1713,14 @@
|
||||||
"message": "You can improve Claude performance by using a System Prompt to give it a role. This technique, known as role prompting, is the most powerful way to use system prompts with Claude. The right role can turn Claude from a general assistant into your virtual domain expert.",
|
"message": "You can improve Claude performance by using a System Prompt to give it a role. This technique, known as role prompting, is the most powerful way to use system prompts with Claude. The right role can turn Claude from a general assistant into your virtual domain expert.",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
"prefs_anthropic_temperature": {
|
||||||
|
"message": "Temperature",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"prefs_anthropic_temperature_Info": {
|
||||||
|
"message": "Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
"Optional_Permission_Denied_Model_Fetching": {
|
"Optional_Permission_Denied_Model_Fetching": {
|
||||||
"message": "You have denied the optional permission needed to fetch models for this integration.",
|
"message": "You have denied the optional permission needed to fetch models for this integration.",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ switch (llm) {
|
||||||
if(prefs_api.chatgpt_developer_messages && prefs_api.chatgpt_developer_messages.length > 0) {
|
if(prefs_api.chatgpt_developer_messages && prefs_api.chatgpt_developer_messages.length > 0) {
|
||||||
additional_text_elements.push({label: browser.i18n.getMessage("ChatGPT_Developer_Messages"), value: prefs_api.chatgpt_developer_messages});
|
additional_text_elements.push({label: browser.i18n.getMessage("ChatGPT_Developer_Messages"), value: prefs_api.chatgpt_developer_messages});
|
||||||
}
|
}
|
||||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
additional_text_elements.push({label: browser.i18n.getMessage("prompt_string"), value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||||
api_string: "ChatGPT API",
|
api_string: "ChatGPT API",
|
||||||
model_string: prefs_api.chatgpt_model,
|
model_string: prefs_api.chatgpt_model,
|
||||||
|
|
@ -138,7 +138,7 @@ switch (llm) {
|
||||||
if(prefs_api.google_gemini_thinking_budget.length > 0){
|
if(prefs_api.google_gemini_thinking_budget.length > 0){
|
||||||
additional_text_elements.push({label: browser.i18n.getMessage("prefs_google_gemini_thinking_budget"), value: prefs_api.google_gemini_thinking_budget});
|
additional_text_elements.push({label: browser.i18n.getMessage("prefs_google_gemini_thinking_budget"), value: prefs_api.google_gemini_thinking_budget});
|
||||||
}
|
}
|
||||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
additional_text_elements.push({label: browser.i18n.getMessage("prompt_string"), value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||||
worker.postMessage({
|
worker.postMessage({
|
||||||
type: 'init',
|
type: 'init',
|
||||||
google_gemini_api_key: prefs_api.google_gemini_api_key,
|
google_gemini_api_key: prefs_api.google_gemini_api_key,
|
||||||
|
|
@ -186,7 +186,7 @@ switch (llm) {
|
||||||
window_id: (await browser.windows.getCurrent()).id
|
window_id: (await browser.windows.getCurrent()).id
|
||||||
});
|
});
|
||||||
let additional_text_elements = [];
|
let additional_text_elements = [];
|
||||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
additional_text_elements.push({label: browser.i18n.getMessage("prompt_string"), value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||||
api_string: "Ollama API",
|
api_string: "Ollama API",
|
||||||
model_string: prefs_api.ollama_model,
|
model_string: prefs_api.ollama_model,
|
||||||
|
|
@ -219,7 +219,7 @@ switch (llm) {
|
||||||
i18nStrings: i18nStrings,
|
i18nStrings: i18nStrings,
|
||||||
});
|
});
|
||||||
let additional_text_elements = [];
|
let additional_text_elements = [];
|
||||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
additional_text_elements.push({label: browser.i18n.getMessage("prompt_string"), value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||||
api_string: "OpenAI Compatible API",
|
api_string: "OpenAI Compatible API",
|
||||||
model_string: prefs_api.openai_comp_model,
|
model_string: prefs_api.openai_comp_model,
|
||||||
|
|
@ -237,6 +237,7 @@ switch (llm) {
|
||||||
anthropic_api_key: prefs_default.anthropic_api_key,
|
anthropic_api_key: prefs_default.anthropic_api_key,
|
||||||
anthropic_model: prefs_default.anthropic_model,
|
anthropic_model: prefs_default.anthropic_model,
|
||||||
anthropic_system_prompt: prefs_default.anthropic_system_prompt,
|
anthropic_system_prompt: prefs_default.anthropic_system_prompt,
|
||||||
|
anthropic_temperature: prefs_default.anthropic_temperature,
|
||||||
anthropic_version: prefs_default.anthropic_version,
|
anthropic_version: prefs_default.anthropic_version,
|
||||||
anthropic_max_tokens: prefs_default.anthropic_max_tokens,
|
anthropic_max_tokens: prefs_default.anthropic_max_tokens,
|
||||||
do_debug: prefs_default.do_debug,
|
do_debug: prefs_default.do_debug,
|
||||||
|
|
@ -257,8 +258,19 @@ switch (llm) {
|
||||||
i18nStrings: i18nStrings,
|
i18nStrings: i18nStrings,
|
||||||
});
|
});
|
||||||
let additional_text_elements = [];
|
let additional_text_elements = [];
|
||||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
additional_text_elements.push({label: browser.i18n.getMessage("prompt_string"), value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||||
additional_text_elements.push({label: "System Prompt", value: prefs_api.anthropic_system_prompt});
|
if(prefs_api.anthropic_system_prompt && prefs_api.anthropic_system_prompt.length > 0){
|
||||||
|
additional_text_elements.push({label: browser.i18n.getMessage("Anthropic_System_Prompt"), value: prefs_api.anthropic_system_prompt});
|
||||||
|
}
|
||||||
|
if(prefs_api.anthropic_version && prefs_api.anthropic_version.length > 0){
|
||||||
|
additional_text_elements.push({label: browser.i18n.getMessage("_api_connecting_version"), value: prefs_api.anthropic_version});
|
||||||
|
}
|
||||||
|
if(prefs_api.anthropic_max_tokens > 0){
|
||||||
|
additional_text_elements.push({label: browser.i18n.getMessage("prefs_OptionText_anthropic_max_tokens"), value: prefs_api.anthropic_max_tokens});
|
||||||
|
}
|
||||||
|
if(prefs_api.anthropic_temperature && prefs_api.anthropic_temperature.length > 0){
|
||||||
|
additional_text_elements.push({label: browser.i18n.getMessage("prefs_anthropic_temperature"), value: prefs_api.anthropic_temperature});
|
||||||
|
}
|
||||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||||
api_string: "Claude API",
|
api_string: "Claude API",
|
||||||
model_string: prefs_api.anthropic_model,
|
model_string: prefs_api.anthropic_model,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ export class Anthropic {
|
||||||
version = '';
|
version = '';
|
||||||
model = '';
|
model = '';
|
||||||
system_prompt = '';
|
system_prompt = '';
|
||||||
|
temperature = '';
|
||||||
max_tokens = 4096;
|
max_tokens = 4096;
|
||||||
stream = false;
|
stream = false;
|
||||||
|
|
||||||
|
|
@ -33,6 +34,7 @@ export class Anthropic {
|
||||||
version = '',
|
version = '',
|
||||||
model = '',
|
model = '',
|
||||||
system_prompt = '',
|
system_prompt = '',
|
||||||
|
temperature = '',
|
||||||
max_tokens = 4096,
|
max_tokens = 4096,
|
||||||
stream = false,
|
stream = false,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
|
|
@ -40,6 +42,7 @@ export class Anthropic {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.system_prompt = system_prompt;
|
this.system_prompt = system_prompt;
|
||||||
|
this.temperature = temperature;
|
||||||
this.max_tokens = max_tokens > 0 ? max_tokens : 4096;
|
this.max_tokens = max_tokens > 0 ? max_tokens : 4096;
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +90,17 @@ export class Anthropic {
|
||||||
// console.log(">>>>>>>>>>> Anthropic API request: " + JSON.stringify(messages));
|
// console.log(">>>>>>>>>>> Anthropic API request: " + JSON.stringify(messages));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
let claude_body = {
|
||||||
|
model: this.model,
|
||||||
|
max_tokens: this.max_tokens,
|
||||||
|
system: this.system_prompt,
|
||||||
|
messages: messages,
|
||||||
|
stream: this.stream,
|
||||||
|
};
|
||||||
|
|
||||||
|
if(this.temperature != '') claude_body.temperature = this.temperature;
|
||||||
|
|
||||||
const response = await fetch("https://api.anthropic.com/v1/messages", {
|
const response = await fetch("https://api.anthropic.com/v1/messages", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -95,13 +109,7 @@ export class Anthropic {
|
||||||
"anthropic-version": this.version,
|
"anthropic-version": this.version,
|
||||||
"anthropic-dangerous-direct-browser-access": "true",
|
"anthropic-dangerous-direct-browser-access": "true",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify(claude_body),
|
||||||
model: this.model,
|
|
||||||
max_tokens: this.max_tokens,
|
|
||||||
system: this.system_prompt,
|
|
||||||
messages: messages,
|
|
||||||
stream: this.stream,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}catch (error) {
|
}catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ export const prefs_default = {
|
||||||
anthropic_version: '2023-06-01',
|
anthropic_version: '2023-06-01',
|
||||||
anthropic_max_tokens: 4096,
|
anthropic_max_tokens: 4096,
|
||||||
anthropic_system_prompt: '',
|
anthropic_system_prompt: '',
|
||||||
|
anthropic_temperature: '',
|
||||||
dynamic_menu_force_enter: false,
|
dynamic_menu_force_enter: false,
|
||||||
dynamic_menu_order_alphabet: true,
|
dynamic_menu_order_alphabet: true,
|
||||||
placeholders_use_default_value: false,
|
placeholders_use_default_value: false,
|
||||||
|
|
|
||||||
|
|
@ -410,6 +410,19 @@ export async function injectConnectionUI({
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="conntype_anthropic_api${tr_class ? ` ${tr_class}` : ''}">
|
||||||
|
<td>
|
||||||
|
<label>
|
||||||
|
<span class="opt_title">__MSG_prefs_anthropic_temperature__</span>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<label>
|
||||||
|
<input type="text" id="anthropic_temperature" name="anthropic_temperature" class="option-input" />
|
||||||
|
<br>__MSG_prefs_anthropic_temperature_Info__
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr class="conntype_anthropic_api${tr_class ? ` ${tr_class}` : ''}">
|
<tr class="conntype_anthropic_api${tr_class ? ` ${tr_class}` : ''}">
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue