Skip to content

Commit

Permalink
pass doc version
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Fontanier committed Nov 28, 2024
1 parent f2fce82 commit 7fffbe7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
8 changes: 6 additions & 2 deletions front/components/assistant/conversation/AgentMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type {
RetrievalActionType,
UserType,
WebsearchActionType,
WithRank,
WorkspaceType,
} from "@dust-tt/types";
import {
Expand Down Expand Up @@ -85,7 +86,7 @@ interface AgentMessageProps {
conversationId: string;
isInModal: boolean;
isLastMessage: boolean;
message: AgentMessageType;
message: WithRank<AgentMessageType>;
messageFeedback: ConversationMessageFeedbackSelectorProps;
owner: WorkspaceType;
user: UserType;
Expand Down Expand Up @@ -458,7 +459,10 @@ export function AgentMessage({
conversationId,
message.sId
),
doc: getInteractiveDocumentPlugin(agentConfiguration.sId, message.sId),
doc: getInteractiveDocumentPlugin(
agentConfiguration.sId,
`${message.rank}.${message.version}`
),
sup: CiteBlock,
mention: MentionBlock,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
MessageWithContentFragmentsType,
UserMessageNewEvent,
UserType,
WithRank,
WorkspaceType,
} from "@dust-tt/types";
import { isContentFragmentType } from "@dust-tt/types";
Expand Down Expand Up @@ -377,8 +378,8 @@ export default ConversationViewer;
*/
const groupMessagesByType = (
messages: FetchConversationMessagesResponse[]
): MessageWithContentFragmentsType[][] => {
const groupedMessages: MessageWithContentFragmentsType[][] = [];
): WithRank<MessageWithContentFragmentsType>[][] => {
const groupedMessages: WithRank<MessageWithContentFragmentsType>[][] = [];
let tempContentFragments: ContentFragmentType[] = [];

messages
Expand All @@ -387,7 +388,7 @@ const groupMessagesByType = (
if (isContentFragmentType(message)) {
tempContentFragments.push(message); // Collect content fragments.
} else {
let messageWithContentFragments: MessageWithContentFragmentsType;
let messageWithContentFragments: WithRank<MessageWithContentFragmentsType>;
if (isUserMessageType(message)) {
// Attach collected content fragments to the user message.
messageWithContentFragments = {
Expand Down
3 changes: 2 additions & 1 deletion front/components/assistant/conversation/MessageGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
FetchConversationMessagesResponse,
MessageWithContentFragmentsType,
UserType,
WithRank,
WorkspaceType,
} from "@dust-tt/types";
import React, { useEffect, useRef } from "react";
Expand All @@ -10,7 +11,7 @@ import MessageItem from "@app/components/assistant/conversation/MessageItem";
import type { AgentMessageFeedbackType } from "@app/lib/api/assistant/feedback";

interface MessageGroupProps {
messages: MessageWithContentFragmentsType[];
messages: WithRank<MessageWithContentFragmentsType>[];
isLastMessageGroup: boolean;
conversationId: string;
feedbacks: AgentMessageFeedbackType[];
Expand Down
3 changes: 2 additions & 1 deletion front/components/assistant/conversation/MessageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useSendNotification } from "@dust-tt/sparkle";
import type {
MessageWithContentFragmentsType,
UserType,
WithRank,
WorkspaceType,
} from "@dust-tt/types";
import { isSupportedImageContentType } from "@dust-tt/types";
Expand All @@ -23,7 +24,7 @@ interface MessageItemProps {
messageFeedback: AgentMessageFeedbackType | undefined;
isInModal: boolean;
isLastMessage: boolean;
message: MessageWithContentFragmentsType;
message: WithRank<MessageWithContentFragmentsType>;
owner: WorkspaceType;
user: UserType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ export interface CoEditionContextType {
agentConfigurationId,
code,
complete,
version,
}: {
agentConfigurationId: string;
code: string;
complete: boolean;
version: string;
}
) => void;
clear: () => void;
Expand Down
6 changes: 5 additions & 1 deletion front/components/markdown/VisualizationBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export function getVisualizationPlugin(
return VisualizationPlugin;
}

export function getInteractiveDocumentPlugin(agentConfigurationId: string) {
export function getInteractiveDocumentPlugin(
agentConfigurationId: string,
version: string
) {
const makeCustomRenderer = (actions: CoEditionContextType["actions"]) => {
return {
doc: (
Expand All @@ -152,6 +155,7 @@ export function getInteractiveDocumentPlugin(agentConfigurationId: string) {
agentConfigurationId,
code,
complete,
version,
});
}}
icon={EyeIcon}
Expand Down

0 comments on commit 7fffbe7

Please sign in to comment.