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

fixes #165

Merged
merged 1 commit into from
Oct 23, 2024
Merged

fixes #165

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
2 changes: 1 addition & 1 deletion src/app/ui/pages/chat/AnnotatePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ const AnnotatePage = () => {
model_name: response.model_name,
output: response.output,
questions_response: response.questions_response,
additional_note: response.additional_note,
})),
prompt_output_pair_id: form.prompt_output_pair_id,
additional_note: forms.additional_note,
}));
console.log("resval: " + resultValue);
} else if (ProjectDetails.project_type == "ModelInteractionEvaluation") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
AccordionDetails,
Divider,
} from "@material-ui/core";
import Spinner from "@/components/common/Spinner";

import MenuIcon from "@mui/icons-material/Menu";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import { Resizable } from "re-resizable";
Expand Down Expand Up @@ -56,6 +58,8 @@ const ModelInteractionEvaluation = ({
const { taskId } = useParams();
const classes = ModelResponseEvaluationStyle();
const [leftPanelVisible, setLeftPanelVisible] = useState(true);
const [loading, setLoading] = useState(true);

// const [selectedQuestions, setSelectedQuestions] = useState([]);
const [blank, setBlank] = useState("");
const questions =
Expand All @@ -70,6 +74,7 @@ const ModelInteractionEvaluation = ({

useEffect(() => {
const fetchData = async () => {
setLoading(true);
const taskAnnotationsObj = new GetTaskAnnotationsAPI(taskId);
const response = await fetch(taskAnnotationsObj.apiEndPoint(), {
method: "GET",
Expand Down Expand Up @@ -144,6 +149,7 @@ const ModelInteractionEvaluation = ({
}

setForms(formsData?.length ? [...formsData] : []);
setLoading(false);
};
fetchData();
}, [taskId, stage]);
Expand All @@ -158,13 +164,15 @@ const ModelInteractionEvaluation = ({

useEffect(() => {
const fetchData = async () => {
setLoading(true);
const taskDetailsObj = new GetTaskDetailsAPI(taskId);
const taskResponse = await fetch(taskDetailsObj.apiEndPoint(), {
method: "GET",
headers: taskDetailsObj.getHeaders().headers,
});
const taskData = await taskResponse.json();
setInteractions(taskData ? [...taskData.data?.interactions_json] : []);
setLoading(false);
};
fetchData();
}, [forms, taskId]);
Expand Down Expand Up @@ -625,6 +633,33 @@ const ModelInteractionEvaluation = ({
return updatedInteraction;
});
};
const styles = {
responseContainer: {
display: "flex",
gap: "20px",
flexWrap: "wrap",
},
responseBox: {
flex: "1 1 45%",
minWidth: "300px",
border: "1px solid #ccc",
fontSize: "16px",
padding: "10px",
borderRadius: "8px",
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)",
backgroundColor: "white",
},
response1Box: {
flex: "1 1 45%",
minWidth: "300px",
border: "1px solid #ccc",
padding: "10px",
fontSize: "17px",
borderRadius: "8px",
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)",
backgroundColor: "white",
},
};

const EvaluationForm = () => {
return (
Expand All @@ -633,9 +668,11 @@ const ModelInteractionEvaluation = ({
<div className={classes.heading} style={{ fontSize: "20px" }}>
{translate("modal.prompt")}
</div>
<ReactMarkdown>
{formatPrompt(currentInteraction?.prompt)}
</ReactMarkdown>
<div style={styles.response1Box}>
<ReactMarkdown>
{formatPrompt(currentInteraction?.prompt)}
</ReactMarkdown>
</div>
</div>
<div className={classes.heading} style={{ fontSize: "20px" }}>
{translate("modal.output")}
Expand All @@ -644,9 +681,11 @@ const ModelInteractionEvaluation = ({
className={classes.outputContainer}
style={{ maxHeight: "auto", overflowY: "auto" }}
>
<ReactMarkdown>
{formatPrompt(currentInteraction?.output)}
</ReactMarkdown>
<div style={styles.response1Box}>
<ReactMarkdown>
{formatPrompt(currentInteraction?.output)}
</ReactMarkdown>
</div>
</div>
{/* <div className={classes.ratingText}>
{translate("model_evaluation_rating")}
Expand Down Expand Up @@ -724,7 +763,10 @@ const ModelInteractionEvaluation = ({
<p className={classes.inputQuestion}>
{i + 1}.{" "}
{splitQuestion?.map((part, index) => (
<span key={`${i}-${index}`}>
<span
key={`${i}-${index}`}
style={{ fontSize: "18px" }}
>
{part}
{index < splitQuestion.length - 1 && (
<input
Expand Down Expand Up @@ -771,7 +813,7 @@ const ModelInteractionEvaluation = ({
return (
<div key={i}>
<div className={classes.inputQuestion}>
<span>
<span style={{ fontSize: "18px" }}>
{i + 1}. {question.input_question}
</span>
{question.mandatory && (
Expand Down Expand Up @@ -822,7 +864,10 @@ const ModelInteractionEvaluation = ({
case "multi_select_options":
return (
<div key={i}>
<div className={classes.inputQuestion}>
<div
className={classes.inputQuestion}
style={{ fontSize: "18px" }}
>
{i + 1}. {question.input_question}
{question.mandatory && (
<span style={{ color: "#d93025", fontSize: "25px" }}>
Expand Down Expand Up @@ -861,7 +906,10 @@ const ModelInteractionEvaluation = ({
case "mcq":
return (
<div key={i}>
<div className={classes.inputQuestion}>
<div
className={classes.inputQuestion}
style={{ fontSize: "18px" }}
>
{i + 1}. {question.input_question}
{question.mandatory && (
<span style={{ color: "#d93025", fontSize: "25px" }}>
Expand Down Expand Up @@ -1111,37 +1159,41 @@ const ModelInteractionEvaluation = ({

return (
<>
<div
className={classes.container}
style={{
width: "100%",
maxwidth: "2300px",
display: "flex",
flexDirection: "column",
justifyContent: "flex-start",
alignItems: "flex-start",
}}
>
<IconButton onClick={toggleLeftPanel}>
<MenuIcon />
</IconButton>
<div className={classes.leftPanel}>
{leftPanelVisible && <InteractionDisplay />}
</div>
{loading ? (
<Spinner />
) : (
<div
className={classes.container}
style={{
width: "100%",
maxwidth: "2300px",
display: "flex",
flexDirection: "column",
justifyContent: "flex-start",
alignItems: "flex-start",
}}
>
<IconButton onClick={toggleLeftPanel}>
<MenuIcon />
</IconButton>
<div className={classes.leftPanel}>
{leftPanelVisible && <InteractionDisplay />}
</div>

{leftPanelVisible && (
<Divider
variant="middle"
style={{
width: "95%",
margin: "0 2rem 0 2rem",
backgroundColor: "black",
}}
/>
)}
{leftPanelVisible && (
<Divider
variant="middle"
style={{
width: "95%",
margin: "0 2rem 0 2rem",
backgroundColor: "black",
}}
/>
)}

{EvaluationForm()}
</div>
{EvaluationForm()}
</div>
)}
</>
);
};
Expand Down
Loading
Loading