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

Btns #205

Merged
merged 2 commits into from
Jan 1, 2025
Merged

Btns #205

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
20 changes: 11 additions & 9 deletions src/app/ui/pages/chat/AnnotatePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ console.log(output,"kk");
setShowNotes(false);
return;
}
else if(chatHistory.length==0) {
else if(ProjectDetails.project_type == "InstructionDrivenChat"&&chatHistory.length==0) {
console.log(chatHistory);

setSnackbarInfo({
Expand Down Expand Up @@ -509,11 +509,14 @@ console.log(output,"kk");
}
}
value === "delete"
? setSnackbarInfo({
open: true,
message: "Chat history has been cleared successfully!",
variant: "success",
})
? (setSnackbarInfo({
open: true,
message: "Chat history has been cleared successfully!",
variant: "success",
}),
setChatHistory([{}]),
setCurrentInteraction({})
)
: value === "delete-pair"
? setSnackbarInfo({
open: true,
Expand All @@ -525,6 +528,7 @@ console.log(output,"kk");
message: resp?.message,
variant: "success",
});
setLoading(false);
} else {
setAutoSave(true);
setSnackbarInfo({
Expand Down Expand Up @@ -718,9 +722,7 @@ console.log(output,"kk");
case "InstructionDrivenChat":
componentToRender = (
<InstructionDrivenChatPage
key={`annotations-${annotations?.length}-${
annotations?.[0]?.id || "default"
}`}
key={`annotations-${annotations?.length}-${new Date().getTime()}`}
handleClick={handleAnnotationClick}
chatHistory={chatHistory}
setChatHistory={setChatHistory}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ const ModelInteractionEvaluation = ({
const handleReset = () => {
setCurrentInteraction((prev) => ({
...prev,
// rating: null,
questions_response: Array(questions?.length).fill(null),
}));
};

const parsedForms = useMemo(() => {
if (annotation && annotation[0]?.result) {
console.log("kek",annotation[0]);

const result = annotation[0].result;
return Array.isArray(result)
? result.map((item) => ({
Expand All @@ -106,7 +107,6 @@ const ModelInteractionEvaluation = ({
},
];
}
console.log("jack","1");

return [];
}, [annotation,taskId]);
Expand All @@ -128,17 +128,17 @@ const ModelInteractionEvaluation = ({
} catch (error) {
console.error("Error fetching interactions:", error);
}
console.log("jack","2");

}, [taskId]);
}, [annotation,taskId]);

useEffect(() => {
fetchInteractions();
}, [fetchInteractions]);

useEffect(() => {
if (forms?.length > 0 && interactions?.length > 0) {
const defaultFormId = forms[0]?.prompt_output_pair_id;
if (forms?.length > 0 && interactions?.length > 0 && !currentInteraction?.prompt) {

const defaultFormId = forms[0]?.prompt_output_pair_id; ;
const currentForm = forms.find(
(form) => form?.prompt_output_pair_id === defaultFormId
);
Expand All @@ -159,9 +159,8 @@ const ModelInteractionEvaluation = ({
setCurrentInteraction(newState);
}
}
console.log("jack","3");

}, [forms, interactions, setCurrentInteraction, questions?.length]);
}, [forms, interactions, questions,annotation,setForms]);

useEffect(() => {
if (forms?.length == 0 && interactions?.length > 0) {
Expand All @@ -177,9 +176,8 @@ const ModelInteractionEvaluation = ({
}));
setForms(initialForms);
}
console.log("jack","4");

}, [forms, interactions, setForms, questions]);
}, [forms, interactions, setForms, questions,annotation]);

useEffect(() => {
if (!forms || forms.length == 0) {
Expand Down Expand Up @@ -235,11 +233,12 @@ const ModelInteractionEvaluation = ({
}, [forms, taskId]);

const handleRating = (rating, interactionIndex) => {
setCurrentInteraction((prev) => {

setCurrentInteraction((prev) => {
const selectedQuestion = questions[interactionIndex];
const ratingArray = [String(rating)];
// const ratingScaleList = selectedQuestion?.rating_scale_list;
const updatedQuestionsResponse = prev.questions_response.map(
const updatedQuestionsResponse = prev.questions_response?.map(
(q, index) => {
if (index === interactionIndex) {
return {
Expand Down Expand Up @@ -270,7 +269,7 @@ const ModelInteractionEvaluation = ({
const answerArray = [String(selectedOption)];

setCurrentInteraction((prev) => {
const updatedQuestionsResponse = prev.questions_response.map(
const updatedQuestionsResponse = prev.questions_response?.map(
(q, index) => {
if (index == interactionIndex) {
return {
Expand Down Expand Up @@ -306,7 +305,7 @@ const ModelInteractionEvaluation = ({
);

setCurrentInteraction((prev) => {
const updatedQuestionsResponse = prev.questions_response.map(
const updatedQuestionsResponse = prev.questions_response?.map(
(q, index) => {
if (index === interactionIndex) {
const updatedAnswers = isChecked
Expand Down Expand Up @@ -370,9 +369,6 @@ const ModelInteractionEvaluation = ({
});
};

console.log(currentInteraction);
console.log(interactions);
console.log(forms);

const handleNoteChange = (event) => {
const newNote = event.target.value;
Expand Down Expand Up @@ -521,7 +517,7 @@ const ModelInteractionEvaluation = ({
const { value } = e.target;

setCurrentInteraction((prev) => {
const updatedQuestionsResponse = prev.questions_response.map(
const updatedQuestionsResponse = prev.questions_response?.map(
(q, index) => {
if (index === interactionIndex) {
const updatedBlankAnswers = q?.response ? [...q?.response] : [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const PreferenceRanking = ({
}
console.log("jack", "4");

}, [forms, interactions, setCurrentInteraction, questions?.length]);
}, [forms, interactions, questions?.length]);
useEffect(() => {
if (!forms || forms.length === 0) {
setAnswered(false);
Expand Down
11 changes: 11 additions & 0 deletions src/components/common/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,17 @@ const handleopenproject=(id,type)=>{
};

const tabs = [
loggedInUserData?.guest_user ? <Typography variant="body1">
<NavLink
to="/guest_workspaces"
className={({ isActive }) =>
isActive ? classes.highlightedMenu : classes.headerMenu
}
activeClassName={classes.highlightedMenu}
>
Guest Workspaces
</NavLink>
</Typography> : null,
<Typography key={1} variant="body1">
<NavLink
hidden={
Expand Down
Loading