fix(site/src/pages/AgentsPage): hedge the 100% row warning when organization overrides fail to load
This commit is contained in:
1 parent
d5888ce15d
commit
3cd5b08f1f
2 files changed
+40
-3
No files matched your search
@@ -256,6 +256,27 @@ export const DisableCompactionWarning: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const DisableCompactionWithOverridesLoadError: Story = {
|
||||
name: "100% Disable Compaction Warning With Overrides Load Error",
|
||||
args: {
|
||||
compactionTriggerLoadErrors: [
|
||||
{
|
||||
organizationID: MockChatModel.organization_id,
|
||||
error: new Error("Network Error"),
|
||||
},
|
||||
],
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const gpt4oInput = await canvas.findByRole("textbox", {
|
||||
name: /GPT-4o compaction threshold/i,
|
||||
});
|
||||
|
||||
await userEvent.type(gpt4oInput, "100");
|
||||
await reopenTooltip(gpt4oInput);
|
||||
},
|
||||
};
|
||||
|
||||
export const OrganizationCompactionTriggerWarning: Story = {
|
||||
args: {
|
||||
compactionTriggersByOrganizationID: mockCompactionTriggersByOrganizationID,
|
||||
|
||||
@@ -248,6 +248,7 @@ type CompactionThresholdRowProps = {
|
||||
provider: string;
|
||||
organizationName: string;
|
||||
organizationTrigger: OrganizationCompactionTrigger | undefined;
|
||||
organizationOverrideNotLoaded: boolean;
|
||||
onDraftChange: (value: string) => void;
|
||||
onReset: () => void;
|
||||
};
|
||||
@@ -261,6 +262,7 @@ const CompactionThresholdRow: React.FC<CompactionThresholdRowProps> = ({
|
||||
provider,
|
||||
organizationName,
|
||||
organizationTrigger,
|
||||
organizationOverrideNotLoaded,
|
||||
onDraftChange,
|
||||
onReset,
|
||||
}) => {
|
||||
@@ -291,11 +293,19 @@ const CompactionThresholdRow: React.FC<CompactionThresholdRowProps> = ({
|
||||
organizationTriggerPercent === undefined
|
||||
? undefined
|
||||
: formatCompactionPercent(organizationTriggerPercent);
|
||||
const disablingCompactionWarning =
|
||||
|
||||
let disablingCompactionWarning =
|
||||
"Setting 100% turns off automatic compaction for this model.";
|
||||
if (
|
||||
organizationTriggerPercentLabel !== undefined &&
|
||||
!isOrganizationPointBeyondWindow
|
||||
? `Setting 100% turns off this model's own compaction threshold. Chats still compact at about ${organizationTriggerPercentLabel}% of this model's window, set by the organization override.`
|
||||
: "Setting 100% turns off automatic compaction for this model.";
|
||||
) {
|
||||
disablingCompactionWarning = `Setting 100% turns off this model's own compaction threshold. Chats still compact at about ${organizationTriggerPercentLabel}% of this model's window, set by the organization override.`;
|
||||
} else if (organizationOverrideNotLoaded) {
|
||||
disablingCompactionWarning =
|
||||
"Setting 100% turns off this model's own compaction threshold. An organization override may still compact chats with this model.";
|
||||
}
|
||||
|
||||
const modelName = getModelLabel(modelConfig);
|
||||
const providerLabel = formatProviderLabel(provider);
|
||||
const effectiveThresholdPercent =
|
||||
@@ -460,6 +470,9 @@ export const UserCompactionThresholdSettings: React.FC<
|
||||
organization.display_name || organization.name,
|
||||
]),
|
||||
);
|
||||
const organizationIDsWithLoadErrors = new Set(
|
||||
compactionTriggerLoadErrors.map(({ organizationID }) => organizationID),
|
||||
);
|
||||
const organizationOptions = organizations.filter((organization) =>
|
||||
enabledModels.some((config) => config.organization_id === organization.id),
|
||||
);
|
||||
@@ -703,6 +716,9 @@ export const UserCompactionThresholdSettings: React.FC<
|
||||
organizationTrigger={compactionTriggersByOrganizationID.get(
|
||||
modelConfig.organization_id,
|
||||
)}
|
||||
organizationOverrideNotLoaded={organizationIDsWithLoadErrors.has(
|
||||
modelConfig.organization_id,
|
||||
)}
|
||||
onDraftChange={(value) => {
|
||||
setDrafts((currentDrafts) => ({
|
||||
...currentDrafts,
|
||||
|
||||
Reference in new issue
Block a user