Skip to content

Commit 21f8c6c

Browse files
committed
Update AIChat component and document evaluation service
- Modified frontend AIChat component - Updated document evaluation service implementation
1 parent c533131 commit 21f8c6c

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

ai/generative-ai-service/generic_document_evaluation/frontend/src/app/components/AIChat.js

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
Fab,
2222
IconButton,
2323
Stack,
24+
Switch,
2425
TextField,
2526
ToggleButton,
2627
ToggleButtonGroup,
@@ -50,6 +51,7 @@ export default function AIChat() {
5051

5152
const [attachedFiles, setAttachedFiles] = useState([]);
5253
const [additionalInstructions, setAdditionalInstructions] = useState("");
54+
const [includeRanking, setIncludeRanking] = useState(false);
5355
const [criteriaMode, setCriteriaMode] = useState("manual");
5456
const [manualCriteria, setManualCriteria] = useState([
5557
{ key: "", value: "" },
@@ -132,7 +134,8 @@ export default function AIChat() {
132134
const evaluationResult = await evaluateDocuments(
133135
criteriaFile,
134136
criteriaJson,
135-
additionalInstructions
137+
additionalInstructions,
138+
includeRanking
136139
);
137140
console.log("Evaluation result:", evaluationResult);
138141

@@ -151,6 +154,7 @@ export default function AIChat() {
151154
const handleNew = () => {
152155
setAttachedFiles([]);
153156
setAdditionalInstructions("");
157+
setIncludeRanking(false);
154158
setManualCriteria([{ key: "", value: "" }]);
155159
setCsvFile(null);
156160
setCriteriaMode("manual");
@@ -1009,6 +1013,59 @@ This is a mock evaluation for development purposes.`;
10091013
},
10101014
}}
10111015
/>
1016+
1017+
<Box
1018+
sx={{
1019+
display: "flex",
1020+
alignItems: "center",
1021+
justifyContent: "space-between",
1022+
mt: 2,
1023+
p: 1.5,
1024+
background: (theme) => theme.palette.background.paper,
1025+
borderRadius: "12px",
1026+
}}
1027+
>
1028+
<Box
1029+
sx={{ display: "flex", alignItems: "center", gap: 0.5 }}
1030+
>
1031+
<Typography
1032+
variant="body2"
1033+
sx={{ color: (theme) => theme.palette.text.primary }}
1034+
>
1035+
Include ranking
1036+
</Typography>
1037+
<Tooltip
1038+
title="Enable this to include document ranking in the evaluation results"
1039+
placement="top"
1040+
arrow
1041+
>
1042+
<InfoOutlined
1043+
sx={{
1044+
fontSize: 16,
1045+
color: (theme) => theme.palette.text.disabled,
1046+
cursor: "pointer",
1047+
"&:hover": {
1048+
color: (theme) => theme.palette.text.secondary,
1049+
},
1050+
}}
1051+
/>
1052+
</Tooltip>
1053+
</Box>
1054+
<Switch
1055+
checked={includeRanking}
1056+
onChange={(e) => setIncludeRanking(e.target.checked)}
1057+
sx={{
1058+
"& .MuiSwitch-switchBase.Mui-checked": {
1059+
color: (theme) => theme.palette.success.main,
1060+
},
1061+
"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":
1062+
{
1063+
backgroundColor: (theme) =>
1064+
theme.palette.success.main,
1065+
},
1066+
}}
1067+
/>
1068+
</Box>
10121069
</Box>
10131070
</Stack>
10141071
)}

ai/generative-ai-service/generic_document_evaluation/frontend/src/services/documentEvaluationService.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export async function uploadDocuments(files) {
1515
export async function evaluateDocuments(
1616
criteriaFile = null,
1717
criteriaJson = null,
18-
additionalInstructions = null
18+
additionalInstructions = null,
19+
includeRanking = false
1920
) {
2021
const formData = new FormData();
2122

@@ -29,6 +30,8 @@ export async function evaluateDocuments(
2930
formData.append("additional_instruction", additionalInstructions);
3031
}
3132

33+
formData.append("include_ranking", includeRanking.toString());
34+
3235
const response = await fetch(`${API_BASE_URL}/evaluate`, {
3336
method: "POST",
3437
body: formData,

0 commit comments

Comments
 (0)