mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-19 04:50:12 +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);
|
require('./src/endpoints/translate').registerEndpoints(app, jsonParser);
|
||||||
|
|
||||||
// Emotion classification
|
// Emotion classification
|
||||||
require('./src/endpoints/classify').registerEndpoints(app, jsonParser);
|
app.use('/api/extra/classify', require('./src/endpoints/classify').router);
|
||||||
|
|
||||||
// Image captioning
|
// Image captioning
|
||||||
app.use('/api/extra/caption', require('./src/endpoints/caption').router);
|
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';
|
const TASK = 'text-classification';
|
||||||
|
|
||||||
/**
|
const router = express.Router();
|
||||||
* @param {import("express").Express} app
|
|
||||||
* @param {any} jsonParser
|
|
||||||
*/
|
|
||||||
function registerEndpoints(app, jsonParser) {
|
|
||||||
const cacheObject = {};
|
|
||||||
|
|
||||||
app.post('/api/extra/classify/labels', jsonParser, async (req, res) => {
|
const cacheObject = {};
|
||||||
|
|
||||||
|
router.post('/labels', jsonParser, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const module = await import('../transformers.mjs');
|
const module = await import('../transformers.mjs');
|
||||||
const pipe = await module.default.getPipeline(TASK);
|
const pipe = await module.default.getPipeline(TASK);
|
||||||
@ -17,9 +17,9 @@ function registerEndpoints(app, jsonParser) {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
return res.sendStatus(500);
|
return res.sendStatus(500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/api/extra/classify', jsonParser, async (req, res) => {
|
router.post('/', jsonParser, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { text } = req.body;
|
const { text } = req.body;
|
||||||
|
|
||||||
@ -45,9 +45,6 @@ function registerEndpoints(app, jsonParser) {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
return res.sendStatus(500);
|
return res.sendStatus(500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = { router };
|
||||||
registerEndpoints,
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user