Skip to content

Commit

Permalink
some final adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
tssweeney committed Nov 18, 2024
1 parent 8d07a9d commit c77b8e7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ export const CallPage: FC<{
return <CallPageInnerVertical {...props} call={call.result} />;
};

const useCallTabs = (call: CallSchema) => {
export const useShowRunnableUI = () => {
const viewerInfo = useViewerInfo();
const showScores = viewerInfo.loading ? false : viewerInfo.userInfo?.admin;
return viewerInfo.loading ? false : viewerInfo.userInfo?.admin;
};

const useCallTabs = (call: CallSchema) => {
const showScores = useShowRunnableUI();
const codeURI = call.opVersionRef;
const {entity, project, callId} = call;
const weaveRef = makeRefCall(entity, project, callId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import {CallSchema} from '../wfReactInterface/wfDataModelHooksInterface';

const RUNNABLE_REF_PREFIX = 'wandb.runnable';



const useLatestActionDefinitionsForCall = (call: CallSchema) => {
const actionSpecs = (
useBaseObjectInstances('ActionSpec', {
Expand Down Expand Up @@ -266,7 +264,7 @@ export const CallScoresViewer: React.FC<{
{
field: 'run',
headerName: '',
width:75,
width: 75,
rowSpanValueGetter: (value, row) => row.displayName,
renderCell: params => {
const actionRef = params.row.runnableActionRef;
Expand Down Expand Up @@ -323,7 +321,6 @@ export const CallScoresViewer: React.FC<{
);
};


const RunButton: React.FC<{
actionRef: string;
callId: string;
Expand Down Expand Up @@ -353,20 +350,27 @@ const RunButton: React.FC<{
}
};


if (error) {
return (
<Button variant="destructive" onClick={handleRunClick} disabled style={{width: '55px'}}>
<Button
variant="destructive"
onClick={handleRunClick}
disabled
style={{width: '55px'}}>
Error
</Button>
);
}

return (
<div>
<Button variant="secondary" onClick={handleRunClick} disabled={isRunning} style={{width: '55px'}}>
<Button
variant="secondary"
onClick={handleRunClick}
disabled={isRunning}
style={{width: '55px'}}>
{isRunning ? '...' : 'Run'}
</Button>
</div>
);
};
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import {Box, Drawer} from '@material-ui/core';
import {Button} from '@wandb/weave/components/Button';
import {Icon, IconName, IconNames} from '@wandb/weave/components/Icon';
import React, {FC, ReactNode, useCallback, useEffect, useState} from 'react';

import React, {
FC,
ReactNode,
useCallback,
useEffect,
useMemo,
useState,
} from 'react';

import {useShowRunnableUI} from '../CallPage/CallPage';
import {TraceServerClient} from '../wfReactInterface/traceServerClient';
import {useGetTraceServerClientContext} from '../wfReactInterface/traceServerClientContext';
import {AutocompleteWithLabel} from './FormComponents';
Expand All @@ -16,7 +24,7 @@ import {
const HUMAN_ANNOTATION_LABEL = 'Human annotation';
export const HUMAN_ANNOTATION_VALUE = 'ANNOTATION';
const LLM_JUDGE_LABEL = 'LLM judge';
const LLM_JUDGE_VALUE = 'LLM_JUDGE';
export const LLM_JUDGE_VALUE = 'LLM_JUDGE';
const PROGRAMMATIC_LABEL = 'Programmatic scorer';
const PROGRAMMATIC_VALUE = 'PROGRAMMATIC';

Expand Down Expand Up @@ -48,7 +56,7 @@ export const scorerTypeRecord: Record<ScorerType, ScorerTypeConfig<any>> = {
},
},
LLM_JUDGE: {
label: LLM_JUDGE_LABEL,
label: LLM_JUDGE_LABEL + ' (W&B Admin Preview)',
value: LLM_JUDGE_VALUE,
icon: IconNames.RobotServiceMember,
Component: LLMJudgeScorerForm.LLMJudgeScorerForm,
Expand Down Expand Up @@ -124,6 +132,12 @@ export const NewScorerDrawer: FC<NewScorerDrawerProps> = ({
}, [selectedScorerType, entity, project, formData, getClient, onClose]);

const ScorerFormComponent = scorerTypeRecord[selectedScorerType].Component;
const showRunnableUI = useShowRunnableUI();
const options = useMemo(() => {
return scorerTypeOptions.filter(
opt => showRunnableUI || opt.value !== LLM_JUDGE_VALUE
);
}, [showRunnableUI]);

return (
<SaveableDrawer
Expand All @@ -134,8 +148,8 @@ export const NewScorerDrawer: FC<NewScorerDrawerProps> = ({
saveDisabled={!isFormValid}>
<AutocompleteWithLabel
label="Scorer type"
options={scorerTypeOptions}
value={scorerTypeOptions.find(opt => opt.value === selectedScorerType)}
options={options}
value={options.find(opt => opt.value === selectedScorerType)}
formatOptionLabel={option => (
<Box display="flex" alignItems="center" style={{gap: '4px'}}>
<Icon name={option.icon} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Button} from '@wandb/weave/components/Button';
import {IconNames} from '@wandb/weave/components/Icon';
import React, {useState} from 'react';

import {useShowRunnableUI} from '../CallPage/CallPage';
import {SimplePageLayoutWithHeader} from '../common/SimplePageLayout';
import {AnnotationsTab} from './AnnotationsTab';
import {ProgrammaticScorersTab} from './CoreScorersTab';
Expand All @@ -22,6 +23,8 @@ export const ScorersPage: React.FC<{
scorerTypeRecord.ANNOTATION.value
);

const showRunnableUI = useShowRunnableUI();

return (
<>
<SimplePageLayoutWithHeader
Expand All @@ -32,11 +35,15 @@ export const ScorersPage: React.FC<{
icon: scorerTypeRecord.ANNOTATION.icon,
content: <AnnotationsTab entity={entity} project={project} />,
},
{
label: scorerTypeRecord.LLM_JUDGE.label + 's',
icon: scorerTypeRecord.LLM_JUDGE.icon,
content: <LLMJudgesTab entity={entity} project={project} />,
},
...(showRunnableUI
? [
{
label: scorerTypeRecord.LLM_JUDGE.label + 's',
icon: scorerTypeRecord.LLM_JUDGE.icon,
content: <LLMJudgesTab entity={entity} project={project} />,
},
]
: []),
{
label: scorerTypeRecord.PROGRAMMATIC.label + 's',
icon: scorerTypeRecord.PROGRAMMATIC.icon,
Expand Down

0 comments on commit c77b8e7

Please sign in to comment.