Skip to content

Commit

Permalink
updated FCS UI (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeelehsan authored Nov 8, 2024
1 parent 052feb7 commit b2e9110
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/views/search/SummaryUx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const SummaryUx = () => {

<VuiSpacer size="s" />

{(fcsMode !== "disable" && factualConsistencyScore !== 0) && (
{(fcsMode !== "disable") && (
<FactualConsistencyBadge
score={factualConsistencyScore}
fcsMode={fcsMode}
Expand Down
67 changes: 30 additions & 37 deletions src/views/search/summary/FactualConsistencyBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,39 @@ const getConfidenceLevel = (score: number): ConfidenceLevel => {
return "high";
};
export const FactualConsistencyBadge = ({ score, fcsMode }: Props) => {
let badge;
const [isHemDrawerOpen, setIsHemDrawerOpen] = useState(false);
if (score !== undefined) {
// badge = <VuiBadge color="accent">Calculating Factual Consistency Score…</VuiBadge>;
const sanitizedScore = parseFloat(score.toFixed(2));
badge = (
<VuiBadge color={"neutral" as "neutral" | "warning" | "success" | "danger"}>
Factual Consistency Score: {sanitizedScore}
</VuiBadge>
);
const sanitizedScore = score ? parseFloat(score.toFixed(2)) : "unavailable";
const badge = (
<VuiBadge color={"neutral" as "neutral" | "warning" | "success" | "danger"}>
Factual Consistency Score: {sanitizedScore}
</VuiBadge>
);

return (
<>
<VuiFlexContainer alignItems="center" data-testid="factualConsistencyBadge">
{/*{score === undefined && <VuiSpinner size="s" />}*/}
<VuiFlexItem>
{
fcsMode === "badge" ? <ConfidenceBadge confidenceLevel={getConfidenceLevel(score ?? -1)} />
: badge
}
</VuiFlexItem>
<VuiFlexItem grow={false} shrink={false}>
<VuiLinkInternal
onClick={() => setIsHemDrawerOpen(true)}
>
What's this?
</VuiLinkInternal>
</VuiFlexItem>
</VuiFlexContainer>
<HemDrawer
isOpen={isHemDrawerOpen}
onClose={() => setIsHemDrawerOpen(false)}
/>
</>
return (
<>
<VuiFlexContainer alignItems="center" data-testid="factualConsistencyBadge">
{/*{score === undefined && <VuiSpinner size="s" />}*/}
<VuiFlexItem>
{
fcsMode === "badge" ? <ConfidenceBadge confidenceLevel={getConfidenceLevel(score ?? -1)} />
: badge
}
</VuiFlexItem>
<VuiFlexItem grow={false} shrink={false}>
<VuiLinkInternal
onClick={() => setIsHemDrawerOpen(true)}
>
What's this?
</VuiLinkInternal>
</VuiFlexItem>
</VuiFlexContainer>
<HemDrawer
isOpen={isHemDrawerOpen}
onClose={() => setIsHemDrawerOpen(false)}
/>
</>

);
}
);

else {
return <></>
}

};

0 comments on commit b2e9110

Please sign in to comment.