mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
feat(bingai.js): add context and systemMessage parameters to askBing function
feat(conversationPreset.js): add context and systemMessage fields to conversation preset schema feat(askBingAI.js): pass context and systemMessage parameters to ask function feat(Settings.jsx): add toneStyle prop to BingAISettings component feat(BingAIOptions/index.jsx): add useEffect to check if advanced mode is needed feat(cleanupPreset.js): add context and systemMessage fields to cleaned up preset object feat(getDefaultConversation.js): add context and systemMessage fields to default conversation object feat(handleSubmit.js): add context and systemMessage fields to message object
This commit is contained in:
parent
3484ff687d
commit
bb75b6df3b
9 changed files with 37 additions and 9 deletions
|
|
@ -7,6 +7,8 @@ const askBing = async ({
|
|||
conversationId,
|
||||
jailbreak,
|
||||
jailbreakConversationId,
|
||||
context,
|
||||
systemMessage,
|
||||
conversationSignature,
|
||||
clientId,
|
||||
invocationId,
|
||||
|
|
@ -30,8 +32,10 @@ const askBing = async ({
|
|||
|
||||
let options = {
|
||||
jailbreakConversationId: jailbreakConversationId || jailbreak,
|
||||
context,
|
||||
systemMessage,
|
||||
parentMessageId,
|
||||
conversationId,
|
||||
conversationId: jailbreakConversationId ? jailbreakConversationId : conversationId,
|
||||
toneStyle,
|
||||
onProgress
|
||||
};
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@ module.exports = {
|
|||
type: String,
|
||||
default: null
|
||||
},
|
||||
context: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
systemMessage: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
clientId: {
|
||||
type: String,
|
||||
default: null
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ router.post('/', async (req, res) => {
|
|||
const endpointOption = {
|
||||
jailbreak: req.body?.jailbreak || false,
|
||||
jailbreakConversationId: req.body?.jailbreakConversationId || null,
|
||||
systemMessage: req.body?.systemMessage || null,
|
||||
context: req.body?.context || null,
|
||||
conversationSignature: req.body?.conversationSignature || null,
|
||||
clientId: req.body?.clientId || null,
|
||||
invocationId: req.body?.invocationId || null,
|
||||
|
|
@ -58,6 +60,7 @@ router.post('/', async (req, res) => {
|
|||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
return await ask({
|
||||
isNewConversation,
|
||||
userMessage,
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ function Settings(props) {
|
|||
disabled={readonly}
|
||||
value={context || ''}
|
||||
onChange={e => setContext(e.target.value || null)}
|
||||
placeholder="Bing can use up to 7k tokens for 'context', text that it can reference per 1 conversation. The specific limit is not known but may run into errors exceeding 7k tokens"
|
||||
placeholder="Bing can use up to 7k tokens for 'context', which it can reference for the conversation. The specific limit is not known but may run into errors exceeding 7k tokens"
|
||||
className={cn(
|
||||
defaultTextProps,
|
||||
'flex max-h-[300px] min-h-[100px] w-full resize-none px-3 py-2'
|
||||
|
|
@ -126,10 +126,10 @@ function Settings(props) {
|
|||
disabled={readonly}
|
||||
value={systemMessage || ''}
|
||||
onChange={e => setSystemMessage(e.target.value || null)}
|
||||
placeholder="WARNING: Misuse of this feature can get you BANNED from using Bing! Click on 'System Message' for full instructions and the default message if omitted, which is the 'Sydney' preset that is considered safe."
|
||||
placeholder="WARNING: Misuse of this feature can get you BANNED from using Bing! Click on 'System Message' for full instructions and the default message if omitted, which is the 'Sydney' preset that is considered safe. Leave blank for the default message."
|
||||
className={cn(
|
||||
defaultTextProps,
|
||||
'flex max-h-[300px] min-h-[148px] w-full resize-none px-3 py-2 '
|
||||
'flex max-h-[300px] min-h-[148px] w-full resize-none px-3 py-2 placeholder:text-red-400'
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ const Settings = ({ preset, ...props }) => {
|
|||
else if (endpoint === 'bingAI')
|
||||
return (
|
||||
<BingAISettings
|
||||
toneStyle={preset?.toneStyle}
|
||||
context={preset?.context}
|
||||
systemMessage={preset?.systemMessage}
|
||||
jailbreak={preset?.jailbreak}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useRecoilValue, useRecoilState } from 'recoil';
|
||||
import { cn } from '~/utils';
|
||||
import { Button } from '../../ui/Button.tsx';
|
||||
|
|
@ -15,7 +15,15 @@ function BingAIOptions() {
|
|||
const [advancedMode, setAdvancedMode] = useState(false);
|
||||
const [saveAsDialogShow, setSaveAsDialogShow] = useState(false);
|
||||
const { endpoint, conversationId } = conversation;
|
||||
const { context, systemMessage, jailbreak } = conversation;
|
||||
const { toneStyle, context, systemMessage, jailbreak } = conversation;
|
||||
|
||||
useEffect(() => {
|
||||
if (endpoint !== 'bingAI') return;
|
||||
|
||||
const mustInAdvancedMode = context !== null || systemMessage !== null;
|
||||
|
||||
if (mustInAdvancedMode && !advancedMode) setAdvancedMode(true);
|
||||
}, [conversation, advancedMode]);
|
||||
|
||||
if (endpoint !== 'bingAI') return null;
|
||||
if (conversationId !== 'new') return null;
|
||||
|
|
@ -49,8 +57,6 @@ function BingAIOptions() {
|
|||
}));
|
||||
};
|
||||
|
||||
const { toneStyle } = conversation;
|
||||
|
||||
const cardStyle =
|
||||
'transition-colors shadow-md rounded-md min-w-[75px] font-normal bg-white border-black/10 hover:border-black/10 focus:border-black/10 dark:border-black/10 dark:hover:border-black/10 dark:focus:border-black/10 border dark:bg-gray-700 text-black dark:text-white';
|
||||
const defaultClasses =
|
||||
|
|
@ -114,7 +120,7 @@ function BingAIOptions() {
|
|||
</div>
|
||||
<EndpointOptionsPopover
|
||||
content={
|
||||
<div className="px-4 py-4 z-50">
|
||||
<div className="z-50 px-4 py-4">
|
||||
<Settings
|
||||
context={context}
|
||||
systemMessage={systemMessage}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ const cleanupPreset = _preset => {
|
|||
endpoint,
|
||||
presetId: _preset?.presetId || null,
|
||||
jailbreak: _preset?.jailbreak || false,
|
||||
context: _preset?.context || null,
|
||||
systemMessage: _preset?.systemMessage || null,
|
||||
jailbreakpresetId: _preset?._jailbreakpresetId || null,
|
||||
presetSignature: null,
|
||||
clientId: null,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ const buildDefaultConversation = ({ conversation, endpoint, lastConversationSetu
|
|||
...conversation,
|
||||
endpoint,
|
||||
jailbreak: lastConversationSetup?.jailbreak || false,
|
||||
systemMessage: lastConversationSetup?.systemMessage || null,
|
||||
context: lastConversationSetup?.context || null,
|
||||
jailbreakConversationId: lastConversationSetup?.jailbreakConversationId || null,
|
||||
conversationSignature: null,
|
||||
clientId: null,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ const useMessageHandler = () => {
|
|||
jailbreak: currentConversation?.jailbreak || false,
|
||||
jailbreakConversationId: currentConversation?.jailbreakConversationId || null,
|
||||
conversationSignature: currentConversation?.conversationSignature || null,
|
||||
systemMessage: currentConversation?.systemMessage || null,
|
||||
context: currentConversation?.context || null,
|
||||
clientId: currentConversation?.clientId || null,
|
||||
invocationId: currentConversation?.invocationId || 1,
|
||||
toneStyle: currentConversation?.toneStyle || 'fast'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue