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

Adaptation of the feedback process to include isConversationShared #9672

Merged
merged 8 commits into from
Jan 2, 2025
Merged
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
54 changes: 35 additions & 19 deletions front/components/assistant/conversation/AgentMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type {
} from "@dust-tt/types";
import {
assertNever,
GLOBAL_AGENTS_SID,
isRetrievalActionType,
isWebsearchActionType,
removeNulls,
Expand Down Expand Up @@ -94,19 +95,23 @@ export const FeedbackSelectorPopoverContent = ({

return (
agentLastAuthor && (
<div className="itemcenter mt-4 flex gap-2">
{agentLastAuthor?.image && (
<img
src={agentLastAuthor?.image}
alt={agentLastAuthor?.firstName}
className="h-8 w-8 rounded-full"
/>
)}
<div className="mb-4 mt-2 flex flex-col gap-2">
<Page.P variant="secondary">
Your feedback will be sent to:
<br />
{agentLastAuthor?.firstName} {agentLastAuthor?.lastName}
Your feedback is available to editors of the assistant. The last
assistant editor is:
</Page.P>
<div className="flex flex-row items-center gap-2">
{agentLastAuthor.image && (
<img
src={agentLastAuthor.image}
alt={agentLastAuthor.firstName}
className="h-8 w-8 rounded-full"
/>
)}
<Page.P variant="primary">
{agentLastAuthor.firstName} {agentLastAuthor.lastName}
</Page.P>
</div>
</div>
)
);
Expand Down Expand Up @@ -153,6 +158,12 @@ export function AgentMessage({
{ index: number; document: MarkdownCitation }[]
>([]);

const isGlobalAgent = useMemo(() => {
return Object.values(GLOBAL_AGENTS_SID).includes(
message.configuration.sId as GLOBAL_AGENTS_SID
);
}, [message.configuration.sId]);

const shouldStream = (() => {
if (message.status !== "created") {
return false;
Expand Down Expand Up @@ -428,14 +439,19 @@ export function AgentMessage({
className="text-muted-foreground"
disabled={isRetryHandlerProcessing || shouldStream}
/>,
<div key="separator" className="flex items-center">
<div className="h-5 w-px bg-border" />
</div>,
<FeedbackSelector
key="feedback-selector"
{...messageFeedback}
getPopoverInfo={PopoverContent}
/>,
// One cannot leave feedback on global agents.
...(isGlobalAgent
? []
: [
<div key="separator" className="flex items-center">
<div className="h-5 w-px bg-border" />
</div>,
<FeedbackSelector
key="feedback-selector"
{...messageFeedback}
getPopoverInfo={PopoverContent}
/>,
]),
];

// References logic.
Expand Down
14 changes: 9 additions & 5 deletions front/components/assistant/conversation/MessageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,31 @@ const MessageItem = React.forwardRef<HTMLDivElement, MessageItemProps>(
useSubmitFunction(
async ({
thumb,
isToRemove,
shouldRemoveExistingFeedback,
feedbackContent,
isConversationShared,
}: {
thumb: string;
isToRemove: boolean;
feedbackContent?: string | null;
shouldRemoveExistingFeedback: boolean;
feedbackContent: string | null;
isConversationShared: boolean;
}) => {
const res = await fetch(
`/api/w/${owner.sId}/assistant/conversations/${conversationId}/messages/${message.sId}/feedbacks`,
{
method: isToRemove ? "DELETE" : "POST",
method: shouldRemoveExistingFeedback ? "DELETE" : "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
thumbDirection: thumb,
feedbackContent,
isConversationShared,
}),
}
);
if (res.ok) {
if (feedbackContent && !isToRemove) {
if (feedbackContent && !shouldRemoveExistingFeedback) {
sendNotification({
title: "Feedback submitted",
description:
Expand All @@ -99,6 +102,7 @@ const MessageItem = React.forwardRef<HTMLDivElement, MessageItemProps>(
? {
thumb: messageFeedback.thumbDirection,
feedbackContent: messageFeedback.content,
isConversationShared: messageFeedback.isConversationShared,
}
: null,
onSubmitThumb,
Expand Down
9 changes: 5 additions & 4 deletions front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@auth0/nextjs-auth0": "^3.5.0",
"@dust-tt/client": "file:../sdks/js",
"@dust-tt/sparkle": "^0.2.350",
"@dust-tt/sparkle": "^0.2.351",
"@dust-tt/types": "file:../types",
"@headlessui/react": "^1.7.7",
"@heroicons/react": "^2.0.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { apiError } from "@app/logger/withlogging";
export const MessageFeedbackRequestBodySchema = t.type({
thumbDirection: t.string,
feedbackContent: t.union([t.string, t.undefined, t.null]),
isConversationShared: t.union([t.boolean, t.undefined]),
});

async function handler(
Expand Down Expand Up @@ -86,6 +87,7 @@ async function handler(
thumbDirection: bodyValidation.right
.thumbDirection as AgentMessageFeedbackDirection,
content: bodyValidation.right.feedbackContent || "",
isConversationShared: bodyValidation.right.isConversationShared,
});

if (created.isErr()) {
Expand Down
Loading