refactor(createPayload): streamline all endpoints to agent route

This commit is contained in:
Danny Avila 2025-06-21 14:33:13 -04:00
parent 2797aff423
commit 7ad3ef7c23
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -13,20 +13,17 @@ export default function createPayload(submission: t.TSubmission) {
ephemeralAgent, ephemeralAgent,
} = submission; } = submission;
const { conversationId } = s.tConvoUpdateSchema.parse(conversation); const { conversationId } = s.tConvoUpdateSchema.parse(conversation);
const { endpoint: _e, endpointType } = endpointOption as { const { endpoint: _e } = endpointOption as {
endpoint: s.EModelEndpoint; endpoint: s.EModelEndpoint;
endpointType?: s.EModelEndpoint; endpointType?: s.EModelEndpoint;
}; };
const endpoint = _e as s.EModelEndpoint; const endpoint = _e as s.EModelEndpoint;
let server = EndpointURLs[endpointType ?? endpoint]; let server = `${EndpointURLs[s.EModelEndpoint.agents]}/${endpoint}`;
const isEphemeral = s.isEphemeralAgent(endpoint, ephemeralAgent); const isEphemeral = s.isEphemeralAgent(endpoint, ephemeralAgent);
if (isEdited && s.isAssistantsEndpoint(endpoint)) { if (isEdited && s.isAssistantsEndpoint(endpoint)) {
server += '/modify'; server += '/modify';
} else if (isEdited) {
server = server.replace('/ask/', '/edit/');
} else if (isEphemeral) {
server = `${EndpointURLs[s.EModelEndpoint.agents]}/${endpoint}`;
} }
const payload: t.TPayload = { const payload: t.TPayload = {