From 567745b6b1c1b831877f5d9d19d4fb3fad8bb478 Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 2 Jan 2025 11:11:43 +0100 Subject: [PATCH] Specialized fetch function (renamed), small margin added to feedbacks, more loaded at once --- .../AssistantBuilderPreviewDrawer.tsx | 10 +++++----- front/lib/api/assistant/feedback.ts | 15 +++++++++------ .../resources/agent_message_feedback_resource.ts | 10 +++++----- front/lib/swr/assistants.ts | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx b/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx index 3dc9ee42c2eb..90ce4b28f1b5 100644 --- a/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx +++ b/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx @@ -3,7 +3,6 @@ import { Button, ChatBubbleBottomCenterTextIcon, cn, - ContentMessage, DropdownMenu, DropdownMenuContent, DropdownMenuItem, @@ -50,7 +49,7 @@ import { ConfirmContext } from "@app/components/Confirm"; import { ACTION_SPECIFICATIONS } from "@app/lib/api/assistant/actions/utils"; import type { AgentMessageFeedbackWithMetadataType } from "@app/lib/api/assistant/feedback"; import { - useAgentConfigurationFeedbacks, + useAgentConfigurationFeedbacksByDescVersion, useAgentConfigurationHistory, } from "@app/lib/swr/assistants"; import { useUser } from "@app/lib/swr/user"; @@ -58,7 +57,7 @@ import { timeAgoFrom } from "@app/lib/utils"; import type { FetchAssistantTemplateResponse } from "@app/pages/api/w/[wId]/assistant/builder/templates/[tId]"; const MAX_FEEDBACKS_TO_DISPLAY = 500; -const FEEDBACKS_BATCH_SIZE = 50; +const FEEDBACKS_BATCH_SIZE = 100; interface AssistantBuilderRightPanelProps { screen: BuilderScreen; @@ -433,8 +432,9 @@ const FeedbacksSection = ({ const [feedbacks, setFeedbacks] = useState< AgentMessageFeedbackWithMetadataType[] >([]); + // Decreasing version, paginated decreasing id. const { agentConfigurationFeedbacks, isAgentConfigurationFeedbacksLoading } = - useAgentConfigurationFeedbacks({ + useAgentConfigurationFeedbacksByDescVersion({ workspaceId: owner.sId, agentConfigurationId: assistantId ?? "", withMetadata: true, @@ -536,7 +536,7 @@ const FeedbacksSection = ({ /> )} {!isNewVersion && !isFirstFeedback && ( -
+
)} diff --git a/front/lib/api/assistant/feedback.ts b/front/lib/api/assistant/feedback.ts index 49873e8da27c..e020c2ce74e7 100644 --- a/front/lib/api/assistant/feedback.ts +++ b/front/lib/api/assistant/feedback.ts @@ -198,12 +198,15 @@ export async function getAgentFeedbacks({ return new Err(new Error("agent_configuration_not_found")); } - const feedbacksRes = await AgentMessageFeedbackResource.fetch({ - workspace: owner, - agentConfiguration, - paginationParams, - withMetadata, - }); + const feedbacksRes = + await AgentMessageFeedbackResource.getAgentConfigurationFeedbacksByDescVersion( + { + workspace: owner, + agentConfiguration, + paginationParams, + withMetadata, + } + ); if (!withMetadata) { return new Ok(feedbacksRes); diff --git a/front/lib/resources/agent_message_feedback_resource.ts b/front/lib/resources/agent_message_feedback_resource.ts index f0651ab45f5c..fe977829b775 100644 --- a/front/lib/resources/agent_message_feedback_resource.ts +++ b/front/lib/resources/agent_message_feedback_resource.ts @@ -4,6 +4,7 @@ import type { ConversationError, ConversationType, ConversationWithoutContentType, + LightAgentConfigurationType, MessageType, Result, UserType, @@ -91,7 +92,7 @@ export class AgentMessageFeedbackResource extends BaseResource = { // IMPORTANT: Necessary for global models who share ids across workspaces. workspaceId: workspace.id, + agentConfigurationId: agentConfiguration.sId.toString(), }; if (paginationParams.lastValue) { @@ -115,9 +117,6 @@ export class AgentMessageFeedbackResource extends BaseResource