Skip to content

Commit

Permalink
Incoporated reasoning into frontend correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
markbotterill committed Nov 8, 2024
1 parent 2a05c65 commit dd76167
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions frontend/src/components/MatchesList.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// src/components/MatchesList.tsx

import React from 'react';
import { MatchedQAPair } from '../interfaces';
import { MatchedChunk, MatchedQAPair } from '../interfaces';

interface MatchesListProps {
matches: MatchedQAPair[]; // Assuming all matches have 'question' and 'answer'
matches: (MatchedChunk | MatchedQAPair)[];
onMatchClick: (pageNumber: number) => void;
}

// Type guard to check if a match is of type MatchedChunk
const isMatchedChunk = (match: MatchedChunk | MatchedQAPair): match is MatchedChunk => {
return (match as MatchedChunk).explanation !== undefined;
};

const MatchesList: React.FC<MatchesListProps> = ({
matches,
onMatchClick,
Expand All @@ -30,7 +33,15 @@ const MatchesList: React.FC<MatchesListProps> = ({
<strong>
Rank {match.rank}, Page {match.page_number}:
</strong>{' '}
{match.question}
{/* Use type guard to check if match is MatchedChunk */}
{isMatchedChunk(match) ? (
<p>{match.explanation}</p>
) : (
<>
<p><strong>Question:</strong> {match.question}</p>
<p><strong>Answer:</strong> {match.answer}</p>
</>
)}
</button>
</li>
))}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/SearchResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface SearchResultCardProps {
}

const SearchResultCard: FC<SearchResultCardProps> = ({ result, onClick, isSelected, precisionSearch }) => {
const matchType = precisionSearch ? 'QA Matches' : 'Page Matches';
const matchType = precisionSearch ? 'Matches' : 'Matches';

return (
<div
Expand Down

0 comments on commit dd76167

Please sign in to comment.