LibreChat/client/src/utils/createPayload.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

export default function createPayload(submission) {
const { conversation, messages, message, initialResponse, isRegenerate = false } = submission;
2023-03-14 21:25:02 -04:00
const endpoint = `/api/ask`;
const {
model,
chatGptLabel,
promptPrefix,
jailbreakConversationId,
conversationId,
conversationSignature,
clientId,
invocationId,
toneStyle
} = conversation;
2023-03-14 21:25:02 -04:00
let payload = {
...message,
...{
model,
chatGptLabel,
promptPrefix,
conversationId
2023-03-14 21:25:02 -04:00
}
};
// if (!payload.conversationId)
// if (convo?.conversationId && convo?.parentMessageId) {
// payload = {
// ...payload,
// conversationId: convo.conversationId,
// parentMessageId: convo.parentMessageId || '00000000-0000-0000-0000-000000000000'
// };
// }
2023-03-14 21:25:02 -04:00
const isBing = model === 'bingai' || model === 'sydney';
if (isBing && !conversationId) {
payload.toneStyle = toneStyle || 'fast';
}
if (isBing && conversationId) {
2023-03-14 21:25:02 -04:00
payload = {
...payload,
jailbreakConversationId,
conversationSignature,
clientId,
invocationId
2023-03-14 21:25:02 -04:00
};
}
let server = endpoint;
server = model === 'bingai' ? server + '/bing' : server;
server = model === 'sydney' ? server + '/sydney' : server;
return { server, payload };
}