From 1f4a65675564b034f2d9c349424840cac3db03cf Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Thu, 26 Oct 2023 11:30:26 -0500 Subject: [PATCH 1/2] Reduce find relevant passage concurrent requests to 2 Signed-off-by: Sean Sundberg --- src/services/data-extraction/data-extraction.impl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/data-extraction/data-extraction.impl.ts b/src/services/data-extraction/data-extraction.impl.ts index 35e795d..b19ab04 100644 --- a/src/services/data-extraction/data-extraction.impl.ts +++ b/src/services/data-extraction/data-extraction.impl.ts @@ -14,7 +14,7 @@ import {first, GenAiModel, GenerativeResponse} from "../../utils"; import pQueue from '../../utils/p-queue' import PQueue from "../../utils/p-queue"; -const queue = new PQueue({concurrency: 4}); +const queue = new PQueue({concurrency: 2}); export interface DataExtractionBackendConfig { identityUrl: string; From c2c95ed912132205b219c7730b8f4e69d40d8cfb Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Thu, 26 Oct 2023 11:09:30 -0500 Subject: [PATCH 2/2] Update llm error handling for data extract Signed-off-by: Sean Sundberg --- .../data-extraction/data-extraction.impl.ts | 25 +++++++++++++++---- src/utils/gen-ai-model.ts | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/services/data-extraction/data-extraction.impl.ts b/src/services/data-extraction/data-extraction.impl.ts index b19ab04..83d10e7 100644 --- a/src/services/data-extraction/data-extraction.impl.ts +++ b/src/services/data-extraction/data-extraction.impl.ts @@ -219,11 +219,26 @@ export class DataExtractionImpl extends DataExtractionCsv { + if (result?.generatedText?.trim()) { + return result + } + + const fallbackModelId: string = 'meta-llama/llama-2-70b-chat' + console.log(`*** No information returned from generate. Trying again with ${fallbackModelId} model`) + + return backends.wml.generate({ + input, + modelId: fallbackModelId, + parameters, + }) + }); console.log('2. Text generated from watsonx.ai:', {prompt, modelId, max_new_tokens, generatedText: result.generatedText, input}) diff --git a/src/utils/gen-ai-model.ts b/src/utils/gen-ai-model.ts index 9608ad9..315bf3a 100644 --- a/src/utils/gen-ai-model.ts +++ b/src/utils/gen-ai-model.ts @@ -91,7 +91,7 @@ export class GenAiModel { } console.log('Error generating text: ', err); - throw err; + return {generatedText: '[Error]'} }) } } \ No newline at end of file