mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
style(tokenizer.js): comment out console.log statement
fix(Settings.jsx): handle null or empty context in useEffect to avoid errors
This commit is contained in:
parent
1a196580b2
commit
6e233accf5
2 changed files with 3 additions and 5 deletions
|
|
@ -7,7 +7,7 @@ const models = require('@dqbd/tiktoken/model_to_encoding.json');
|
||||||
|
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
const { arg } = req.body;
|
const { arg } = req.body;
|
||||||
console.log(typeof req.body === 'object' ? { ...req.body, ...req.query } : req.query);
|
// console.log(typeof req.body === 'object' ? { ...req.body, ...req.query } : req.query);
|
||||||
const model = await load(registry[models['gpt-3.5-turbo']]);
|
const model = await load(registry[models['gpt-3.5-turbo']]);
|
||||||
const encoder = new Tiktoken(model.bpe_ranks, model.special_tokens, model.pat_str);
|
const encoder = new Tiktoken(model.bpe_ranks, model.special_tokens, model.pat_str);
|
||||||
const tokens = encoder.encode(arg.text);
|
const tokens = encoder.encode(arg.text);
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,12 @@ function Settings(props) {
|
||||||
// useEffect to update token count
|
// useEffect to update token count
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!context) return;
|
if (!context || context.trim() === '') {
|
||||||
|
|
||||||
if (context.trim() === '') {
|
|
||||||
setTokenCount(0);
|
setTokenCount(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debouncedPost = debounce(axiosPost, 500);
|
const debouncedPost = debounce(axiosPost, 250);
|
||||||
const handleTextChange = context => {
|
const handleTextChange = context => {
|
||||||
debouncedPost({
|
debouncedPost({
|
||||||
url: '/api/tokenizer',
|
url: '/api/tokenizer',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue