tokenizer / index.js
omrahm's picture
added files
3693d04
import express, { json } from "express";
import { encode } from "gpt-3-encoder";
const app = express();
const port = 7860;
app.use(json());
app.post('*', (req, res) => {
const { text } = req.body;
const encoded = encode(text);
const length = encoded.length;
res.send({ length });
});
app.use((req, res) => {
res.status(405).send({ error: "Method not allowed" });
});
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});