mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
* 🐛 fix: Enhance provider validation and error handling in getProviderConfig function
* WIP: edit text part
* refactor: Allow updating of both TEXT and THINK content types in message updates
* WIP: first pass, save & submit
* chore: remove legacy generation user message field
* feat: merge edited content
* fix: update placeholder and description for bedrock setting
* fix: remove unsupported warning message for AI resubmission
42 lines
1.1 KiB
TypeScript
42 lines
1.1 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 {
|
|
conversation,
|
|
userMessage,
|
|
endpointOption,
|
|
isEdited,
|
|
isContinued,
|
|
isTemporary,
|
|
ephemeralAgent,
|
|
editedContent,
|
|
} = 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,
|
|
ephemeralAgent: s.isAssistantsEndpoint(endpoint) ? undefined : ephemeralAgent,
|
|
isContinued: !!(isEdited && isContinued),
|
|
conversationId,
|
|
isTemporary,
|
|
editedContent,
|
|
};
|
|
|
|
return { server, payload };
|
|
}
|