Skip to content

Commit

Permalink
Add Test Mode toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
JustMaier committed Apr 20, 2024
1 parent a68dab8 commit 3a6a3cc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@ const GenerationFormInner = ({ onSuccess }: { onSuccess?: () => void }) => {
resources: [{ type: ModelType.VAE, baseModelSet: baseModel }],
}}
/>
{currentUser?.isModerator && (
<InputSwitch name="staging" label="Test Mode" labelPosition="left" />
)}
</Stack>
</Accordion.Panel>
</Accordion.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const useEstimateTextToImageJobCost = () => {
const input = useGenerationFormStore(
useCallback(
(state) => {
const { aspectRatio, steps, quantity, sampler, draft } = state;
const { aspectRatio, steps, quantity, sampler, draft, staging } = state;
if (!status.charge || !baseModel) return null;

return {
Expand All @@ -141,6 +141,7 @@ export const useEstimateTextToImageJobCost = () => {
steps: steps ?? generation.defaultValues.steps,
quantity: quantity ?? generation.defaultValues.quantity,
sampler: sampler ?? generation.defaultValues.sampler,
staging,
draft,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const useGetGenerationRequests = (
if (!isLoading) updateFromEvents();
}, [isLoading]);

return { data, requests, images, isLoading, ...rest };
return { data, requests, images, isLoading: !currentUser ? false : isLoading, ...rest };
};

export const updateGenerationRequest = (
Expand Down
1 change: 1 addition & 0 deletions src/server/schema/generation.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const sharedGenerationParamsSchema = z.object({
quantity: z.coerce.number().min(1).max(20),
nsfw: z.boolean().optional(),
draft: z.boolean().optional(),
staging: z.boolean().optional(),
baseModel: z.string().optional(),
aspectRatio: z.string(),
});
Expand Down
18 changes: 9 additions & 9 deletions src/server/services/generation/generation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,15 @@ export const createGenerationRequest = async ({
// console.log(JSON.stringify(generationRequest));
// console.log('________');

const charge = status.charge;
const response = await fetch(
`${env.SCHEDULER_ENDPOINT}/requests${charge ? '?charge=true' : ''}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(generationRequest),
}
);
const schedulerUrl = new URL(`${env.SCHEDULER_ENDPOINT}/requests`);
if (status.charge) schedulerUrl.searchParams.set('charge', 'true');
if (params.staging) schedulerUrl.searchParams.set('staging', 'true');

const response = await fetch(schedulerUrl.toString(), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(generationRequest),
});

// console.log('________');
// console.log(response);
Expand Down

0 comments on commit 3a6a3cc

Please sign in to comment.