Skip to content

Commit

Permalink
Memoize extra agent configurations. (#3068)
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd authored Jan 4, 2024
1 parent 091e62d commit 4c98bb9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions front/components/assistant/conversation/input_bar/InputBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Fragment,
useContext,
useEffect,
useMemo,
useState,
} from "react";
import { mutate } from "swr";
Expand Down Expand Up @@ -68,15 +69,15 @@ export function AssistantInputBar({
workspaceId: owner.sId,
agentsGetView: conversationId ? { conversationId } : "list",
});
const agentConfigurationsToAdd = additionalAgentConfigurations
? additionalAgentConfigurations.filter(
(a) => !baseAgentConfigurations.find((b) => a.sId === b.sId)
)
: [];
const agentConfigurations = [
...baseAgentConfigurations,
...agentConfigurationsToAdd,
];

const agentConfigurations = useMemo(() => {
const agentConfigurationsToAdd = additionalAgentConfigurations
? additionalAgentConfigurations.filter(
(a) => !baseAgentConfigurations.find((b) => a.sId === b.sId)
)
: [];
return [...baseAgentConfigurations, ...agentConfigurationsToAdd];
}, [baseAgentConfigurations, additionalAgentConfigurations]);

const sendNotification = useContext(SendNotificationsContext);

Expand Down

0 comments on commit 4c98bb9

Please sign in to comment.