Merge pull request #3162 from alexdenton123/patch-1 Update index.js

050f485a5b9cdb36c4021fcd6949fc0824b1b762

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

Signed
1 files changed, +10 -0Showing whitespace changes
public/scripts/extensions/expressions/index.js+10 -0
@@ -697,6 +697,11 @@ async function moduleWorker() {
697697 return;
698698 }
699699
700+ // If using LLM api then check if streamingProcessor is finished to avoid sending multiple requests to the API
701+ if (extension_settings.expressions.api === EXPRESSION_API.llm && context.streamingProcessor && !context.streamingProcessor.isFinished) {
702+ return;
703+ }
704+
700705 // API is busy
701706 if (inApiCall) {
702707 console.debug('Classification API is busy');
@@ -995,6 +1000,11 @@ function sampleClassifyText(text) {
9951000 // Replace macros, remove asterisks and quotes
9961001 let result = substituteParams(text).replace(/[*"]/g, '');
9971002
1003+ // If using LLM api there is no need to check length of characters
1004+ if (extension_settings.expressions.api === EXPRESSION_API.llm) {
1005+ return result.trim();
1006+ }
1007+
9981008 const SAMPLE_THRESHOLD = 500;
9991009 const HALF_SAMPLE_THRESHOLD = SAMPLE_THRESHOLD / 2;
10001010