Skip to content

Commit

Permalink
Update usage query to filter out private assistants and only count them
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph committed Jan 13, 2025
1 parent d7507da commit 4ae60aa
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 43 deletions.
3 changes: 2 additions & 1 deletion front/components/spaces/SpaceResourcesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ const getTableColumns = ({

const usedByColumn = {
header: "Used by",
accessorFn: (row: RowData) => row.dataSourceView.usage?.count ?? 0,
accessorFn: (row: RowData) =>
row.dataSourceView.usage?.totalAgentCount ?? 0,
id: "usedBy",
meta: {
width: "6rem",
Expand Down
17 changes: 12 additions & 5 deletions front/components/spaces/UsedByButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ScrollArea,
} from "@dust-tt/sparkle";
import type { DataSourceWithAgentsUsageType } from "@dust-tt/types";
import { pluralize } from "@dust-tt/types";

export const UsedByButton = ({
usage,
Expand All @@ -16,13 +17,13 @@ export const UsedByButton = ({
usage: DataSourceWithAgentsUsageType;
onItemClick: (assistantSid: string) => void;
}) => {
return usage.count === 0 ? (
return usage.totalAgentCount === 0 ? (
<Button
icon={RobotIcon}
variant="ghost"
isSelect={false}
size="sm"
label={`${usage.count}`}
label={`${usage.totalAgentCount}`}
disabled
/>
) : (
Expand All @@ -33,21 +34,27 @@ export const UsedByButton = ({
variant="ghost"
isSelect={true}
size="sm"
label={`${usage.count}`}
label={`${usage.totalAgentCount}`}
/>
</DropdownMenuTrigger>
<DropdownMenuContent className="max-w-[300px]">
<ScrollArea className="border-1 h-[130px]">
{usage.agentNames.map((name) => (
{usage.publicAgentNames.map((name) => (
<DropdownMenuItem
key={`assistant-picker-${name}`}
label={name}
label={`@${name}`}
onClick={(e) => {
e.stopPropagation();
onItemClick(name);
}}
/>
))}
{usage.privateAgentCount > 0 && (
<DropdownMenuItem
label={`+ ${usage.privateAgentCount} private agent${pluralize(usage.privateAgentCount)}`}
disabled={true}
/>
)}
</ScrollArea>
</DropdownMenuContent>
</DropdownMenu>
Expand Down
Loading

0 comments on commit 4ae60aa

Please sign in to comment.