LibreChat/client/src/utils/createPayload.js
Wentao Lyu c7c30d8bb5 refactor: basic message and send message. as well as model
THIS IS NOT FINISHED. DONT USE THIS
2023-03-28 22:39:27 +08:00

55 lines
1.3 KiB
JavaScript

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