Add server endpoint to call prompt processing on demand

b55dd497463b5ee1e0c27823245a9c863eced7fb

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +18 -0Showing whitespace changes
src/endpoints/backends/chat-completions.js+18 -0
@@ -2292,3 +2292,21 @@ multimodalModels.post('/xai', async (req, res) => {
22922292});
22932293
22942294router.use('/multimodal-models', multimodalModels);
2295+
2296+router.post('/process', async function (request, response) {
2297+ try {
2298+ if (!Array.isArray(request.body.messages)) {
2299+ return response.status(400).send({ error: 'Invalid messages format' });
2300+ }
2301+
2302+ if (!Object.values(PROMPT_PROCESSING_TYPE).includes(request.body.type)) {
2303+ return response.status(400).send({ error: 'Unknown processing type' });
2304+ }
2305+
2306+ const messages = postProcessPrompt(request.body.messages, request.body.type, getPromptNames(request));
2307+ return response.send({ messages });
2308+ } catch (error) {
2309+ console.error(error);
2310+ return response.sendStatus(500);
2311+ }
2312+});