diff --git a/src/services/data-extraction/data-extraction.impl.ts b/src/services/data-extraction/data-extraction.impl.ts index 35e795d..7c53e1d 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