Skip to content

Commit

Permalink
feat: add ability to toggle viz from builder (gated) (#6624)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Aug 1, 2024
1 parent 420dac3 commit faf7bdf
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions front/components/assistant/TryAssistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function usePreviewAssistant({
generationSettings: builderState.generationSettings,
actions: builderState.actions,
maxStepsPerRun: builderState.maxStepsPerRun,
visualizationEnabled: builderState.visualizationEnabled,
templateId: builderState.templateId,
},
agentConfigurationId: null,
Expand Down Expand Up @@ -131,6 +132,7 @@ export function usePreviewAssistant({
builderState.actions,
builderState.maxStepsPerRun,
builderState.templateId,
builderState.visualizationEnabled,
sendNotification,
]);

Expand Down
26 changes: 26 additions & 0 deletions front/components/assistant_builder/ActionsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
BookOpenIcon,
Button,
CardButton,
Checkbox,
ContentMessage,
DropdownMenu,
Icon,
Expand Down Expand Up @@ -346,6 +347,31 @@ export default function ActionsScreen({
</div>
</div>
</div>
<div className="flex flex-col gap-8">
{owner.flags.includes("visualization_action_flag") && (
<div className="flex flex-row gap-2">
<Checkbox
checked={builderState.visualizationEnabled}
onChange={() => {
setEdited(true);
setBuilderState((state) => ({
...state,
visualizationEnabled: !state.visualizationEnabled,
}));
}}
variant="checkable"
/>
<div>
<div className="flex w-full gap-1 font-medium text-element-900">
Visualization
</div>
<div className="w-full truncate text-base text-element-700">
The assistant can create graphs and charts
</div>
</div>
</div>
)}
</div>
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions front/components/assistant_builder/AssistantBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default function AssistantBuilder({
maxStepsPerRun:
initialBuilderState.maxStepsPerRun ??
getDefaultAssistantState().maxStepsPerRun,
visualizationEnabled: initialBuilderState.visualizationEnabled,
templateId: initialBuilderState.templateId,
}
: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ export async function submitAssistantBuilderForm({
temperature: builderState.generationSettings.temperature,
},
maxStepsPerRun,
// TODO(@fontanierh): support viz in the builder
visualizationEnabled: false,
visualizationEnabled: builderState.visualizationEnabled,
templateId: builderState.templateId,
},
};
Expand Down
3 changes: 3 additions & 0 deletions front/components/assistant_builder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export type AssistantBuilderState = {
};
actions: Array<AssistantBuilderActionConfiguration>;
maxStepsPerRun: number | null;
visualizationEnabled: boolean;
templateId: string | null;
};

Expand All @@ -184,6 +185,7 @@ export type AssistantBuilderInitialState = {
} | null;
actions: Array<AssistantBuilderActionConfiguration>;
maxStepsPerRun: number | null;
visualizationEnabled: boolean;
templateId: string | null;
};

Expand All @@ -204,6 +206,7 @@ export function getDefaultAssistantState() {
temperature: 0.7,
},
maxStepsPerRun: 3,
visualizationEnabled: false,
templateId: null,
} satisfies AssistantBuilderState;
}
Expand Down
1 change: 1 addition & 0 deletions front/lib/api/assistant/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export async function generateMockAgentConfigurationFromTemplate(
name: template.handle,
scope: flow === "personal_assistants" ? "private" : "workspace",
pictureUrl: template.pictureUrl,
visualizationEnabled: false,
isTemplate: true,
});
}
1 change: 1 addition & 0 deletions front/pages/w/[wId]/builder/assistants/[aId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export default function EditAssistant({
temperature: agentConfiguration.model.temperature,
},
actions,
visualizationEnabled: agentConfiguration.visualizationEnabled,
maxStepsPerRun: agentConfiguration.maxStepsPerRun,
templateId: agentConfiguration.templateId,
}}
Expand Down
1 change: 1 addition & 0 deletions front/pages/w/[wId]/builder/assistants/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export default function CreateAssistant({
temperature: agentConfiguration.model.temperature,
},
maxStepsPerRun: agentConfiguration.maxStepsPerRun ?? null,
visualizationEnabled: agentConfiguration.visualizationEnabled,
templateId: templateId,
}
: null
Expand Down
1 change: 1 addition & 0 deletions types/src/front/assistant/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export interface TemplateAgentConfigurationType {
instructions: string | null;
isTemplate: true;
maxStepsPerRun?: number;
visualizationEnabled: boolean;
}

export const MAX_STEPS_USE_PER_RUN_LIMIT = 8;

0 comments on commit faf7bdf

Please sign in to comment.