mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
adding sydney in progress. only uses jailbreakConvoId and parentMsgId
This commit is contained in:
parent
69b3edc52c
commit
2c1ae68dc4
11 changed files with 53 additions and 41 deletions
|
|
@ -10,7 +10,7 @@ const askBing = async ({ text, progressCallback, convo }) => {
|
||||||
// If the above doesn't work, provide all your cookies as a string instead
|
// If the above doesn't work, provide all your cookies as a string instead
|
||||||
// cookies: '',
|
// cookies: '',
|
||||||
debug: false,
|
debug: false,
|
||||||
cache: new KeyvFile({ filename: './data/cache.json' })
|
cache: { store: new KeyvFile({ filename: './data/cache.json' }) }
|
||||||
});
|
});
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ const askSydney = async ({ text, progressCallback, convo }) => {
|
||||||
// If the above doesn't work, provide all your cookies as a string instead
|
// If the above doesn't work, provide all your cookies as a string instead
|
||||||
// cookies: '',
|
// cookies: '',
|
||||||
debug: false,
|
debug: false,
|
||||||
cache: new KeyvFile({ filename: './data/cache.json' })
|
cache: { store: new KeyvFile({ filename: './data/cache.json' }) }
|
||||||
});
|
});
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
|
|
@ -18,10 +18,12 @@ const askSydney = async ({ text, progressCallback, convo }) => {
|
||||||
onProgress: async (partialRes) => await progressCallback(partialRes),
|
onProgress: async (partialRes) => await progressCallback(partialRes),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (convo) {
|
if (convo.parentMessageId) {
|
||||||
options = { ...options, ...convo };
|
options = { ...options, jailbreakConversationId: convo.jailbreakConversationId, parentMessageId: convo.parentMessageId };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('sydney options', options);
|
||||||
|
|
||||||
const res = await sydneyClient.sendMessage(text, options
|
const res = await sydneyClient.sendMessage(text, options
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ const {
|
||||||
const { getConvo, saveMessage, deleteMessages, saveConvo } = require('../../models');
|
const { getConvo, saveMessage, deleteMessages, saveConvo } = require('../../models');
|
||||||
const { handleError, sendMessage } = require('./handlers');
|
const { handleError, sendMessage } = require('./handlers');
|
||||||
|
|
||||||
router.use('/bing', askSydney);
|
router.use('/bing', askBing);
|
||||||
|
router.use('/sydney', askSydney);
|
||||||
|
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
let { model, text, parentMessageId, conversationId, chatGptLabel, promptPrefix } = req.body;
|
let { model, text, parentMessageId, conversationId, chatGptLabel, promptPrefix } = req.body;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ router.post('/', async (req, res) => {
|
||||||
convo
|
convo
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('CLIENT RESPONSE');
|
console.log('BING RESPONSE');
|
||||||
console.dir(response, { depth: null });
|
console.dir(response, { depth: null });
|
||||||
|
|
||||||
userMessage.conversationSignature =
|
userMessage.conversationSignature =
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ router.post('/', async (req, res) => {
|
||||||
convo
|
convo
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('CLIENT RESPONSE');
|
console.log('SYDNEY RESPONSE');
|
||||||
console.dir(response, { depth: null });
|
// console.dir(response, { depth: null });
|
||||||
|
|
||||||
userMessage.conversationSignature =
|
userMessage.conversationSignature =
|
||||||
convo.conversationSignature || response.conversationSignature;
|
convo.conversationSignature || response.conversationSignature;
|
||||||
|
|
@ -57,6 +57,7 @@ router.post('/', async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
response.text = response.response;
|
response.text = response.response;
|
||||||
|
response.parentMessageId = convo.parentMessageId || response.messageId;
|
||||||
response.id = response.details.messageId;
|
response.id = response.details.messageId;
|
||||||
response.suggestions =
|
response.suggestions =
|
||||||
response.details.suggestedResponses &&
|
response.details.suggestedResponses &&
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export default function Conversation({
|
||||||
title = 'New conversation',
|
title = 'New conversation',
|
||||||
bingData,
|
bingData,
|
||||||
chatGptLabel = null,
|
chatGptLabel = null,
|
||||||
promptPrefix = null,
|
promptPrefix = null
|
||||||
}) {
|
}) {
|
||||||
const [renaming, setRenaming] = useState(false);
|
const [renaming, setRenaming] = useState(false);
|
||||||
const [titleInput, setTitleInput] = useState(title);
|
const [titleInput, setTitleInput] = useState(title);
|
||||||
|
|
@ -34,11 +34,17 @@ export default function Conversation({
|
||||||
const convo = { title, error: false, conversationId: id, chatGptLabel, promptPrefix };
|
const convo = { title, error: false, conversationId: id, chatGptLabel, promptPrefix };
|
||||||
|
|
||||||
if (bingData) {
|
if (bingData) {
|
||||||
const { conversationSignature, jailbreakConversationId, clientId, invocationId } = bingData;
|
const {
|
||||||
|
parentMessageId,
|
||||||
|
conversationSignature,
|
||||||
|
jailbreakConversationId,
|
||||||
|
clientId,
|
||||||
|
invocationId
|
||||||
|
} = bingData;
|
||||||
dispatch(
|
dispatch(
|
||||||
setConversation({
|
setConversation({
|
||||||
...convo,
|
...convo,
|
||||||
parentMessageId: null,
|
parentMessageId: parentMessageId || null,
|
||||||
jailbreakConversationId,
|
jailbreakConversationId,
|
||||||
conversationSignature,
|
conversationSignature,
|
||||||
clientId,
|
clientId,
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,10 @@ export default function TextChat({ messages }) {
|
||||||
setMessages([...messages, currentMsg, { sender, text: data.text || data.response }])
|
setMessages([...messages, currentMsg, { sender, text: data.text || data.response }])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isBing = model === 'bingai' || model === 'sydney';
|
||||||
|
|
||||||
if (
|
if (
|
||||||
model !== 'bingai' &&
|
!isBing &&
|
||||||
convo.conversationId === null &&
|
convo.conversationId === null &&
|
||||||
convo.parentMessageId === null
|
convo.parentMessageId === null
|
||||||
) {
|
) {
|
||||||
|
|
@ -66,13 +68,15 @@ export default function TextChat({ messages }) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
model === 'bingai' &&
|
isBing &&
|
||||||
convo.conversationId === null &&
|
convo.conversationId === null &&
|
||||||
convo.invocationId === null
|
convo.invocationId === null
|
||||||
) {
|
) {
|
||||||
|
console.log('Bing data:', data)
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
jailbreakConversationId,
|
jailbreakConversationId,
|
||||||
|
parentMessageId,
|
||||||
conversationSignature,
|
conversationSignature,
|
||||||
clientId,
|
clientId,
|
||||||
conversationId,
|
conversationId,
|
||||||
|
|
@ -82,11 +86,11 @@ export default function TextChat({ messages }) {
|
||||||
setConversation({
|
setConversation({
|
||||||
title,
|
title,
|
||||||
jailbreakConversationId,
|
jailbreakConversationId,
|
||||||
|
parentMessageId: parentMessageId || null,
|
||||||
conversationSignature,
|
conversationSignature,
|
||||||
clientId,
|
clientId,
|
||||||
conversationId,
|
conversationId,
|
||||||
invocationId,
|
invocationId,
|
||||||
parentMessageId: null
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -94,24 +98,6 @@ export default function TextChat({ messages }) {
|
||||||
dispatch(setSubmitState(false));
|
dispatch(setSubmitState(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
// const convoHandler = (data) => {
|
|
||||||
// const { conversationId, id, invocationId } = data;
|
|
||||||
// const conversationData = {
|
|
||||||
// title: data.title,
|
|
||||||
// conversationId,
|
|
||||||
// parentMessageId:
|
|
||||||
// model !== 'bingai' && !convo.conversationId && !convo.parentMessageId ? id : null,
|
|
||||||
// conversationSignature:
|
|
||||||
// model === 'bingai' && !convo.conversationId ? data.conversationSignature : null,
|
|
||||||
// clientId: model === 'bingai' && !convo.conversationId ? data.clientId : null,
|
|
||||||
// // invocationId: model === 'bingai' && !convo.conversationId ? data.invocationId : null
|
|
||||||
// invocationId: invocationId ? invocationId : null
|
|
||||||
// };
|
|
||||||
// dispatch(setMessages([...messages, currentMsg, { sender: model, text: data.text || data.response }]));
|
|
||||||
// dispatch(setConversation(conversationData));
|
|
||||||
// dispatch(setSubmitState(false));
|
|
||||||
// };
|
|
||||||
|
|
||||||
const errorHandler = (event) => {
|
const errorHandler = (event) => {
|
||||||
console.log('Error:', event);
|
console.log('Error:', event);
|
||||||
const errorResponse = {
|
const errorResponse = {
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,12 @@ export default function Message({
|
||||||
const bgColors = {
|
const bgColors = {
|
||||||
chatgpt: 'rgb(16, 163, 127)',
|
chatgpt: 'rgb(16, 163, 127)',
|
||||||
chatgptBrowser: 'rgb(25, 207, 207)',
|
chatgptBrowser: 'rgb(25, 207, 207)',
|
||||||
bingai: ''
|
bingai: '',
|
||||||
|
sydney: 'rgb(214, 255, 255)',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isBing = sender === 'bingai' || sender === 'sydney';
|
||||||
|
|
||||||
let icon = `${sender}:`;
|
let icon = `${sender}:`;
|
||||||
let backgroundColor = bgColors[sender];
|
let backgroundColor = bgColors[sender];
|
||||||
|
|
||||||
|
|
@ -59,13 +62,13 @@ export default function Message({
|
||||||
'w-full border-b border-black/10 bg-gray-50 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-100 dark:bg-[#444654]';
|
'w-full border-b border-black/10 bg-gray-50 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-100 dark:bg-[#444654]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((notUser && backgroundColor) || sender === 'bingai') {
|
if ((notUser && backgroundColor) || isBing) {
|
||||||
icon = (
|
icon = (
|
||||||
<div
|
<div
|
||||||
style={{ backgroundColor }}
|
style={{ backgroundColor }}
|
||||||
className="relative flex h-[30px] w-[30px] items-center justify-center rounded-sm p-1 text-white"
|
className="relative flex h-[30px] w-[30px] items-center justify-center rounded-sm p-1 text-white"
|
||||||
>
|
>
|
||||||
{sender === 'bingai' ? <BingIcon /> : <GPTIcon />}
|
{isBing ? <BingIcon /> : <GPTIcon />}
|
||||||
{error && (
|
{error && (
|
||||||
<span className="absolute right-0 top-[20px] -mr-2 flex h-4 w-4 items-center justify-center rounded-full border border-white bg-red-500 text-[10px] text-white">
|
<span className="absolute right-0 top-[20px] -mr-2 flex h-4 w-4 items-center justify-center rounded-full border border-white bg-red-500 text-[10px] text-white">
|
||||||
!
|
!
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,9 @@ export default function ModelMenu() {
|
||||||
'dark:disabled:hover:bg-transparent'
|
'dark:disabled:hover:bg-transparent'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const isBing = model === 'bingai' || model === 'sydney';
|
||||||
const colorProps = model === 'chatgpt' ? chatgptColorProps : defaultColorProps;
|
const colorProps = model === 'chatgpt' ? chatgptColorProps : defaultColorProps;
|
||||||
const icon = model === 'bingai' ? <BingIcon button={true} /> : <GPTIcon button={true} />;
|
const icon = isBing ? <BingIcon button={true} /> : <GPTIcon button={true} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog onOpenChange={onOpenChange}>
|
<Dialog onOpenChange={onOpenChange}>
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,17 @@ const initialState = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: '3',
|
_id: '3',
|
||||||
|
name: 'Sydney',
|
||||||
|
value: 'sydney'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_id: '4',
|
||||||
name: 'ChatGPT',
|
name: 'ChatGPT',
|
||||||
value: 'chatgptBrowser'
|
value: 'chatgptBrowser'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
modelMap: {},
|
modelMap: {},
|
||||||
initial: { chatgpt: true, chatgptCustom: true, bingai: true, chatgptBrowser: true }
|
initial: { chatgpt: true, chatgptCustom: true, bingai: true, sydney: true, chatgptBrowser: true }
|
||||||
// initial: { chatgpt: true, chatgptCustom: true, bingai: true, }
|
// initial: { chatgpt: true, chatgptCustom: true, bingai: true, }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,13 @@ export default function handleSubmit({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model === 'bingai' && convo.conversationId) {
|
const isBing = model === 'bingai' || model === 'sydney';
|
||||||
|
if (isBing && convo.conversationId) {
|
||||||
|
|
||||||
|
console.log('bing convo', convo);
|
||||||
payload = {
|
payload = {
|
||||||
...payload,
|
...payload,
|
||||||
|
jailbreakConversationId: convo.jailbreakConversationId,
|
||||||
conversationId: convo.conversationId,
|
conversationId: convo.conversationId,
|
||||||
conversationSignature: convo.conversationSignature,
|
conversationSignature: convo.conversationSignature,
|
||||||
clientId: convo.clientId,
|
clientId: convo.clientId,
|
||||||
|
|
@ -31,7 +35,10 @@ export default function handleSubmit({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = model === 'bingai' ? endpoint + '/bing' : endpoint;
|
let server = endpoint;
|
||||||
|
server = model === 'bingai' ? server + '/bing' : server;
|
||||||
|
server = model === 'sydney' ? server + '/sydney' : server;
|
||||||
|
|
||||||
const events = new SSE(server, {
|
const events = new SSE(server, {
|
||||||
payload: JSON.stringify(payload),
|
payload: JSON.stringify(payload),
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue