Compare commits

..

18 Commits

Author SHA1 Message Date
Chen188 4d2f9b147d clear stale code, fix bedrock aksk UI 2024-04-16 13:08:24 +00:00
Chen188 7209cabaf4 Merge branch 'release' of https://github.com/SillyTavern/SillyTavern into bedrock 2024-04-16 12:54:35 +00:00
Chen188 a9df3d96c0 remove duplicate key, seperate bedrock access key and secret key. 2024-04-16 12:53:38 +00:00
deffcolony 1c9b89fdcc Create issue-auto-comments.yml 2024-04-16 12:48:29 +02:00
deffcolony 035dbe4901 added issue/pr label workflows
3 months of inactivity Bot posts a comment to remind about it and assigns a stale label No further activity - 5 work days passes bot closes the issue
2024-04-15 16:41:43 +02:00
Cohee 789bb0da59 Fix extensions update loop 2024-04-15 00:24:15 +03:00
Cohee 6f5ca7b0b0
Merge pull request #2089 from africsnail/release
Add web-search connector toggle for Cohere API
2024-04-14 19:33:44 +03:00
Cohee 607e85639c Code clean-up 2024-04-14 19:31:38 +03:00
Cohee 2a061fdf54 Fix app init order 2024-04-14 14:58:58 +03:00
Cohee 2ccb6dc275
Merge pull request #2088 from CasualAutopsy/release
favicon.ico Enhancement
2024-04-14 14:43:54 +03:00
Cohee 26e798e13a
Merge pull request #2082 from Touch-Night/release
Improve Chinese translation
2024-04-14 14:43:20 +03:00
Ondřej Sakala 5ce625fb6b added a web-search toggle for Cohere API 2024-04-14 02:25:11 +02:00
CasualAutopsy 33461fb8e2
favicon.ico Enhancement 2024-04-13 19:42:59 -04:00
Cohee 8ae9212cc5 #2075 Fix Draw Things auth 2024-04-13 20:02:54 +03:00
Touch-Night d7d3787088 Some more fixes 2024-04-13 21:30:48 +08:00
Touch-Night 985b77d407 Improve Chinese translation 2024-04-13 20:40:02 +08:00
Cohee 4f83782430 Fix double count of chat injects for message fitting logic 2024-04-09 19:06:39 +03:00
Cohee 2411a7480e Add deprecated endpoint redirection 2024-04-09 16:21:13 +03:00
20 changed files with 560 additions and 802 deletions

2
.github/close-label.yml vendored Normal file
View File

@ -0,0 +1,2 @@
🐛 Bug: ✅ Fixed
🦄 Feature Request: ✅ Implemented

62
.github/issue-auto-comments.yml vendored Normal file
View File

@ -0,0 +1,62 @@
comment:
footer: |
---
> I am a bot, and this is an automated message 🤖
labels:
- name: ✖️ Invalid
labeled:
issue:
action: close
body: >
Hello @{{ issue.user.login }} your ticket has been marked as invalid.
Please ensure you follow the issue template, provide all requested info,
and be sure to check the docs + previous issues prior to raising tickets.
pr:
body: Thank you @{{ pull_request.user.login }} for suggesting this. Please follow the pull request templates.
action: close
- name: 👩‍💻 Good First Issue
labeled:
issue:
body: >
This issue has been marked as a good first issue for first-time contributors to implement!
This is a great way to support the project, while also improving your skills, you'll also be credited as a contributor once your PR is merged.
If you're new to SillyTavern [here are a collection of resources](https://docs.sillytavern.app/)
If you need any support at all, feel free to reach out via [Discord](https://discord.gg/sillytavern).
- name: ❌ wontfix
labeled:
issue:
action: close
body: >
This ticked has been marked as 'wontfix', which usually means it is out-of-scope, or not feasible at this time.
You can still fork the project and make the changes yourself.
- name: ✅ Fixed
labeled:
issue:
body: >
Hello @{{ issue.user.login }}! It looks like all or part of this issue has now been implemented.
- name: ‼️ High Priority
labeled:
issue:
body: >
This ticket has been marked as high priority, and has been bumped to the top of the priority list.
You should expect an implementation to be pushed out soon. Thank you for your patience.
- name: 💀 Spam
labeled:
issue:
action: close
locking: lock
lock_reason: spam
body: >
This issue has been identified as spam, and is now locked.
Users who repeatedly raise spam issues may be blocked or reported.
- name: ⛔ Don't Merge
labeled:
pr:
body: This PR has been temporarily blocked from merging.

View File

@ -0,0 +1,28 @@
# Based on a label applied to an issue, the bot will add a comment with some additional info
name: 🎯 Auto-Reply to Labeled Tickets
on:
issues:
types:
- labeled
- unlabeled
pull_request_target:
types:
- labeled
- unlabeled
permissions:
contents: read
issues: write
pull-requests: write
jobs:
comment:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Label Commenter
uses: peaceiris/actions-label-commenter@v1
with:
config_file: .github/issue-auto-comments.yml
github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,16 @@
# Detect and label pull requests that have merge conflicts
name: 🏗️ Check Merge Conflicts
on:
push:
branches:
- staging
jobs:
check-conflicts:
runs-on: ubuntu-latest
steps:
- uses: mschilde/auto-label-merge-conflicts@master
with:
CONFLICT_LABEL_NAME: "🚫 Merge Conflicts"
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
MAX_RETRIES: 5
WAIT_MS: 5000

View File

@ -0,0 +1,82 @@
# Closes any issues that no longer have user interaction
name: 🎯 Close Stale Issues
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight UTC
jobs:
stale:
runs-on: ubuntu-latest
steps:
# Comment on, then close issues that haven't been updated for ages
- name: Close Stale Issues
uses: actions/stale@v4
with:
repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
days-before-stale: 360
days-before-close: 5
operations-per-run: 30
remove-stale-when-updated: true
enable-statistics: true
stale-issue-message: >
This issue has gone 3 months without an update. To keep the ticket open, please indicate that it is still relevant in a comment below.
Otherwise it will be closed in 5 working days.
stale-pr-message: >
This PR is stale because it has been open 6 weeks with no activity. Either remove the stale label or comment below with a short update,
otherwise this PR will be closed in 5 days.
close-issue-message: >
This issue was automatically closed because it has been stalled for over 1 year with no activity.
close-pr-message: >
This pull request was automatically closed because it has been stalled for over 1 year with no activity.
stale-issue-label: '⚰️ Stale'
close-issue-label: '🕸️ Inactive'
stale-pr-label: '⚰️ Stale'
close-pr-label: '🕸️ Inactive'
exempt-issue-labels: '📌 Keep Open'
exempt-pr-labels: '📌 Keep Open'
labels-to-add-when-unstale: '📌 Keep Open'
# Comment on, then close issues that required a response from the user, but didn't get one
- name: Close Issues without Response
uses: actions/stale@v4
with:
repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
days-before-stale: 5
days-before-close: 3
operations-per-run: 30
remove-stale-when-updated: true
stale-issue-message: >
Hi! Looks like additional info is required for this issue to be addressed.
Don't forget to provide this within the next few days to keep your ticket open.
close-issue-message: 'Issue closed due to no response from user.'
only-labels: '🚏 Awaiting User Response'
labels-to-remove-when-unstale: '🚏 Awaiting User Response, 🛑 No Response'
stale-issue-label: '🛑 No Response'
close-issue-label: '🕸️ Inactive'
exempt-issue-labels: '📌 Keep Open'
exempt-pr-labels: '📌 Keep Open'
# Comment on issues that we should have replied to
- name: Notify Repo Owner to Respond
uses: actions/stale@v4
with:
repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
days-before-stale: 7
days-before-close: 365
operations-per-run: 30
remove-stale-when-updated: true
stale-issue-message: Hey SillyTavern, - Don't forget to respond!
stale-pr-message: Hey SillyTavern, - Don't forget to respond!
only-labels: '👤 Awaiting Maintainer Response'
labels-to-remove-when-unstale: '👤 Awaiting Maintainer Response'
close-issue-message: 'Closed due to no response from repo author for over a year'
close-pr-message: 'Closed due to no response from repo author for over a year'
stale-issue-label: '👤 Awaiting Maintainer Response'
stale-pr-label: '👤 Awaiting Maintainer Response'
close-issue-label: '🕸️ Inactive'
close-pr-label: '🕸️ Inactive'
exempt-issue-labels: '📌 Keep Open'
exempt-pr-labels: '📌 Keep Open'

39
.github/workflows/get-pr-size.yml vendored Normal file
View File

@ -0,0 +1,39 @@
# Adds a comment to new PRs, showing the compressed size and size difference of new code
# And also labels the PR based on the number of lines changes
name: 🌈 Check PR Size
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Find and comment with compressed size
- name: Get Compressed Size
uses: preactjs/compressed-size-action@v2
with:
repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
pattern: './dist/**/*.{js,css,html}'
strip-hash: '\\b\\w{8}\\.'
exclude: '**/node_modules/**'
minimum-change-threshold: 100
# Check number of lines of code added
- name: Label based on Lines of Code
uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
xs_max_size: '10'
s_max_size: '100'
m_max_size: '500'
l_max_size: '1000'
s_label: '🟩 PR - Small'
m_label: '🟨 PR - Medium'
l_label: '🟧 PR - Large'
xl_label: '🟥 PR - XL'
fail_if_xl: 'false'
message_if_xl: >
It looks like this PR is very large (over 1000 lines).
Try to avoid addressing multiple issues in a single PR, and
in the future consider breaking large tasks down into smaller steps.
This it to make reviewing, testing, reverting and general quality management easier.

View File

@ -0,0 +1,17 @@
# When a new comment is added to an issue, if it had the Stale or Awaiting User Response labels, then those labels will be removed
name: 🎯 Remove Pending Labels on Close
on:
issues:
types: [closed]
jobs:
remove-labels:
runs-on: ubuntu-latest
steps:
- name: Remove Labels when Closed
uses: actions-cool/issues-helper@v2
with:
actions: remove-labels
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: '🚏 Awaiting User Response,⚰️ Stale,👤 Awaiting Maintainer Response'

View File

@ -0,0 +1,42 @@
# When a new comment is added to an issue, if it had the Stale or Awaiting User Response labels, then those labels will be removed
name: 🎯 Add/ Remove Awaiting Response Labels
on:
issue_comment:
types: [created]
jobs:
remove-stale:
runs-on: ubuntu-latest
if: ${{ github.event.comment.author_association != 'COLLABORATOR' && github.event.comment.author_association != 'OWNER' }}
steps:
- name: Remove Stale labels when Updated
uses: actions-cool/issues-helper@v2
with:
actions: remove-labels
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: '🚏 Awaiting User Response,⚰️ Stale'
add-awaiting-author:
runs-on: ubuntu-latest
if: ${{!github.event.issue.pull_request && github.event.comment.author_association != 'COLLABORATOR' && github.event.comment.author_association != 'OWNER' && github.event.issue.state == 'open' }}
steps:
- name: Add Awaiting Author labels when Updated
uses: actions-cool/issues-helper@v2
with:
actions: add-labels
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: '👤 Awaiting Maintainer Response'
remove-awaiting-author:
runs-on: ubuntu-latest
if: ${{ github.event.comment.author_association == 'OWNER' }}
steps:
- name: Remove Awaiting Author labels when Updated
uses: actions-cool/issues-helper@v2
with:
actions: remove-labels
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: '👤 Awaiting Maintainer Response'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -458,6 +458,17 @@
</span>
</div>
</div>
<div class="range-block" data-source="cohere">
<label for="websearch_toggle" title="Enable Cohere web-search connector" data-i18n="[title]Enable Cohere web-search connector" class="checkbox_label widthFreeExpand">
<input id="websearch_toggle" type="checkbox" />
<span data-i18n="Web-search">Web-search</span>
</label>
<div class="toggle-description justifyLeft">
<span data-i18n="Allow the model to use the web-search connector.">
Allow the model to use the web-search connector.
</span>
</div>
</div>
<div class="range-block" data-source="openai,claude,windowai,openrouter,ai21,scale,makersuite,mistralai,custom,cohere">
<div class="range-block-title" data-i18n="Temperature">
Temperature
@ -1301,6 +1312,7 @@
<input class="neo-range-input" type="number" min="1" max="10" step="0.01" data-for="smoothing_curve_textgenerationwebui" id="smoothing_curve_counter_textgenerationwebui">
</div>
</div>
</div>
<!--
<div data-tg-type="aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0" data-i18n="Responses">
<small>Responses</small>
@ -2444,24 +2456,17 @@
</select>
</div>
<h4>AWS AKSK(Optional, if you use IAM Role/AWS CLI)</h4>
<!-- <div>
<span data-i18n="Get your key from">Get your key from </span> <a target="_blank" href="https://console.anthropic.com/account/keys" data-i18n="Anthropic's developer console">Anthropic's developer console</a>.
</div> -->
<h4>AWS AK/SK(Optional if you use IAM Role/AWS CLI)</h4>
<div class="flex-container">
<input id="api_key_bedrock" name="api_key_bedrock" readonly placeholder="Bedrock Key(AWS AK/SK)" class="text_pole flex1" maxlength="500" value="" type="text" autocomplete="off">
<div title="Clear your API key" data-i18n="[title]Clear your Access key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_bedrock"></div>
<input id="api_key_bedrock_access" name="api_key_bedrock_access" placeholder="AWS Access key" title="AWS Access key" class="text_pole flex1" maxlength="500" value="" type="text" autocomplete="off">
<div title="Clear your API key" data-i18n="[title]Clear your Access key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_bedrock_access"></div>
<input id="api_key_bedrock_secret" name="api_key_bedrock_secret" placeholder="AWS Secret key" title="AWS Secret key" class="text_pole flex1" maxlength="500" value="" type="text" autocomplete="off">
<div title="Clear your API key" data-i18n="[title]Clear your Secret key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_bedrock_secret"></div>
</div>
<div class="flex-container">
<input id="access_key_aws" name="access_key_aws" placeholder="AWS Access Key" class="text_pole flex1" maxlength="500" value="" type="text" autocomplete="off">
</div>
<div class="flex-container">
<input id="secret_key_aws" name="secret_key_aws" placeholder="AWS Secret Key" class="text_pole flex1" maxlength="500" value="" type="text" autocomplete="off">
</div>
<div data-for="access_key_aws" class="neutral_warning">
<div data-for="api_key_bedrock_access" class="neutral_warning">
For privacy reasons, your Access key will be hidden after you reload the page.
</div>
<div data-for="secret_key_aws" class="neutral_warning">
<div data-for="api_key_bedrock_secret" class="neutral_warning">
For privacy reasons, your Secret key will be hidden after you reload the page.
</div>
<div>

View File

@ -14,3 +14,4 @@
{ "lang": "uk-ua", "display": "Yкраїнська (Ukrainian)" },
{ "lang": "vi-vn", "display": "Tiếng Việt (Vietnamese)" }
]

File diff suppressed because it is too large Load Diff

View File

@ -897,11 +897,11 @@ async function firstLoadInit() {
throw new Error('Initialization failed');
}
getSystemMessages();
sendSystemMessage(system_message_types.WELCOME);
await getClientVersion();
await readSecretState();
await getSettings();
getSystemMessages();
sendSystemMessage(system_message_types.WELCOME);
initLocales();
initTags();
await getUserAvatars(true, user_avatar);
@ -3466,7 +3466,6 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
// Add persona description to prompt
addPersonaDescriptionExtensionPrompt();
// Call combined AN into Generate
let allAnchors = getAllExtensionPrompts();
const beforeScenarioAnchor = getExtensionPrompt(extension_prompt_types.BEFORE_PROMPT).trimStart();
const afterScenarioAnchor = getExtensionPrompt(extension_prompt_types.IN_PROMPT);
@ -3513,10 +3512,11 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
function getMessagesTokenCount() {
const encodeString = [
beforeScenarioAnchor,
storyString,
afterScenarioAnchor,
examplesString,
chatString,
allAnchors,
quiet_prompt,
cyclePrompt,
userAlignmentMessage,
@ -3784,12 +3784,13 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
console.debug('---checking Prompt size');
setPromptString();
const prompt = [
beforeScenarioAnchor,
storyString,
afterScenarioAnchor,
mesExmString,
mesSend.map((e) => `${e.extensionPrompts.join('')}${e.message}`).join(''),
'\n',
generatedPromptCache,
allAnchors,
quiet_prompt,
].join('').replace(/\r/gm, '');
let thisPromptContextSize = getTokenCount(prompt, power_user.token_padding);
@ -4025,7 +4026,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
...thisPromptBits[currentArrayEntry],
rawPrompt: generate_data.prompt || generate_data.input,
mesId: getNextMessageId(type),
allAnchors: allAnchors,
allAnchors: '',
summarizeString: (extension_prompts['1_memory']?.value || ''),
authorsNoteString: (extension_prompts['2_floating_prompt']?.value || ''),
smartContextString: (extension_prompts['chromadb']?.value || ''),
@ -9187,15 +9188,6 @@ jQuery(async function () {
}
});
$('#access_key_aws, #secret_key_aws').on('change', async function(e){
e.stopPropagation();
const access_key_aws = String($('#access_key_aws').val()).trim();
const secret_key_aws = String($('#secret_key_aws').val()).trim();
$('#api_key_bedrock').val(JSON.stringify([access_key_aws, secret_key_aws]));
});
$('#api_button_textgenerationwebui').on('click', async function (e) {
const keys = [
{ id: 'api_key_mancer', secret: SECRET_KEYS.MANCER },

View File

@ -210,6 +210,7 @@ const default_settings = {
top_a_openai: 1,
repetition_penalty_openai: 1,
stream_openai: false,
websearch_cohere: false,
openai_max_context: max_4k,
openai_max_tokens: 300,
wrap_in_quotes: false,
@ -281,6 +282,7 @@ const oai_settings = {
top_a_openai: 1,
repetition_penalty_openai: 1,
stream_openai: false,
websearch_cohere: false,
openai_max_context: max_4k,
openai_max_tokens: 300,
wrap_in_quotes: false,
@ -1765,6 +1767,7 @@ async function sendOpenAIRequest(type, messages, signal) {
generate_data['frequency_penalty'] = Math.min(Math.max(Number(oai_settings.freq_pen_openai), 0), 1);
generate_data['presence_penalty'] = Math.min(Math.max(Number(oai_settings.pres_pen_openai), 0), 1);
generate_data['stop'] = getCustomStoppingStrings(5);
generate_data['websearch'] = oai_settings.websearch_cohere;
}
if ((isOAI || isOpenRouter || isMistral || isCustom || isCohere) && oai_settings.seed >= 0) {
@ -2266,7 +2269,7 @@ export class ChatCompletion {
const shouldSquash = (message) => {
return !excludeList.includes(message.identifier) && message.role === 'system' && !message.name;
}
};
if (shouldSquash(message)) {
if (lastMessage && shouldSquash(lastMessage)) {
@ -2613,6 +2616,7 @@ function loadOpenAISettings(data, settings) {
oai_settings.min_p_openai = settings.min_p_openai ?? default_settings.min_p_openai;
oai_settings.repetition_penalty_openai = settings.repetition_penalty_openai ?? default_settings.repetition_penalty_openai;
oai_settings.stream_openai = settings.stream_openai ?? default_settings.stream_openai;
oai_settings.websearch_cohere = settings.websearch_cohere ?? default_settings.websearch_cohere;
oai_settings.openai_max_context = settings.openai_max_context ?? default_settings.openai_max_context;
oai_settings.openai_max_tokens = settings.openai_max_tokens ?? default_settings.openai_max_tokens;
oai_settings.bias_preset_selected = settings.bias_preset_selected ?? default_settings.bias_preset_selected;
@ -2676,6 +2680,7 @@ function loadOpenAISettings(data, settings) {
if (settings.claude_use_sysprompt !== undefined) oai_settings.claude_use_sysprompt = !!settings.claude_use_sysprompt;
if (settings.use_alt_scale !== undefined) { oai_settings.use_alt_scale = !!settings.use_alt_scale; updateScaleForm(); }
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
$('#websearch_toggle').prop('checked', oai_settings.websearch_cohere);
$('#api_url_scale').val(oai_settings.api_url_scale);
$('#openai_proxy_password').val(oai_settings.proxy_password);
$('#claude_assistant_prefill').val(oai_settings.assistant_prefill);
@ -2978,6 +2983,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
personality_format: settings.personality_format,
group_nudge_prompt: settings.group_nudge_prompt,
stream_openai: settings.stream_openai,
websearch_cohere: settings.websearch_cohere,
prompts: settings.prompts,
prompt_order: settings.prompt_order,
api_url_scale: settings.api_url_scale,
@ -3354,6 +3360,7 @@ function onSettingsPresetChange() {
personality_format: ['#personality_format_textarea', 'personality_format', false],
group_nudge_prompt: ['#group_nudge_prompt_textarea', 'group_nudge_prompt', false],
stream_openai: ['#stream_toggle', 'stream_openai', true],
websearch_cohere: ['#websearch_toggle', 'websearch_cohere', true],
prompts: ['', 'prompts', false],
prompt_order: ['', 'prompt_order', false],
api_url_scale: ['#api_url_scale', 'api_url_scale', false],
@ -3929,16 +3936,21 @@ async function onConnectButtonClick(e) {
}
if (oai_settings.chat_completion_source == chat_completion_sources.BEDROCK) {
const access_key_aws = String($('#access_key_aws').val()).trim();
const secret_key_aws = String($('#secret_key_aws').val()).trim();
const access_key_aws = String($('#api_key_bedrock_access').val()).trim();
const secret_key_aws = String($('#api_key_bedrock_secret').val()).trim();
if (access_key_aws.length > 0 && secret_key_aws.length > 0) {
await writeSecret(SECRET_KEYS.BEDROCK, [access_key_aws, secret_key_aws]);
if (access_key_aws.length) {
await writeSecret(SECRET_KEYS.BEDROCK_ACCESS_KEY, access_key_aws);
}
if (!secret_state[SECRET_KEYS.BEDROCK_ACCESS_KEY]) {
console.log('No access key saved for Amazon Bedrock');
}
if (!secret_state[SECRET_KEYS.BEDROCK]) {
console.log('No secret key saved for Amazon Bedrock');
return;
}
if (secret_key_aws.length) {
await writeSecret(SECRET_KEYS.BEDROCK_SECRET_KEY, secret_key_aws);
}
if (!secret_state[SECRET_KEYS.BEDROCK_SECRET_KEY]) {
console.log('No secret key saved for Amazon Bedrock');
}
}
startStatusLoading();
@ -4093,7 +4105,7 @@ export function isImageInliningSupported() {
'gemini-1.0-pro-vision-latest',
'gemini-1.5-pro-latest',
'gemini-pro-vision',
'claude-3'
'claude-3',
];
switch (oai_settings.chat_completion_source) {
@ -4319,6 +4331,11 @@ $(document).ready(async function () {
saveSettingsDebounced();
});
$('#websearch_toggle').on('change', function () {
oai_settings.websearch_cohere = !!$('#websearch_toggle').prop('checked');
saveSettingsDebounced();
});
$('#wrap_in_quotes').on('change', function () {
oai_settings.wrap_in_quotes = !!$('#wrap_in_quotes').prop('checked');
saveSettingsDebounced();

View File

@ -20,7 +20,8 @@ export const SECRET_KEYS = {
DREAMGEN: 'api_key_dreamgen',
CUSTOM: 'api_key_custom',
OOBA: 'api_key_ooba',
BEDROCK: 'api_key_bedrock',
BEDROCK_ACCESS_KEY: 'api_key_bedrock_access',
BEDROCK_SECRET_KEY: 'api_key_bedrock_secret',
NOMICAI: 'api_key_nomicai',
KOBOLDCPP: 'api_key_koboldcpp',
LLAMACPP: 'api_key_llamacpp',
@ -34,7 +35,6 @@ const INPUT_MAP = {
[SECRET_KEYS.NOVEL]: '#api_key_novel',
[SECRET_KEYS.CLAUDE]: '#api_key_claude',
[SECRET_KEYS.OPENROUTER]: '.api_key_openrouter',
[SECRET_KEYS.OPENROUTER]: '.api_key_openrouter',
[SECRET_KEYS.SCALE]: '#api_key_scale',
[SECRET_KEYS.AI21]: '#api_key_ai21',
[SECRET_KEYS.SCALE_COOKIE]: '#scale_cookie',
@ -45,7 +45,8 @@ const INPUT_MAP = {
[SECRET_KEYS.CUSTOM]: '#api_key_custom',
[SECRET_KEYS.TOGETHERAI]: '#api_key_togetherai',
[SECRET_KEYS.OOBA]: '#api_key_ooba',
[SECRET_KEYS.BEDROCK]: '#api_key_bedrock',
[SECRET_KEYS.BEDROCK_ACCESS_KEY]: '#api_key_bedrock_access',
[SECRET_KEYS.BEDROCK_SECRET_KEY]: '#api_key_bedrock_secret',
[SECRET_KEYS.INFERMATICAI]: '#api_key_infermaticai',
[SECRET_KEYS.DREAMGEN]: '#api_key_dreamgen',
[SECRET_KEYS.NOMICAI]: '#api_key_nomicai',
@ -63,11 +64,7 @@ async function clearSecret() {
await writeSecret(key, '');
secret_state[key] = false;
updateSecretDisplay();
$(INPUT_MAP[key]).val('').trigger('input').trigger('input');
if (key == SECRET_KEYS.BEDROCK) {
$('#access_key_aws').val('').trigger('input');
$('#secret_key_aws').val('').trigger('input');
}
$(INPUT_MAP[key]).val('').trigger('input');
$('#main_api').trigger('change');
}

View File

@ -341,6 +341,7 @@ redirect('/savequickreply', '/api/quick-replies/save');
// Redirect deprecated image endpoints
redirect('/uploadimage', '/api/images/upload');
redirect('/listimgfiles/:folder', '/api/images/list/:folder');
redirect('/api/content/import', '/api/content/importURL');
// Redirect deprecated moving UI endpoints
redirect('/savemovingui', '/api/moving-ui/save');

View File

@ -8,19 +8,20 @@ const getClient = (function() {
const client = {};
let aksk = '';
return function(region_name) {
const secrets = readSecret(SECRET_KEYS.BEDROCK);
const _aksk = secrets[0] + secrets[1] || '';
const access_key = readSecret(SECRET_KEYS.BEDROCK_ACCESS_KEY) || '';
const secret_key = readSecret(SECRET_KEYS.BEDROCK_SECRET_KEY) || '';
const _aksk = access_key + secret_key;
const refresh = _aksk != aksk;
if(! client[region_name] || refresh) {
aksk = _aksk;
const secrets = readSecret(SECRET_KEYS.BEDROCK);
if (secrets[0] && secrets[1]) {
if (access_key && secret_key) {
client[region_name] = new BedrockClient({
region: region_name,
credentials: {
accessKeyId: secrets[0],
secretAccessKey: secrets[1]
accessKeyId: access_key,
secretAccessKey: secret_key
}
});
} else {
@ -36,18 +37,19 @@ const getRuntimeClient = (function() {
const client = {};
let aksk = '';
return function(region_name) {
const secrets = readSecret(SECRET_KEYS.BEDROCK);
const _aksk = secrets[0] + secrets[1] || '';
const access_key = readSecret(SECRET_KEYS.BEDROCK_ACCESS_KEY) || '';
const secret_key = readSecret(SECRET_KEYS.BEDROCK_SECRET_KEY) || '';
const _aksk = access_key + secret_key;
const refresh = _aksk != aksk;
if(! client[region_name] || refresh) {
aksk = _aksk;
if (secrets[0] && secrets[1]) {
if (access_key && secret_key) {
client[region_name] = new BedrockRuntimeClient({
region: region_name,
credentials: {
accessKeyId: secrets[0],
secretAccessKey: secrets[1]
accessKeyId: access_key,
secretAccessKey: secret_key
}
});
} else {

View File

@ -620,6 +620,13 @@ async function sendCohereRequest(request, response) {
try {
const convertedHistory = convertCohereMessages(request.body.messages);
const connectors = [];
if (request.body.websearch) {
connectors.push({
id: 'web-search',
});
}
// https://docs.cohere.com/reference/chat
const requestBody = {
@ -637,7 +644,7 @@ async function sendCohereRequest(request, response) {
frequency_penalty: request.body.frequency_penalty,
presence_penalty: request.body.presence_penalty,
prompt_truncation: 'AUTO_PRESERVE_ORDER',
connectors: [], // TODO
connectors: connectors,
documents: [],
tools: [],
tool_results: [],
@ -692,6 +699,7 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
let api_url;
let api_key_openai;
let headers;
let bedrock_region = 'us-east-1';
if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.OPENAI) {
api_url = new URL(request.body.reverse_proxy || API_OPENAI).toString();
@ -712,7 +720,7 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
headers = {};
mergeObjectWithYaml(headers, request.body.custom_include_headers);
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.BEDROCK) {
var bedrock_region = request.body.bedrock_region;
bedrock_region = request.body.bedrock_region;
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.COHERE) {
api_url = API_COHERE;
api_key_openai = readSecret(SECRET_KEYS.COHERE);
@ -722,7 +730,6 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
return response_getstatus_openai.status(400).send({ error: true });
}
// todo: should check Key or IAM Role permission
if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.BEDROCK) {
try {
let resp = await listTextModels(bedrock_region);
@ -951,11 +958,6 @@ router.post('/generate', jsonParser, function (request, response) {
bodyParams.logprobs = true;
}
mergeObjectWithYaml(bodyParams, request.body.custom_include_body);
mergeObjectWithYaml(headers, request.body.custom_include_headers);
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.BEDROCK) {
console.log(request);
apiKey = readSecret(SECRET_KEYS.BEDROCK);
mergeObjectWithYaml(bodyParams, request.body.custom_include_body);
mergeObjectWithYaml(headers, request.body.custom_include_headers);
} else {

View File

@ -30,7 +30,8 @@ const SECRET_KEYS = {
MISTRALAI: 'api_key_mistralai',
CUSTOM: 'api_key_custom',
OOBA: 'api_key_ooba',
BEDROCK: 'api_key_bedrock',
BEDROCK_ACCESS_KEY: 'api_key_bedrock_access',
BEDROCK_SECRET_KEY: 'api_key_bedrock_secret',
INFERMATICAI: 'api_key_infermaticai',
DREAMGEN: 'api_key_dreamgen',
NOMICAI: 'api_key_nomicai',

View File

@ -684,15 +684,17 @@ drawthings.post('/generate', jsonParser, async (request, response) => {
const url = new URL(request.body.url);
url.pathname = '/sdapi/v1/txt2img';
const body = {...request.body};
const body = { ...request.body };
const auth = getBasicAuthHeader(request.body.auth);
delete body.url;
delete body.auth;
const result = await fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
'Authorization': getBasicAuthHeader(request.body.auth),
'Authorization': auth,
},
timeout: 0,
});