diff --git a/front/components/assistant/conversation/AgentSuggestion.tsx b/front/components/assistant/conversation/AgentSuggestion.tsx index 2e916f3d825c..eecd36b81397 100644 --- a/front/components/assistant/conversation/AgentSuggestion.tsx +++ b/front/components/assistant/conversation/AgentSuggestion.tsx @@ -26,7 +26,7 @@ export function AgentSuggestion({ }: AgentSuggestionProps) { const { agentConfigurations } = useAgentConfigurations({ workspaceId: owner.sId, - agentsGetView: { conversationId: conversationId }, + agentsGetView: "list", includes: ["authors", "usage"], }); const sendNotification = useContext(SendNotificationsContext); diff --git a/front/components/assistant/conversation/input_bar/InputBar.tsx b/front/components/assistant/conversation/input_bar/InputBar.tsx index c9db4b9eb596..563a48b498a4 100644 --- a/front/components/assistant/conversation/input_bar/InputBar.tsx +++ b/front/components/assistant/conversation/input_bar/InputBar.tsx @@ -79,7 +79,7 @@ export function AssistantInputBar({ const { agentConfigurations: baseAgentConfigurations } = useAgentConfigurations({ workspaceId: owner.sId, - agentsGetView: "assistants-search", + agentsGetView: "list", }); // Files upload. diff --git a/front/components/assistant/conversation/input_bar/editor/useAssistantSuggestions.ts b/front/components/assistant/conversation/input_bar/editor/useAssistantSuggestions.ts index 7c764e6faff9..343c451a9052 100644 --- a/front/components/assistant/conversation/input_bar/editor/useAssistantSuggestions.ts +++ b/front/components/assistant/conversation/input_bar/editor/useAssistantSuggestions.ts @@ -26,7 +26,7 @@ const useAssistantSuggestions = ( ) => { const { agentConfigurations } = useAgentConfigurations({ workspaceId: owner.sId, - agentsGetView: "assistants-search", + agentsGetView: "list", }); // `useMemo` will ensure that suggestions is only recalculated diff --git a/front/lib/api/assistant/configuration.ts b/front/lib/api/assistant/configuration.ts index 63b34ee0c818..c108d273851a 100644 --- a/front/lib/api/assistant/configuration.ts +++ b/front/lib/api/assistant/configuration.ts @@ -172,16 +172,8 @@ function determineGlobalAgentIdsToFetch( case "list": case "all": case "admin_internal": - case "assistants-search": return undefined; // undefined means all global agents will be fetched default: - if ( - typeof agentsGetView === "object" && - "conversationId" in agentsGetView - ) { - // All global agents in conversation view. - return undefined; - } if (typeof agentsGetView === "object" && "agentIds" in agentsGetView) { return agentsGetView.agentIds.filter(isGlobalAgentId); } @@ -303,7 +295,6 @@ async function fetchWorkspaceAgentConfigurationsWithoutActions( where: baseConditionsAndScopesIn(["published"]), }); - case "assistants-search": case "list": const user = auth.user(); @@ -339,22 +330,6 @@ async function fetchWorkspaceAgentConfigurationsWithoutActions( order: [["version", "DESC"]], ...(agentsGetView.allVersions ? {} : { limit: 1 }), }); - } else if ( - typeof agentsGetView === "object" && - "conversationId" in agentsGetView - ) { - const user = auth.user(); - - return AgentConfiguration.findAll({ - ...baseAgentsSequelizeQuery, - where: { - ...baseWhereConditions, - [Op.or]: [ - { scope: { [Op.in]: ["workspace", "published"] } }, - { authorId: user?.id }, - ], - }, - }); } assertNever(agentsGetView); } @@ -547,10 +522,7 @@ export async function getAgentConfigurations({ throw new Error("Archived view is for dust superusers only."); } - if ( - (agentsGetView === "list" || agentsGetView === "assistants-search") && - !user - ) { + if (agentsGetView === "list" && !user) { throw new Error( "`list` or `assistants-search` view is specific to a user." ); diff --git a/front/lib/swr/assistants.ts b/front/lib/swr/assistants.ts index fbb399bc0643..f989b30b8545 100644 --- a/front/lib/swr/assistants.ts +++ b/front/lib/swr/assistants.ts @@ -97,10 +97,6 @@ export function useAgentConfigurations({ const params = new URLSearchParams(); if (typeof agentsGetView === "string") { params.append("view", agentsGetView); - } else { - if (agentsGetView && "conversationId" in agentsGetView) { - params.append("conversationId", agentsGetView.conversationId); - } } if (includes.includes("usage")) { params.append("withUsage", "true"); @@ -157,7 +153,7 @@ export function useProgressiveAgentConfigurations({ isAgentConfigurationsLoading: isInitialAgentConfigurationsLoading, } = useAgentConfigurations({ workspaceId, - agentsGetView: "assistants-search", + agentsGetView: "list", limit: 24, includes: ["usage"], disabled, @@ -171,7 +167,7 @@ export function useProgressiveAgentConfigurations({ mutateRegardlessOfQueryParams, } = useAgentConfigurations({ workspaceId, - agentsGetView: "assistants-search", + agentsGetView: "list", includes: ["authors", "usage"], disabled, }); diff --git a/front/pages/api/v1/w/[wId]/assistant/agent_configurations.ts b/front/pages/api/v1/w/[wId]/assistant/agent_configurations.ts index 4f0f668ef708..2e07190ada26 100644 --- a/front/pages/api/v1/w/[wId]/assistant/agent_configurations.ts +++ b/front/pages/api/v1/w/[wId]/assistant/agent_configurations.ts @@ -56,7 +56,7 @@ async function handler( case "GET": { const agentConfigurations = await getAgentConfigurations({ auth, - agentsGetView: auth.user() ? "assistants-search" : "all", + agentsGetView: auth.user() ? "list" : "all", variant: "light", }); return res.status(200).json({ diff --git a/front/pages/api/w/[wId]/assistant/agent_configurations/index.ts b/front/pages/api/w/[wId]/assistant/agent_configurations/index.ts index 7b658244091d..cac6a0bf507e 100644 --- a/front/pages/api/w/[wId]/assistant/agent_configurations/index.ts +++ b/front/pages/api/w/[wId]/assistant/agent_configurations/index.ts @@ -78,13 +78,9 @@ async function handler( }); } - const { view, conversationId, limit, withUsage, withAuthors, sort } = + const { view, limit, withUsage, withAuthors, sort } = queryValidation.right; - const viewParam = view - ? view - : conversationId - ? { conversationId } - : "all"; + const viewParam = view ? view : "all"; if (viewParam === "admin_internal" && !auth.isDustSuperUser()) { return apiError(req, res, { status_code: 404, diff --git a/front/pages/w/[wId]/builder/assistants/index.tsx b/front/pages/w/[wId]/builder/assistants/index.tsx index b01c58a65d33..2a1965b15bee 100644 --- a/front/pages/w/[wId]/builder/assistants/index.tsx +++ b/front/pages/w/[wId]/builder/assistants/index.tsx @@ -100,7 +100,7 @@ export default function WorkspaceAssistants({ const { agentConfigurations: searchableAgentConfigurations } = useAgentConfigurations({ workspaceId: owner.sId, - agentsGetView: assistantSearch ? "assistants-search" : null, + agentsGetView: assistantSearch ? "list" : null, }); const filteredAgents = ( diff --git a/types/src/front/api_handlers/internal/agent_configuration.ts b/types/src/front/api_handlers/internal/agent_configuration.ts index df5f8646cade..eaf8fa378f80 100644 --- a/types/src/front/api_handlers/internal/agent_configuration.ts +++ b/types/src/front/api_handlers/internal/agent_configuration.ts @@ -21,10 +21,8 @@ export const GetAgentConfigurationsQuerySchema = t.type({ t.literal("global"), t.literal("admin_internal"), t.literal("all"), - t.literal("assistants-search"), t.undefined, ]), - conversationId: t.union([t.string, t.undefined]), withUsage: t.union([t.literal("true"), t.literal("false"), t.undefined]), withAuthors: t.union([t.literal("true"), t.literal("false"), t.undefined]), limit: t.union([LimitCodec, t.undefined]), diff --git a/types/src/front/assistant/agent.ts b/types/src/front/assistant/agent.ts index 0faa1b923482..ab25c9bd65bf 100644 --- a/types/src/front/assistant/agent.ts +++ b/types/src/front/assistant/agent.ts @@ -97,13 +97,8 @@ export type AgentConfigurationScope = * 'views': * - 'list': Retrieves all active agents accessible to the user * - {agentIds: string}: Retrieves specific agents by their sIds. - * - {conversationId: string}: like 'list', plus the agents mentioned in the - * conversation with the provided id. This can be useful to share - * conversations with personal agents * - 'all': All non-private agents (so combines workspace, published and global * agents); used e.g. for non-user calls such as API - * - 'assistants-search': retrieves all global agents including inactive ones, - * all workspace, all published and the user's private agents. * - 'workspace': Retrieves all agents exclusively with a 'workspace' scope. * - 'published': Retrieves all agents exclusively with a 'published' scope. * - 'global': Retrieves all agents exclusively with a 'global' scope. @@ -115,9 +110,7 @@ export type AgentConfigurationScope = export type AgentsGetViewType = | { agentIds: string[]; allVersions?: boolean } | "list" - | { conversationId: string } | "all" - | "assistants-search" | "workspace" | "published" | "global" diff --git a/types/src/shared/cache.ts b/types/src/shared/cache.ts index 17acc10d983e..899c067bc91b 100644 --- a/types/src/shared/cache.ts +++ b/types/src/shared/cache.ts @@ -7,13 +7,19 @@ import { redisClient } from "../shared/redis_client"; // if caching big objects, there is a possible race condition (mulitple calls to // caching), therefore, we use a lock -export function cacheWithRedis Promise>( + +/* eslint-disable @typescript-eslint/no-explicit-any */ +export function cacheWithRedis< + T extends (...args: any[]) => Promise>> +>( fn: T, resolver: (...args: Parameters) => string, ttlMs: number, redisUri?: string, lockCaching?: boolean -): (...args: Parameters) => Promise>> { +): ( + ...args: Parameters +) => Promise>> | Promise> { if (ttlMs > 60 * 60 * 24 * 1000) { throw new Error("ttlMs should be less than 24 hours"); } @@ -70,6 +76,7 @@ export function cacheWithRedis Promise>( } }; } +/* eslint-enable @typescript-eslint/no-explicit-any */ const locks: Record void)[]> = {};