2023-03-28 22:39:27 +08:00
|
|
|
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`;
|
2023-03-28 22:39:27 +08:00
|
|
|
const {
|
|
|
|
|
model,
|
|
|
|
|
chatGptLabel,
|
|
|
|
|
promptPrefix,
|
|
|
|
|
jailbreakConversationId,
|
|
|
|
|
conversationId,
|
|
|
|
|
conversationSignature,
|
|
|
|
|
clientId,
|
|
|
|
|
invocationId,
|
|
|
|
|
toneStyle
|
|
|
|
|
} = conversation;
|
2023-03-14 21:25:02 -04:00
|
|
|
|
2023-03-28 22:39:27 +08:00
|
|
|
let payload = {
|
|
|
|
|
...message,
|
|
|
|
|
...{
|
|
|
|
|
model,
|
|
|
|
|
chatGptLabel,
|
|
|
|
|
promptPrefix,
|
|
|
|
|
conversationId
|
2023-03-14 21:25:02 -04:00
|
|
|
}
|
2023-03-28 22:39:27 +08: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';
|
2023-03-28 22:39:27 +08:00
|
|
|
if (isBing && !conversationId) {
|
|
|
|
|
payload.toneStyle = toneStyle || 'fast';
|
2023-03-24 16:21:10 -04:00
|
|
|
}
|
2023-03-28 22:39:27 +08:00
|
|
|
|
|
|
|
|
if (isBing && conversationId) {
|
2023-03-14 21:25:02 -04:00
|
|
|
payload = {
|
|
|
|
|
...payload,
|
2023-03-28 22:39:27 +08:00
|
|
|
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 };
|
2023-03-24 16:21:10 -04:00
|
|
|
}
|