Skip to content

Commit

Permalink
Show the question, but disabled, before they click to see the data in…
Browse files Browse the repository at this point in the history
… hny
  • Loading branch information
jessitron committed Sep 15, 2024
1 parent d1f5580 commit e528d61
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/BoothGame/analyzeData/DataQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { MultipleChoice, MultipleChoiceResult } from "./MultipleChoice";
import { DataQuestionParameters } from "./DataQuestionParameters";
import popOutIndicator from "../../../static/images/arrowSquareUpRight.svg";

const PleaseLookAtTheData = { questionVisible: false };
const LookedAtTheData = { questionVisible: true };
const PleaseLookAtTheData = { questionEnabled: false };
const LookedAtTheData = { questionEnabled: true };

type DataQuestionState = typeof PleaseLookAtTheData | typeof LookedAtTheData;

Expand Down Expand Up @@ -36,16 +36,16 @@ function DataQuestionInternal<T>(props: DataQuestionProps<T>) {
setState(LookedAtTheData);
}

const questionAndAnswer = state.questionVisible ? (
const questionAndAnswer =
<MultipleChoice<T>
enabled={state.questionEnabled}
questionText={<>Which question led to the slowest response?</>}
queryDefinition={queryDefinition}
queryName="Slowest response from LLM"
dataset={BACKEND_DATASET_NAME}
moveOn={props.moveForward}
interpretData={props.interpretData}
/>
) : null;
/>;

return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/BoothGame/analyzeData/DataQuestionParameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const whichResponseTookTheLongestQuestionParameters = (activeLifecycleSpa
,
queryDefinition: queryForLongestLLMResponse(activeLifecycleSpan, honeycombTeam),
datasetSlug: BACKEND_DATASET_NAME,
interpretData
interpretData
});

function interpretData(data: DataFromLongestLLMResponse[]): WhatMultipleChoiceNeedsToKnow {
Expand Down
23 changes: 20 additions & 3 deletions src/BoothGame/analyzeData/MultipleChoice.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useEffect } from "react";
import { ComponentLifecycleTracing, ActiveLifecycleSpan } from "../../tracing/ComponentLifecycleTracing";
import { HoneycombTeamContext } from "../HoneycombTeamContext";
import { fetchFromBackend } from "../../tracing/fetchFromBackend";
Expand Down Expand Up @@ -105,6 +105,7 @@ type MultipleChoiceInternalProps = {
answers: AnswerOption[],
scoreAnswer: (a: AnswerOption) => Score
moveOn: (result: MultipleChoiceResult) => void;
enabled: boolean
};

export type AnswerOption = {
Expand All @@ -117,10 +118,18 @@ export type Score = {
remark: string
}

const NoAnswerAllowedYet = {
name: "no answer allowed yet",
answer: undefined,
button: "Submit",
buttonEnabled: false,
radioButtonsEnabled: false,
};

const NoAnswerPicked = {
name: "no answer picked",
answer: undefined,
button: "submit",
button: "Submit",
buttonEnabled: false,
radioButtonsEnabled: true,
};
Expand All @@ -144,10 +153,17 @@ type MultipleChoiceInternalState = typeof NoAnswerPicked | PickedOne | DeliverVe

function MultipleChoiceInternal(props: MultipleChoiceInternalProps) {
const activeLifecycleSpan = React.useContext(ActiveLifecycleSpan);
const [state, setState] = useLocalTracedState<MultipleChoiceInternalState>(NoAnswerPicked, {
const [state, setState] = useLocalTracedState<MultipleChoiceInternalState>(props.enabled ? NoAnswerPicked : NoAnswerAllowedYet, {
componentName: "MultipleChoiceDisplay",
});

useEffect(() => {
// this state update comes in from outside
if (state.name === "no answer allowed yet" && props.enabled) {
setState(NoAnswerPicked);
}
}, [props.enabled, state])

const answers = props.answers

const handleSelection = (event: React.ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -242,6 +258,7 @@ type MultipleChoiceProps<ParticularQueryData> = {
dataset: string;
interpretData: (data: ParticularQueryData[]) => WhatMultipleChoiceNeedsToKnow;
moveOn: (result: MultipleChoiceResult) => void;
enabled: boolean;
};
export function MultipleChoice<ParticularQueryData>(props: MultipleChoiceProps<ParticularQueryData>) {
return (
Expand Down

0 comments on commit e528d61

Please sign in to comment.