comments
This commit is contained in:
parent
48829672cb
commit
1ee2832e2b
@ -71,13 +71,14 @@ export function Index() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
try {
|
try {
|
||||||
const result: Result = await fal.queue.subscribe('110602490-lora', {
|
const result: Result = await fal.subscribe('110602490-lora', {
|
||||||
input: {
|
input: {
|
||||||
prompt,
|
prompt,
|
||||||
model_name: 'stabilityai/stable-diffusion-xl-base-1.0',
|
model_name: 'stabilityai/stable-diffusion-xl-base-1.0',
|
||||||
image_size: 'square_hd',
|
image_size: 'square_hd',
|
||||||
},
|
},
|
||||||
pollInterval: 5000, // Default is 1000 (every 1s)
|
pollInterval: 5000, // Default is 1000 (every 1s)
|
||||||
|
logs: true,
|
||||||
onQueueUpdate(update) {
|
onQueueUpdate(update) {
|
||||||
setElapsedTime(Date.now() - start);
|
setElapsedTime(Date.now() - start);
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -131,7 +131,7 @@ export async function subscribe<Input, Output>(
|
|||||||
const pollInterval = options.pollInterval ?? 1000;
|
const pollInterval = options.pollInterval ?? 1000;
|
||||||
const poll = async () => {
|
const poll = async () => {
|
||||||
try {
|
try {
|
||||||
const requestStatus = await queue.status(id, requestId, true);
|
const requestStatus = await queue.status(id, requestId, options.logs ?? true);
|
||||||
if (options.onQueueUpdate) {
|
if (options.onQueueUpdate) {
|
||||||
options.onQueueUpdate(requestStatus);
|
options.onQueueUpdate(requestStatus);
|
||||||
}
|
}
|
||||||
@ -176,6 +176,11 @@ type QueueSubscribeOptions = {
|
|||||||
* @param status - The current status of the queue.
|
* @param status - The current status of the queue.
|
||||||
*/
|
*/
|
||||||
onQueueUpdate?: (status: QueueStatus) => void;
|
onQueueUpdate?: (status: QueueStatus) => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If `true`, the response will include the logs for the request.
|
||||||
|
*/
|
||||||
|
logs?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -6,11 +6,6 @@ export type EnqueueResult = {
|
|||||||
request_id: string;
|
request_id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// export type QueueStatus = {
|
|
||||||
// status: "IN_PROGRESS" | "COMPLETED";
|
|
||||||
// queue: number;
|
|
||||||
// };
|
|
||||||
|
|
||||||
export type RequestLog = {
|
export type RequestLog = {
|
||||||
message: string;
|
message: string;
|
||||||
level: 'STDERR' | 'STDOUT' | 'ERROR' | 'INFO' | 'WARN' | 'DEBUG';
|
level: 'STDERR' | 'STDOUT' | 'ERROR' | 'INFO' | 'WARN' | 'DEBUG';
|
||||||
@ -22,7 +17,7 @@ export type QueueStatus =
|
|||||||
| {
|
| {
|
||||||
status: 'IN_PROGRESS' | 'COMPLETED';
|
status: 'IN_PROGRESS' | 'COMPLETED';
|
||||||
response_url: string;
|
response_url: string;
|
||||||
logs: RequestLog[];
|
logs: null | RequestLog[];
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
status: 'IN_QUEUE';
|
status: 'IN_QUEUE';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user