Skip to content

Commit

Permalink
[Security GenAI] KB index entry created via pdf upload does not give …
Browse files Browse the repository at this point in the history
…the right response
  • Loading branch information
e40pud committed Oct 28, 2024
1 parent 962f731 commit a8252fd
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ export const getStructuredToolForIndexEntry = ({
return { ...prev, [field]: hit._source[field] };
}, {});
}

// We want to send relevant inner hits (chunks) to the LLM as a context
const innerHitPath = `${indexEntry.name}.${indexEntry.field}`;
if (hit.inner_hits?.[innerHitPath]) {
return {
text: hit.inner_hits[innerHitPath].hits.hits
.map((innerHit) => innerHit._source.text)
.join('\n --- \n'),
};
}

return {
text: get(hit._source, `${indexEntry.field}.inference.chunks[0].text`),
};
Expand Down

0 comments on commit a8252fd

Please sign in to comment.