Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tssweeney committed Nov 8, 2024
1 parent df21873 commit f3d875b
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 219 deletions.
17 changes: 9 additions & 8 deletions weave-js/src/components/FancyPage/useProjectSidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ export const useProjectSidebar = (
isShown: isWeaveOnly,
iconName: IconNames.BenchmarkSquare,
},
{
type: 'button' as const,
name: 'Scorers',
slug: 'weave/scorers',
isShown: isWeaveOnly,
iconName: IconNames.TypeNumberAlt,
},
// Hiding until we want to release
// {
// type: 'button' as const,
// name: 'Scorers',
// slug: 'weave/scorers',
// isShown: isWeaveOnly,
// iconName: IconNames.TypeNumberAlt,
// },
{
type: 'divider' as const,
key: 'dividerWithinWeave-2',
Expand Down Expand Up @@ -220,7 +221,7 @@ export const useProjectSidebar = (
// iconName: IconNames.OverflowHorizontal,
menu: [
'weave/leaderboards',
'weave/scorers',
// 'weave/scorers', // Hiding until we want to release
'weave/operations',
'weave/objects',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import {
} from './Browse3/pages/ObjectVersionsPage';
import {OpPage} from './Browse3/pages/OpPage';
import {OpsPage} from './Browse3/pages/OpsPage';
import {OpVersionPage} from './Browse3/pages/OpVersionPage/OpVersionPage';
import {OpVersionPage} from './Browse3/pages/OpVersionPage';
import {OpVersionsPage} from './Browse3/pages/OpVersionsPage';
import {PlaygroundPage} from './Browse3/pages/PlaygroundPage/PlaygroundPage';
import {ScorersPage} from './Browse3/pages/ScorersPage/ScorersPage';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const OBJECT_ICONS: Record<KnownBaseObjectClassType, IconName> = {
Dataset: 'table',
Evaluation: 'baseline-alt',
Leaderboard: 'benchmark-square',
Scorer: 'type-number-alt',
};
const ObjectIcon = ({baseObjectClass}: ObjectIconProps) => {
if (baseObjectClass in OBJECT_ICONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import {StyledDataGrid} from '../StyledDataGrid';
import {basicField} from './common/DataTable';
import {Empty} from './common/Empty';
import {
EMPTY_PROPS_ACTION_DEFINITIONS,
EMPTY_PROPS_DATASETS,
EMPTY_PROPS_LEADERBOARDS,
EMPTY_PROPS_MODEL,
EMPTY_PROPS_OBJECTS,
EMPTY_PROPS_PROGRAMATIC_SCORERS,
EMPTY_PROPS_PROGRAMMATIC_SCORERS,
EMPTY_PROPS_PROMPTS,
} from './common/EmptyContent';
import {
Expand Down Expand Up @@ -170,9 +169,7 @@ export const FilterableObjectVersionsTable: React.FC<{
} else if (base === 'Leaderboard') {
propsEmpty = EMPTY_PROPS_LEADERBOARDS;
} else if (base === 'Scorer') {
propsEmpty = EMPTY_PROPS_PROGRAMATIC_SCORERS;
} else if (base === 'ActionSpec') {
propsEmpty = EMPTY_PROPS_ACTION_DEFINITIONS;
propsEmpty = EMPTY_PROPS_PROGRAMMATIC_SCORERS;
}
return <Empty {...propsEmpty} />;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';

export const ActionSpecsTab: React.FC<{
entity: string;
project: string;
}> = ({entity, project}) => {
return <>Coming Soon - Configurable Judges</>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';

export const AnnotationsTab: React.FC<{
entity: string;
project: string;
}> = ({entity, project}) => {
return <>Coming Soon - Annotations</>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

import {FilterableObjectVersionsTable} from '../ObjectVersionsPage';

export const ProgrammaticScorersTab: React.FC<{
entity: string;
project: string;
}> = ({entity, project}) => {
return (
<FilterableObjectVersionsTable
entity={entity}
project={project}
initialFilter={{
baseObjectClass: 'Scorer',
}}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import {Box} from '@material-ui/core';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import {Button} from '@wandb/weave/components/Button/Button';
import React, {FC, useState} from 'react';
import React from 'react';

import {SimplePageLayoutWithHeader} from '../common/SimplePageLayout';
import {FilterableObjectVersionsTable} from '../ObjectVersionsPage';
import {useCreateBaseObjectInstance} from '../wfReactInterface/baseObjectClassQuery';
import {
ActionSpec,
ActionType,
} from '../wfReactInterface/generatedBaseObjectClasses.zod';
import {projectIdFromParts} from '../wfReactInterface/tsDataModelHooks';
import {actionSpecConfigurationSpecs} from './actionSpecConfigurations';
import {NewActionSpecModal} from './NewActionSpecModal';
import {ActionSpecsTab} from './ActionSpecsTab';
import {AnnotationsTab} from './AnnotationsTab';
import {ProgrammaticScorersTab} from './CoreScorersTab';

export const ScorersPage: React.FC<{
entity: string;
Expand All @@ -25,194 +15,18 @@ export const ScorersPage: React.FC<{
tabs={[
{
label: 'Programmatic Scorers',
content: <CodeScorersTab entity={entity} project={project} />,
content: <ProgrammaticScorersTab entity={entity} project={project} />,
},
// This is a placeholder for Griffin's annotation column manager section
// {
// label: 'Human Review',
// content: <HumanScorersTab entity={entity} project={project} />,
// },
{
// It is true that this panel can show more than LLM Judges, but the
// branding is better
label: 'Configurable Judges',
label: 'Human Annotations',
content: <AnnotationsTab entity={entity} project={project} />,
},
{
label: 'Configurable Scorers',
content: <ActionSpecsTab entity={entity} project={project} />,
},
]}
headerContent={undefined}
/>
);
};

const CodeScorersTab: React.FC<{
entity: string;
project: string;
}> = ({entity, project}) => {
return (
<FilterableObjectVersionsTable
entity={entity}
project={project}
initialFilter={{
baseObjectClass: 'Scorer',
}}
/>
);
};

const ActionSpecsTab: React.FC<{
entity: string;
project: string;
}> = ({entity, project}) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [selectedTemplate, setSelectedTemplate] = useState<{
actionType: ActionType;
template: {name: string; config: Record<string, any>};
} | null>(null);
const createCollectionObject = useCreateBaseObjectInstance('ActionSpec');
const [lastUpdatedTimestamp, setLastUpdatedTimestamp] = useState(0);

const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);

const handleCreateBlank = () => {
setSelectedTemplate(null);
setIsModalOpen(true);
};

const handleDropdownClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
setAnchorEl(null);
};

const handleTemplateSelect = (template: {
actionType: ActionType;
template: {name: string; config: Record<string, any>};
}) => {
setSelectedTemplate(template);
setIsModalOpen(true);
handleClose();
};

const handleCloseModal = () => {
setIsModalOpen(false);
setSelectedTemplate(null);
};

const handleSaveModal = (newAction: ActionSpec) => {
let objectId = newAction.name;
// Remove non alphanumeric characters
// TODO: reconcile this null-name issue
objectId = objectId?.replace(/[^a-zA-Z0-9]/g, '-') ?? '';
createCollectionObject({
obj: {
project_id: projectIdFromParts({entity, project}),
object_id: objectId,
val: newAction,
},
})
.then(() => {
setLastUpdatedTimestamp(Date.now());
})
.catch(err => {
console.error(err);
})
.finally(() => {
handleCloseModal();
});
};

return (
<Box
sx={{
display: 'flex',
flexDirection: 'column',
flex: '1 1 auto',
width: '100%',
}}>
<Box
sx={{
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-end',
p: 2,
width: '100%',
}}>
<Box sx={{display: 'flex', alignItems: 'center'}}>
<Button
className="mr-1"
size="medium"
variant="primary"
onClick={handleCreateBlank}
icon="add-new">
Create New
</Button>
<Button
size="medium"
variant="secondary"
onClick={handleDropdownClick}
icon="chevron-down"
tooltip="Select a template"
/>
</Box>
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
{Object.entries(actionSpecConfigurationSpecs).flatMap(
([actionType, spec]) =>
spec.templates.map(template => (
<MenuItem
key={template.name}
onClick={() =>
handleTemplateSelect({
actionType: actionType as ActionType,
template,
})
}>
{template.name}
</MenuItem>
))
)}
</Menu>
</Box>
<FilterableObjectVersionsTable
key={lastUpdatedTimestamp}
entity={entity}
project={project}
initialFilter={{
baseObjectClass: 'ActionSpec',
}}
/>
<NewActionSpecModal
open={isModalOpen}
onClose={handleCloseModal}
onSave={handleSaveModal}
initialTemplate={selectedTemplate}
/>
</Box>
);
};

export const AddNewButton: FC<{
onClick: () => void;
disabled?: boolean;
tooltipText?: string;
}> = ({onClick, disabled, tooltipText}) => (
<Box
sx={{
height: '100%',
display: 'flex',
alignItems: 'center',
}}>
<Button
className="mx-4"
size="medium"
variant="primary"
disabled={disabled}
onClick={onClick}
icon="add-new"
tooltip={tooltipText}>
Create New
</Button>
</Box>
);
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const EMPTY_NO_TRACE_SERVER: EmptyProps = {
),
};

export const EMPTY_PROPS_PROGRAMATIC_SCORERS: EmptyProps = {
export const EMPTY_PROPS_PROGRAMMATIC_SCORERS: EmptyProps = {
icon: 'type-number-alt' as const,
heading: 'No programmatic scorers yet',
description: 'Create programmatic scorers in Python.',
Expand All @@ -198,11 +198,3 @@ export const EMPTY_PROPS_PROGRAMATIC_SCORERS: EmptyProps = {
</>
),
};

export const EMPTY_PROPS_ACTION_DEFINITIONS: EmptyProps = {
icon: 'automation-robot-arm' as const,
heading: 'No configurations yet',
description:
'Create new configuration by clicking "Create new" in the top right.',
moreInformation: <></>,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const colorMap: Record<KnownBaseObjectClassType, TagColorName> = {
Dataset: 'green',
Evaluation: 'cactus',
Leaderboard: 'gold',
Scorer: 'purple',
};

export const TypeVersionCategoryChip: React.FC<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export const KNOWN_BASE_OBJECT_CLASSES = [
'Dataset',
'Evaluation',
'Leaderboard',
'Scorer',
] as const;

0 comments on commit f3d875b

Please sign in to comment.