Skip to content

Commit d74a757

Browse files
authored
Revert "[AAQ-577] Playground feedback (#285)" (#292)
This reverts commit 65a42a2.
1 parent 65a42a2 commit d74a757

File tree

4 files changed

+11
-170
lines changed

4 files changed

+11
-170
lines changed

admin_app/src/app/integrations/components/ChatManagerCard.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const ChatManagerCard: React.FC<ChatManagerCardInfo> = ({ logo_src, name }) => (
1212
justifyContent: "center",
1313
alignItems: "center",
1414
display: "flex",
15-
cursor: "pointer",
1615
}}
1716
>
1817
<CardContent

admin_app/src/app/playground/components/PlaygroundComponents.tsx

+10-96
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@ import PersonIcon from "@mui/icons-material/Person";
2424
import SendIcon from "@mui/icons-material/Send";
2525
import AutoAwesomeIcon from "@mui/icons-material/AutoAwesome";
2626
import TextField from "@mui/material/TextField";
27-
import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt";
28-
import ThumbUpOffAltIcon from "@mui/icons-material/ThumbUpOffAlt";
29-
import ThumbDownAltIcon from "@mui/icons-material/ThumbDownAlt";
30-
import ThumbDownOffAltIcon from "@mui/icons-material/ThumbDownOffAlt";
3127

3228
type QueryType = "embeddings-search" | "llm-response" | "urgency-detection";
3329

34-
type FeedbackSentimentType = "positive" | "negative";
35-
3630
interface ResponseSummary {
3731
index: string;
3832
title: string;
@@ -233,19 +227,8 @@ const MessageSkeleton = () => {
233227
);
234228
};
235229

236-
const MessageBox = ({
237-
message,
238-
onFeedbackSend,
239-
}: {
240-
message: Message;
241-
onFeedbackSend: (
242-
message: ResponseMessage,
243-
feedbackSentiment: FeedbackSentimentType,
244-
) => void;
245-
}) => {
230+
const MessageBox = (message: Message) => {
246231
const [open, setOpen] = useState(false);
247-
const [thumbsUp, setThumbsUp] = useState(false);
248-
const [thumbsDown, setThumbsDown] = useState(false);
249232

250233
const renderResults = (content: ResponseSummary[]) => {
251234
return content.map((c: ResponseSummary) => (
@@ -257,38 +240,6 @@ const MessageBox = ({
257240
</Box>
258241
));
259242
};
260-
const handlePositiveFeedback = (
261-
event: React.MouseEvent<HTMLButtonElement>,
262-
) => {
263-
if (thumbsUp) {
264-
console.log("Already sent positive feedback");
265-
} else {
266-
setThumbsUp(true);
267-
return onFeedbackSend(
268-
message as ResponseMessage,
269-
"positive" as FeedbackSentimentType,
270-
);
271-
}
272-
};
273-
const handleNegativeFeedback = (
274-
event: React.MouseEvent<HTMLButtonElement>,
275-
) => {
276-
if (thumbsDown) {
277-
console.log("Already sent negative feedback");
278-
} else {
279-
setThumbsDown(true);
280-
return onFeedbackSend(
281-
message as ResponseMessage,
282-
"negative" as FeedbackSentimentType,
283-
);
284-
}
285-
};
286-
const feedbackButtonStyle = {
287-
background: "none",
288-
border: "none",
289-
cursor: "pointer",
290-
};
291-
292243
const toggleJsonModal = () => setOpen(!open);
293244
const modalStyle = {
294245
position: "absolute",
@@ -304,7 +255,6 @@ const MessageBox = ({
304255
overflow: "scroll",
305256
borderRadius: "10px",
306257
};
307-
308258
return (
309259
<Box
310260
sx={{
@@ -360,51 +310,16 @@ const MessageBox = ({
360310
? message.content
361311
: renderResults(message.content)}
362312
</Typography>
363-
{message.type == "response" && (
364-
<Box
365-
style={{
366-
marginTop: "5px",
367-
display: "flex",
368-
justifyContent: "flex-end",
369-
alignItems: "center",
370-
}}
313+
{message.hasOwnProperty("json") && (
314+
<Link
315+
onClick={toggleJsonModal}
316+
variant="caption"
317+
align="right"
318+
underline="hover"
319+
sx={{ cursor: "pointer" }}
371320
>
372-
{message.json.hasOwnProperty("feedback_secret_key") && (
373-
<Box sx={{ marginRight: "8px" }}>
374-
<IconButton
375-
aria-label="thumbs up"
376-
onClick={handlePositiveFeedback}
377-
style={feedbackButtonStyle}
378-
>
379-
{thumbsUp ? (
380-
<ThumbUpAltIcon fontSize="small" />
381-
) : (
382-
<ThumbUpOffAltIcon fontSize="small" />
383-
)}
384-
</IconButton>
385-
<IconButton
386-
aria-label="thumbs down"
387-
onClick={handleNegativeFeedback}
388-
style={feedbackButtonStyle}
389-
>
390-
{thumbsDown ? (
391-
<ThumbDownAltIcon fontSize="small" />
392-
) : (
393-
<ThumbDownOffAltIcon fontSize="small" />
394-
)}
395-
</IconButton>
396-
</Box>
397-
)}
398-
<Link
399-
onClick={toggleJsonModal}
400-
variant="caption"
401-
align="right"
402-
underline="hover"
403-
sx={{ cursor: "pointer" }}
404-
>
405-
{"<json>"}
406-
</Link>
407-
</Box>
321+
{"<json>"}
322+
</Link>
408323
)}
409324
</Box>
410325

@@ -478,7 +393,6 @@ export { ErrorSnackBar, MessageBox, MessageSkeleton, PersistentSearchBar };
478393
export type {
479394
Message,
480395
QueryType,
481-
FeedbackSentimentType,
482396
ResponseMessage,
483397
ResponseSummary,
484398
UserMessage,

admin_app/src/app/playground/page.tsx

+1-44
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import {
1212
MessageSkeleton,
1313
PersistentSearchBar,
1414
QueryType,
15-
FeedbackSentimentType,
1615
ResponseSummary,
1716
UserMessage,
18-
ResponseMessage,
1917
} from "./components/PlaygroundComponents";
2018
import { Box } from "@mui/material";
2119
import { useAuth } from "@/utils/auth";
@@ -204,42 +202,6 @@ const Page = () => {
204202
}
205203
}
206204
};
207-
208-
const sendResponseFeedback = (
209-
message: ResponseMessage,
210-
feedback_sentiment: FeedbackSentimentType,
211-
) => {
212-
if (token) {
213-
// Assuming message.json is a JSON string. Parse it if necessary.
214-
const jsonResponse =
215-
typeof message.json === "string"
216-
? JSON.parse(message.json)
217-
: message.json;
218-
219-
const queryID = jsonResponse.query_id;
220-
const feedbackSecretKey = jsonResponse.feedback_secret_key;
221-
222-
apiCalls
223-
.postResponseFeedback(
224-
queryID,
225-
feedback_sentiment,
226-
feedbackSecretKey,
227-
token,
228-
)
229-
.then((response) => {
230-
if (response.status === 200) {
231-
console.log("Feedback sent successfully");
232-
} else {
233-
console.error(response);
234-
}
235-
})
236-
.catch((error: Error) => {
237-
setError("Failed to send response feedback.");
238-
console.error(error);
239-
});
240-
}
241-
};
242-
243205
const handleErrorClose = (
244206
event?: React.SyntheticEvent | Event,
245207
reason?: string,
@@ -249,7 +211,6 @@ const Page = () => {
249211
}
250212
setError(null);
251213
};
252-
253214
return (
254215
<>
255216
<Global
@@ -276,11 +237,7 @@ const Page = () => {
276237
}}
277238
>
278239
{messages.map((message, index) => (
279-
<MessageBox
280-
key={index}
281-
message={message}
282-
onFeedbackSend={sendResponseFeedback}
283-
/>
240+
<MessageBox key={index} {...message} />
284241
))}
285242
{loading && <MessageSkeleton />}
286243
<div ref={bottomRef} />

admin_app/src/utils/api.ts

-29
Original file line numberDiff line numberDiff line change
@@ -314,34 +314,6 @@ const getLLMResponse = async (search: string, token: string) => {
314314
});
315315
};
316316

317-
const postResponseFeedback = async (
318-
query_id: number,
319-
feedback_sentiment: string,
320-
feedback_secret_key: string,
321-
token: string,
322-
) => {
323-
const feedbackUrl = `${NEXT_PUBLIC_BACKEND_URL}/response-feedback`;
324-
return fetch(feedbackUrl, {
325-
method: "POST",
326-
headers: {
327-
"Content-Type": "application/json",
328-
Authorization: `Bearer ${token}`,
329-
},
330-
body: JSON.stringify({
331-
query_id: query_id,
332-
feedback_sentiment: feedback_sentiment,
333-
feedback_secret_key: feedback_secret_key,
334-
}),
335-
}).then((response) => {
336-
if (response.ok) {
337-
let resp = response.json();
338-
return resp;
339-
} else {
340-
throw new Error("Error sending response feedback");
341-
}
342-
});
343-
};
344-
345317
const getQuestionStats = async (token: string) => {
346318
return fetch(`${NEXT_PUBLIC_BACKEND_URL}/dashboard/question_stats`, {
347319
method: "GET",
@@ -456,7 +428,6 @@ export const apiCalls = {
456428
getGoogleLoginToken,
457429
getEmbeddingsSearch,
458430
getLLMResponse,
459-
postResponseFeedback,
460431
getQuestionStats,
461432
getUrgencyDetection,
462433
createTag,

0 commit comments

Comments
 (0)