Add dummy model evaluation buttons to model editor (#3381)

This commit is contained in:
Charis Kyriakou
2024-02-20 14:50:15 +00:00
committed by GitHub
parent 3598b1871f
commit 46a15bfdd6
6 changed files with 103 additions and 1 deletions

View File

@@ -590,6 +590,14 @@ interface StopGeneratingMethodsFromLlmMessage {
packageName: string; packageName: string;
} }
interface StartModelEvaluationMessage {
t: "startModelEvaluation";
}
interface StopModelEvaluationMessage {
t: "stopModelEvaluation";
}
interface ModelDependencyMessage { interface ModelDependencyMessage {
t: "modelDependency"; t: "modelDependency";
} }
@@ -648,7 +656,9 @@ export type FromModelEditorMessage =
| StopGeneratingMethodsFromLlmMessage | StopGeneratingMethodsFromLlmMessage
| ModelDependencyMessage | ModelDependencyMessage
| HideModeledMethodsMessage | HideModeledMethodsMessage
| SetMultipleModeledMethodsMessage; | SetMultipleModeledMethodsMessage
| StartModelEvaluationMessage
| StopModelEvaluationMessage;
interface RevealInEditorMessage { interface RevealInEditorMessage {
t: "revealInModelEditor"; t: "revealInModelEditor";

View File

@@ -715,6 +715,7 @@ const LLM_GENERATION_DEV_ENDPOINT = new Setting(
"llmGenerationDevEndpoint", "llmGenerationDevEndpoint",
MODEL_SETTING, MODEL_SETTING,
); );
const MODEL_EVALUATION = new Setting("evaluation", MODEL_SETTING);
const EXTENSIONS_DIRECTORY = new Setting("extensionsDirectory", MODEL_SETTING); const EXTENSIONS_DIRECTORY = new Setting("extensionsDirectory", MODEL_SETTING);
const ENABLE_PYTHON = new Setting("enablePython", MODEL_SETTING); const ENABLE_PYTHON = new Setting("enablePython", MODEL_SETTING);
const ENABLE_ACCESS_PATH_SUGGESTIONS = new Setting( const ENABLE_ACCESS_PATH_SUGGESTIONS = new Setting(
@@ -759,6 +760,10 @@ export class ModelConfigListener extends ConfigListener implements ModelConfig {
return LLM_GENERATION_DEV_ENDPOINT.getValue<string | undefined>(); return LLM_GENERATION_DEV_ENDPOINT.getValue<string | undefined>();
} }
public get modelEvaluation(): boolean {
return !!MODEL_EVALUATION.getValue<boolean>();
}
public getExtensionsDirectory(languageId: string): string | undefined { public getExtensionsDirectory(languageId: string): string | undefined {
return EXTENSIONS_DIRECTORY.getValue<string>({ return EXTENSIONS_DIRECTORY.getValue<string>({
languageId, languageId,

View File

@@ -337,6 +337,12 @@ export class ModelEditorView extends AbstractWebview<
this.setModeledMethods(msg.methodSignature, msg.modeledMethods); this.setModeledMethods(msg.methodSignature, msg.modeledMethods);
break; break;
} }
case "startModelEvaluation":
this.startModelEvaluation();
break;
case "stopModelEvaluation":
this.stopModelEvaluation();
break;
case "telemetry": case "telemetry":
telemetryListener?.sendUIInteraction(msg.action); telemetryListener?.sendUIInteraction(msg.action);
break; break;
@@ -402,6 +408,8 @@ export class ModelEditorView extends AbstractWebview<
const showLlmButton = const showLlmButton =
this.databaseItem.language === "java" && this.modelConfig.llmGeneration; this.databaseItem.language === "java" && this.modelConfig.llmGeneration;
const showEvaluationUi = this.modelConfig.modelEvaluation;
const sourceArchiveAvailable = const sourceArchiveAvailable =
this.databaseItem.hasSourceArchiveInExplorer(); this.databaseItem.hasSourceArchiveInExplorer();
@@ -416,6 +424,7 @@ export class ModelEditorView extends AbstractWebview<
language: this.language, language: this.language,
showGenerateButton, showGenerateButton,
showLlmButton, showLlmButton,
showEvaluationUi,
mode: this.modelingStore.getMode(this.databaseItem), mode: this.modelingStore.getMode(this.databaseItem),
showModeSwitchButton, showModeSwitchButton,
sourceArchiveAvailable, sourceArchiveAvailable,
@@ -910,4 +919,12 @@ export class ModelEditorView extends AbstractWebview<
); );
this.modelingStore.addModifiedMethod(this.databaseItem, signature); this.modelingStore.addModifiedMethod(this.databaseItem, signature);
} }
private startModelEvaluation() {
// Do nothing for now. This will be fleshed out in the near future.
}
private stopModelEvaluation() {
// Do nothing for now. This will be fleshed out in the near future.
}
} }

View File

@@ -7,6 +7,7 @@ export interface ModelEditorViewState {
language: QueryLanguage; language: QueryLanguage;
showGenerateButton: boolean; showGenerateButton: boolean;
showLlmButton: boolean; showLlmButton: boolean;
showEvaluationUi: boolean;
mode: Mode; mode: Mode;
showModeSwitchButton: boolean; showModeSwitchButton: boolean;
sourceArchiveAvailable: boolean; sourceArchiveAvailable: boolean;

View File

@@ -74,6 +74,50 @@ const ButtonsContainer = styled.div`
margin-top: 1rem; margin-top: 1rem;
`; `;
const ModelEvaluation = ({
viewState,
modeledMethods,
modifiedSignatures,
onStartEvaluation,
onStopEvaluation,
evaluationInProgress,
}: {
viewState: ModelEditorViewState;
modeledMethods: Record<string, ModeledMethod[]>;
modifiedSignatures: Set<string>;
onStartEvaluation: () => void;
onStopEvaluation: () => void;
evaluationInProgress: boolean;
}) => {
if (!viewState.showEvaluationUi) {
return null;
}
if (!evaluationInProgress) {
const customModelsExist = Object.values(modeledMethods).some(
(methods) => methods.filter((m) => m.type !== "none").length > 0,
);
const unsavedChanges = modifiedSignatures.size > 0;
return (
<VSCodeButton
onClick={onStartEvaluation}
appearance="secondary"
disabled={!customModelsExist || unsavedChanges}
>
Evaluate
</VSCodeButton>
);
} else {
return (
<VSCodeButton onClick={onStopEvaluation} appearance="secondary">
Stop evaluation
</VSCodeButton>
);
}
};
type Props = { type Props = {
initialViewState?: ModelEditorViewState; initialViewState?: ModelEditorViewState;
initialMethods?: Method[]; initialMethods?: Method[];
@@ -114,6 +158,8 @@ export function ModelEditor({
string | null string | null
>(null); >(null);
const [evaluationInProgress, setEvaluationInProgress] = useState(false);
useEffect(() => { useEffect(() => {
vscode.postMessage({ vscode.postMessage({
t: "hideModeledMethods", t: "hideModeledMethods",
@@ -254,6 +300,20 @@ export function ModelEditor({
[selectedSignatures], [selectedSignatures],
); );
const onStartEvaluation = useCallback(() => {
setEvaluationInProgress(true);
vscode.postMessage({
t: "startModelEvaluation",
});
}, []);
const onStopEvaluation = useCallback(() => {
setEvaluationInProgress(false);
vscode.postMessage({
t: "stopModelEvaluation",
});
}, []);
const onGenerateFromSourceClick = useCallback(() => { const onGenerateFromSourceClick = useCallback(() => {
vscode.postMessage({ vscode.postMessage({
t: "generateMethod", t: "generateMethod",
@@ -373,6 +433,14 @@ export function ModelEditor({
Generate Generate
</VSCodeButton> </VSCodeButton>
)} )}
<ModelEvaluation
viewState={viewState}
modeledMethods={modeledMethods}
modifiedSignatures={modifiedSignatures}
onStartEvaluation={onStartEvaluation}
onStopEvaluation={onStopEvaluation}
evaluationInProgress={evaluationInProgress}
/>
</ButtonsContainer> </ButtonsContainer>
</HeaderRow> </HeaderRow>
</HeaderColumn> </HeaderColumn>

View File

@@ -11,6 +11,7 @@ export function createMockModelEditorViewState(
mode: Mode.Application, mode: Mode.Application,
showGenerateButton: false, showGenerateButton: false,
showLlmButton: false, showLlmButton: false,
showEvaluationUi: false,
showModeSwitchButton: true, showModeSwitchButton: true,
extensionPack: createMockExtensionPack(), extensionPack: createMockExtensionPack(),
sourceArchiveAvailable: true, sourceArchiveAvailable: true,