| | |
| | | }; |
| | | |
| | | const checkIsText = (item) => { |
| | | const isText = item?.content?.values?.some((item) => item?.content?.type === AnswerType.Knowledge) || item?.conclusion?.length > 0; |
| | | const isText = |
| | | item?.content?.values?.some((item) => item?.content?.type === AnswerType.Knowledge || item?.conclusion?.length > 0) || |
| | | item?.conclusion?.length > 0; |
| | | return isText; |
| | | }; |
| | | |
| | | const getPlainText = (item) => { |
| | | let result = ''; |
| | | const knowledgeText = item.content.values |
| | | .filter((item) => { |
| | | const type = item?.content?.type; |
| | | return type === AnswerType.Knowledge; |
| | | }) |
| | | |
| | | .reduce((acc, cur) => { |
| | | const answer = cur?.content?.values |
| | | ?.map((item) => { |
| | | const mdText = item.answer; |
| | | const linkText = item.metadata?.Title; |
| | | if (linkText) { |
| | | return `${mdText}\n\n${linkText}`; |
| | | } |
| | | return mdText; |
| | | }) |
| | | .join('\n\n'); |
| | | return acc + answer; |
| | | const conclusionText = |
| | | cur.conclusion |
| | | ?.filter((cur) => !!cur.report) |
| | | .map((cur) => cur.report) |
| | | .join('\n\n') ?? ''; |
| | | acc += conclusionText; |
| | | if (cur?.content?.type === AnswerType.Knowledge) { |
| | | const answer = cur?.content?.values |
| | | ?.map((item) => { |
| | | const mdText = item.answer; |
| | | const linkText = item.metadata?.Title; |
| | | if (linkText) { |
| | | return `${mdText}\n\n${linkText}`; |
| | | } |
| | | return mdText; |
| | | }) |
| | | .join('\n\n'); |
| | | |
| | | acc += answer; |
| | | } |
| | | |
| | | return acc; |
| | | }, ''); |
| | | |
| | | const conclusionText = |