Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle error from find relevant passages #132

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/services/data-extraction/data-extraction.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,14 @@ export class DataExtractionImpl extends DataExtractionCsv<WatsonBackends, Contex
console.log('Getting relevant passage')

const relevantPassage = await axios
.post<{relevant_passage: string}>(url, {question, passages})
.then(response => response.data.relevant_passage)
.post<{relevant_passage: string} | string>(url, {question, passages})
.then(response => {
if (typeof response.data === 'string') {
throw new Error('Error retrieving data')
}

return response.data.relevant_passage
})
.catch(err => {
console.error('Error getting relevant passages: ', {err})

Expand Down Expand Up @@ -239,9 +245,9 @@ export class DataExtractionImpl extends DataExtractionCsv<WatsonBackends, Contex
parameters,
});

console.log('2. Text generated from watsonx.ai:', {prompt, modelId, max_new_tokens, generatedText: result.generatedText, input})
console.log('2. Text generated from watsonx.ai:', {prompt, modelId, max_new_tokens, generatedText: result.generatedText.trim(), input})

return {watsonxResponse: result.generatedText, prompt: input};
return {watsonxResponse: result.generatedText.trim(), prompt: input};
}

async getBackends(): Promise<WatsonBackends> {
Expand Down Expand Up @@ -286,6 +292,11 @@ export class DataExtractionImpl extends DataExtractionCsv<WatsonBackends, Contex
texts[SOURCE_KYCSUMMARY] = await this.kycSummaryService
.summarize(subject)
.then(text => text.replace(/^Output: */, ''))
.then(text => {
console.log(`KYC Summary for ${subject}: ${text}`)

return text
})
.catch(err => {
console.log('Error getting kyc summary: ', {err})

Expand Down