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

Fix paginated chunk numbering #175

Merged
merged 1 commit into from
Jan 29, 2025
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
12 changes: 7 additions & 5 deletions src/components/ChatDemo/utils/documentDialogInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ const DocumentInfoDialog: React.FC<DocumentInfoDialogProps> = ({
<ExpandableDocumentChunks
chunks={currentChunks}
onChunkDeleted={refreshChunks}
currentPage={chunksCurrentPage}
pageSize={10}
/>
{chunksLoading && (
<Loader className="mx-auto mt-4 animate-spin" size={32} />
Expand Down Expand Up @@ -504,7 +506,9 @@ const ExpandableInfoRow: React.FC<{
const ExpandableDocumentChunks: React.FC<{
chunks: ChunkResponse[] | undefined;
onChunkDeleted?: () => void;
}> = ({ chunks, onChunkDeleted }) => {
currentPage?: number;
pageSize?: number;
}> = ({ chunks, onChunkDeleted, currentPage = 1, pageSize = 10 }) => {
const [allExpanded, setAllExpanded] = useState(false);

const toggleAllExpanded = () => {
Expand All @@ -530,7 +534,7 @@ const ExpandableDocumentChunks: React.FC<{
<ExpandableChunk
key={index}
chunk={chunk}
index={index}
index={(currentPage - 1) * pageSize + index}
isExpanded={allExpanded}
onDelete={onChunkDeleted}
/>
Expand Down Expand Up @@ -595,14 +599,12 @@ const ExpandableChunk: React.FC<{
throw new Error('Failed to get authenticated client');
}

// FIXME: Pretty sure this is wrong! It needs the chunk ID, not the document ID
await client.chunks.update({
id: chunk.id, // Corrected to use chunk.id
id: chunk.id,
text: editText,
metadata: chunk.metadata,
});
setIsEditing(false);
// Optionally, refresh chunks
onDelete?.();
} catch (error) {
console.error('Error updating chunk:', error);
Expand Down