mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
* fix: Add `isRegenerate` flag to chat payload to avoid saving temporary response IDs * fix: Remove unused `isResubmission` flag * ci: Add tests for responseMessageId regeneration logic in BaseClient
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import type * as t from './types';
|
|
import { EndpointURLs } from './config';
|
|
import * as s from './schemas';
|
|
|
|
export default function createPayload(submission: t.TSubmission) {
|
|
const {
|
|
isEdited,
|
|
userMessage,
|
|
isContinued,
|
|
isTemporary,
|
|
isRegenerate,
|
|
conversation,
|
|
editedContent,
|
|
ephemeralAgent,
|
|
endpointOption,
|
|
} = submission;
|
|
const { conversationId } = s.tConvoUpdateSchema.parse(conversation);
|
|
const { endpoint: _e, endpointType } = endpointOption as {
|
|
endpoint: s.EModelEndpoint;
|
|
endpointType?: s.EModelEndpoint;
|
|
};
|
|
|
|
const endpoint = _e as s.EModelEndpoint;
|
|
let server = `${EndpointURLs[s.EModelEndpoint.agents]}/${endpoint}`;
|
|
if (s.isAssistantsEndpoint(endpoint)) {
|
|
server =
|
|
EndpointURLs[(endpointType ?? endpoint) as 'assistants' | 'azureAssistants'] +
|
|
(isEdited ? '/modify' : '');
|
|
}
|
|
|
|
const payload: t.TPayload = {
|
|
...userMessage,
|
|
...endpointOption,
|
|
endpoint,
|
|
isTemporary,
|
|
isRegenerate,
|
|
editedContent,
|
|
conversationId,
|
|
isContinued: !!(isEdited && isContinued),
|
|
ephemeralAgent: s.isAssistantsEndpoint(endpoint) ? undefined : ephemeralAgent,
|
|
};
|
|
|
|
return { server, payload };
|
|
}
|