Merge pull request #3162 from alexdenton123/patch-1 Update index.js
Signed| @@ -697,6 +697,11 @@ async function moduleWorker() { | ||
| 697 | 697 | return; |
| 698 | 698 | } |
| 699 | 699 | |
| 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 | + | |
| 700 | 705 | // API is busy |
| 701 | 706 | if (inApiCall) { |
| 702 | 707 | console.debug('Classification API is busy'); |
| @@ -995,6 +1000,11 @@ function sampleClassifyText(text) { | ||
| 995 | 1000 | // Replace macros, remove asterisks and quotes |
| 996 | 1001 | let result = substituteParams(text).replace(/[*"]/g, ''); |
| 997 | 1002 | |
| 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 | + | |
| 998 | 1008 | const SAMPLE_THRESHOLD = 500; |
| 999 | 1009 | const HALF_SAMPLE_THRESHOLD = SAMPLE_THRESHOLD / 2; |
| 1000 | 1010 | |