Skip to content

Commit

Permalink
Update logic for data extract (#22)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund authored Sep 12, 2023
1 parent 0a040be commit 0284b1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ export class DataExtractionController {
const questionIds = (await this.service.listQuestions()).map(question => question.id)

return this.service.extractData(customer, questionIds.map(id => ({id})))
.catch(err => console.error(err))
}
}
8 changes: 5 additions & 3 deletions src/services/data-extraction/data-extraction.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,24 @@ export class DataExtractionImpl extends DataExtractionCsv<WatsonBackends> implem

console.log('1. Text extracted from Discovery:', {naturalLanguageQuery, text})

console.log(text)

return text;
}

handleDiscoveryResult(result: DiscoveryV2.QueryResponse): string {
return result.results
.map(result => result.document_passages
.map(passage => passage.passage_text)
.join('\n')
.join(' ')
)
.join('\n')
.join(' ')
}

handleDiscoveryPassages(result: DiscoveryV2.QueryResponse): string {
return result.passages
.map(passage => passage.passage_text)
.join('\n')
.join(' ')
}

async generateResponse(customer: string, config: DataExtractionConfig, text: string, backends: WatsonBackends): Promise<string> {
Expand Down

0 comments on commit 0284b1a

Please sign in to comment.