mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-18 20:39:58 +01:00
Merge pull request #1454 from valadaptive/classify-router
Use Express router for classify endpoint
This commit is contained in:
commit
88396935cd
@ -3621,7 +3621,7 @@ require('./src/endpoints/vectors').registerEndpoints(app, jsonParser);
|
||||
require('./src/endpoints/translate').registerEndpoints(app, jsonParser);
|
||||
|
||||
// Emotion classification
|
||||
require('./src/endpoints/classify').registerEndpoints(app, jsonParser);
|
||||
app.use('/api/extra/classify', require('./src/endpoints/classify').router);
|
||||
|
||||
// Image captioning
|
||||
app.use('/api/extra/caption', require('./src/endpoints/caption').router);
|
||||
|
@ -1,13 +1,13 @@
|
||||
const express = require('express');
|
||||
const { jsonParser } = require('../express-common');
|
||||
|
||||
const TASK = 'text-classification';
|
||||
|
||||
/**
|
||||
* @param {import("express").Express} app
|
||||
* @param {any} jsonParser
|
||||
*/
|
||||
function registerEndpoints(app, jsonParser) {
|
||||
const cacheObject = {};
|
||||
const router = express.Router();
|
||||
|
||||
app.post('/api/extra/classify/labels', jsonParser, async (req, res) => {
|
||||
const cacheObject = {};
|
||||
|
||||
router.post('/labels', jsonParser, async (req, res) => {
|
||||
try {
|
||||
const module = await import('../transformers.mjs');
|
||||
const pipe = await module.default.getPipeline(TASK);
|
||||
@ -17,9 +17,9 @@ function registerEndpoints(app, jsonParser) {
|
||||
console.error(error);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/api/extra/classify', jsonParser, async (req, res) => {
|
||||
router.post('/', jsonParser, async (req, res) => {
|
||||
try {
|
||||
const { text } = req.body;
|
||||
|
||||
@ -45,9 +45,6 @@ function registerEndpoints(app, jsonParser) {
|
||||
console.error(error);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
registerEndpoints,
|
||||
};
|
||||
module.exports = { router };
|
||||
|
Loading…
Reference in New Issue
Block a user