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

Support rating of LLM outputs #2659

Draft
wants to merge 2 commits into
base: llm-default-prompt
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/commons/sideContent/SideContentAutograder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ControlButton from '../ControlButton';
import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
import SideContentResultCard from './SideContentResultCard';
import SideContentTestcaseCard from './SideContentTestcaseCard';
import StarRating from './StarRating';

export type SideContentAutograderProps = DispatchProps & StateProps & OwnProps;

Expand All @@ -31,6 +32,7 @@ type OwnProps = {
const SideContentAutograder: React.FunctionComponent<SideContentAutograderProps> = props => {
const [showsTestcases, setTestcasesShown] = React.useState<boolean>(true);
const [showsResults, setResultsShown] = React.useState<boolean>(true);
const [userRating, setUserRating] = React.useState<number | null>(null);

const { testcases, autogradingResults, handleTestcaseEval, workspaceLocation } = props;

Expand Down Expand Up @@ -96,6 +98,10 @@ const SideContentAutograder: React.FunctionComponent<SideContentAutograderProps>
<Collapse isOpen={showsTestcases} keepChildrenMounted={true}>
{testcaseCards}
</Collapse>
<div className="star-rating-section">
<div className="star-rating-label">Rate the Quality of the Answer:</div>
<StarRating value={userRating || 0} onChange={setUserRating} />
</div>
{collapseButton('Autograder Results', showsResults, toggleResults)}
<Collapse isOpen={showsResults} keepChildrenMounted={true}>
{resultCards}
Expand Down
31 changes: 31 additions & 0 deletions src/commons/sideContent/StarRating.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Icon } from '@blueprintjs/core';
import React from 'react';

interface StarRatingProps {
value: number;
onChange: (rating: number) => void;
}

const StarRating: React.FC<StarRatingProps> = ({ value, onChange }) => {
const maxStars = 5;

const handleStarClick = (selectedValue: number) => {
if (onChange) {
onChange(selectedValue);
}
};

return (
<div className="star-rating">
{[...Array(maxStars)].map((_, index) => (
<Icon
key={index}
icon={value >= index + 1 ? 'star' : 'star-empty'}
onClick={() => handleStarClick(index + 1)}
/>
))}
</div>
);
};

export default StarRating;