Skip to content

Commit

Permalink
Better message
Browse files Browse the repository at this point in the history
  • Loading branch information
philipperolet committed Oct 6, 2023
1 parent d7f5f66 commit c028160
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions front/components/assistant/conversation/RetrievalAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ export default function RetrievalAction({
? text.substring(0, maxLength) + "..."
: text;
}
// exhaustive retrieval, checks whether max chunks was reached
const tooManyChunks =
retrievalAction.documents &&
retrievalAction.documents
.map((d) => d.chunks.length)
.reduce((a, b) => a + b, 0) === topK;

// retrieval date limit given the last document's timestamp
const retrievalTsLimit =
retrievalAction.documents &&
retrievalAction.documents.length > 0 &&
retrievalAction.documents[retrievalAction.documents.length - 1].timestamp;
// turn the timestamp into a date (e.g. Oct 1st)
const date = retrievalTsLimit && new Date(retrievalTsLimit);
const retrievalDateLimit =
date &&
`${date.toLocaleString("default", {
month: "short",
})} ${date.getDate()}`;

return (
<>
Expand Down Expand Up @@ -63,18 +82,16 @@ export default function RetrievalAction({
/>
</Tooltip>
)}
{!query && // exhaustive retrieval, checks whether all documents could be read
retrievalAction.documents &&
retrievalAction.documents.length === topK && (
<Tooltip
label={`Too much data to read in one go. Only part of the data was read.`}
>
<Chip
color="warning"
label={`Too much data, retrieved only the first ${topK} documents`}
/>
</Tooltip>
)}
{!query && tooManyChunks && (
<Tooltip
label={`Too much data to retrieve in one go. Retrieved only ${topK} excerpts from the most recent ${retrievalAction.documents?.length} documents, up to ${retrievalDateLimit}`}
>
<Chip
color="warning"
label={`Warning: limited data retrieval (from now to ${retrievalDateLimit})`}
/>
</Tooltip>
)}
</Chip.List>
</div>
<div className="grid grid-cols-[auto,1fr] gap-2">
Expand Down

0 comments on commit c028160

Please sign in to comment.