diff --git a/api/app/bingai.js b/api/app/bingai.js index dff3958294..4dfa8a71d5 100644 --- a/api/app/bingai.js +++ b/api/app/bingai.js @@ -10,7 +10,7 @@ const askBing = async ({ text, progressCallback, convo }) => { // If the above doesn't work, provide all your cookies as a string instead // cookies: '', debug: false, - cache: new KeyvFile({ filename: './data/cache.json' }) + cache: { store: new KeyvFile({ filename: './data/cache.json' }) } }); let options = { diff --git a/api/app/sydney.js b/api/app/sydney.js index a599128640..fe47c74f57 100644 --- a/api/app/sydney.js +++ b/api/app/sydney.js @@ -10,7 +10,7 @@ const askSydney = async ({ text, progressCallback, convo }) => { // If the above doesn't work, provide all your cookies as a string instead // cookies: '', debug: false, - cache: new KeyvFile({ filename: './data/cache.json' }) + cache: { store: new KeyvFile({ filename: './data/cache.json' }) } }); let options = { @@ -18,10 +18,12 @@ const askSydney = async ({ text, progressCallback, convo }) => { onProgress: async (partialRes) => await progressCallback(partialRes), }; - if (convo) { - options = { ...options, ...convo }; + if (convo.parentMessageId) { + options = { ...options, jailbreakConversationId: convo.jailbreakConversationId, parentMessageId: convo.parentMessageId }; } + console.log('sydney options', options); + const res = await sydneyClient.sendMessage(text, options ); diff --git a/api/server/routes/ask.js b/api/server/routes/ask.js index 883be12737..23ed20ba85 100644 --- a/api/server/routes/ask.js +++ b/api/server/routes/ask.js @@ -13,7 +13,8 @@ const { const { getConvo, saveMessage, deleteMessages, saveConvo } = require('../../models'); const { handleError, sendMessage } = require('./handlers'); -router.use('/bing', askSydney); +router.use('/bing', askBing); +router.use('/sydney', askSydney); router.post('/', async (req, res) => { let { model, text, parentMessageId, conversationId, chatGptLabel, promptPrefix } = req.body; diff --git a/api/server/routes/askBing.js b/api/server/routes/askBing.js index 7b3ab74a53..d77282f888 100644 --- a/api/server/routes/askBing.js +++ b/api/server/routes/askBing.js @@ -38,7 +38,7 @@ router.post('/', async (req, res) => { convo }); - console.log('CLIENT RESPONSE'); + console.log('BING RESPONSE'); console.dir(response, { depth: null }); userMessage.conversationSignature = diff --git a/api/server/routes/askSydney.js b/api/server/routes/askSydney.js index 8dbf287f8f..0b77526b8b 100644 --- a/api/server/routes/askSydney.js +++ b/api/server/routes/askSydney.js @@ -38,8 +38,8 @@ router.post('/', async (req, res) => { convo }); - console.log('CLIENT RESPONSE'); - console.dir(response, { depth: null }); + console.log('SYDNEY RESPONSE'); + // console.dir(response, { depth: null }); userMessage.conversationSignature = convo.conversationSignature || response.conversationSignature; @@ -47,7 +47,7 @@ router.post('/', async (req, res) => { userMessage.invocationId = response.invocationId; userMessage.jailbreakConversationId = convo.jailbreakConversationId || response.jailbreakConversationId; await saveMessage(userMessage); - + if (!convo.conversationSignature) { response.title = await titleConvo({ model, @@ -55,8 +55,9 @@ router.post('/', async (req, res) => { response: JSON.stringify(response.response) }); } - + response.text = response.response; + response.parentMessageId = convo.parentMessageId || response.messageId; response.id = response.details.messageId; response.suggestions = response.details.suggestedResponses && diff --git a/client/src/components/Conversations/Conversation.jsx b/client/src/components/Conversations/Conversation.jsx index cd4b61f916..455d331d07 100644 --- a/client/src/components/Conversations/Conversation.jsx +++ b/client/src/components/Conversations/Conversation.jsx @@ -16,7 +16,7 @@ export default function Conversation({ title = 'New conversation', bingData, chatGptLabel = null, - promptPrefix = null, + promptPrefix = null }) { const [renaming, setRenaming] = useState(false); const [titleInput, setTitleInput] = useState(title); @@ -34,11 +34,17 @@ export default function Conversation({ const convo = { title, error: false, conversationId: id, chatGptLabel, promptPrefix }; if (bingData) { - const { conversationSignature, jailbreakConversationId, clientId, invocationId } = bingData; + const { + parentMessageId, + conversationSignature, + jailbreakConversationId, + clientId, + invocationId + } = bingData; dispatch( setConversation({ ...convo, - parentMessageId: null, + parentMessageId: parentMessageId || null, jailbreakConversationId, conversationSignature, clientId, diff --git a/client/src/components/Main/TextChat.jsx b/client/src/components/Main/TextChat.jsx index 7701885b4c..a162a452d2 100644 --- a/client/src/components/Main/TextChat.jsx +++ b/client/src/components/Main/TextChat.jsx @@ -46,8 +46,10 @@ export default function TextChat({ messages }) { setMessages([...messages, currentMsg, { sender, text: data.text || data.response }]) ); + const isBing = model === 'bingai' || model === 'sydney'; + if ( - model !== 'bingai' && + !isBing && convo.conversationId === null && convo.parentMessageId === null ) { @@ -66,13 +68,15 @@ export default function TextChat({ messages }) { }) ); } else if ( - model === 'bingai' && + isBing && convo.conversationId === null && convo.invocationId === null ) { + console.log('Bing data:', data) const { title, jailbreakConversationId, + parentMessageId, conversationSignature, clientId, conversationId, @@ -82,11 +86,11 @@ export default function TextChat({ messages }) { setConversation({ title, jailbreakConversationId, + parentMessageId: parentMessageId || null, conversationSignature, clientId, conversationId, invocationId, - parentMessageId: null }) ); } @@ -94,24 +98,6 @@ export default function TextChat({ messages }) { 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) => { console.log('Error:', event); const errorResponse = { diff --git a/client/src/components/Messages/Message.jsx b/client/src/components/Messages/Message.jsx index b713df48ec..0accb1afeb 100644 --- a/client/src/components/Messages/Message.jsx +++ b/client/src/components/Messages/Message.jsx @@ -48,9 +48,12 @@ export default function Message({ const bgColors = { chatgpt: 'rgb(16, 163, 127)', chatgptBrowser: 'rgb(25, 207, 207)', - bingai: '' + bingai: '', + sydney: 'rgb(214, 255, 255)', }; + const isBing = sender === 'bingai' || sender === 'sydney'; + let icon = `${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]'; } - if ((notUser && backgroundColor) || sender === 'bingai') { + if ((notUser && backgroundColor) || isBing) { icon = (