Skip to content

Commit 07da906

Browse files
committed
tapes: deterministic URL
1 parent 98dff4a commit 07da906

File tree

2 files changed

+18
-93
lines changed

2 files changed

+18
-93
lines changed

packages/inference/src/tasks/cv/textToImage.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export async function textToImage(args: TextToImageArgs, options?: Options): Pro
4545
!args.provider || args.provider === "hf-inference" || args.provider === "sambanova"
4646
? args
4747
: {
48-
...omit(args, ["inputs", "parameters"]),
49-
...args.parameters,
50-
...getResponseFormatArg(args.provider),
51-
prompt: args.inputs,
52-
};
48+
...omit(args, ["inputs", "parameters"]),
49+
...args.parameters,
50+
...getResponseFormatArg(args.provider),
51+
prompt: args.inputs,
52+
};
5353
const res = await request<
5454
TextToImageOutput | Base64ImageGeneration | OutputUrlImageGeneration | BlackForestLabsResponse
5555
>(payload, {
@@ -89,7 +89,7 @@ async function pollBflResponse(url: string): Promise<Blob> {
8989
for (let step = 0; step < 5; step++) {
9090
await delay(1000);
9191
console.debug(`Polling Black Forest Labs API for the result... ${step + 1}/5`);
92-
urlObj.searchParams.set("uuid", randomUUID());
92+
urlObj.searchParams.set("attempt", step.toString(10));
9393
const resp = await fetch(urlObj, { headers: { "Content-Type": "application/json" } });
9494
if (!resp.ok) {
9595
throw new InferenceOutputError("Failed to fetch result from black forest labs API");

packages/inference/test/tapes.json

Lines changed: 12 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -7026,81 +7026,6 @@
70267026
}
70277027
}
70287028
},
7029-
"31cf35b760a4e1567bcaa8094b425854e35e1285aa014263253a136875197665": {
7030-
"url": "https://api.us1.bfl.ai/v1/flux-dev",
7031-
"init": {
7032-
"headers": {
7033-
"Content-Type": "application/json"
7034-
},
7035-
"method": "POST",
7036-
"body": "{\"height\":256,\"width\":256,\"num_inference_steps\":4,\"seed\":8817,\"response_format\":\"base64\",\"prompt\":\"A raccoon driving a truck\"}"
7037-
},
7038-
"response": {
7039-
"body": "{\"id\":\"a00fbfe4-1abd-4d54-966a-71cb1c3c3700\",\"polling_url\":\"https://api.us1.bfl.ai/v1/get_result?id=a00fbfe4-1abd-4d54-966a-71cb1c3c3700\"}",
7040-
"status": 200,
7041-
"statusText": "OK",
7042-
"headers": {
7043-
"connection": "keep-alive",
7044-
"content-type": "application/json",
7045-
"strict-transport-security": "max-age=31536000; includeSubDomains"
7046-
}
7047-
}
7048-
},
7049-
"bc182ea4d907a4b1fe558f2b238ac5252f7b9b4768c9a398faae8e2b89177d49": {
7050-
"url": "https://api.us1.bfl.ai/v1/get_result?id=a00fbfe4-1abd-4d54-966a-71cb1c3c3700&uuid=87c533f5-b483-4105-8bc8-4aacd2831cc0",
7051-
"init": {
7052-
"headers": {
7053-
"Content-Type": "application/json"
7054-
}
7055-
},
7056-
"response": {
7057-
"body": "{\"id\":\"a00fbfe4-1abd-4d54-966a-71cb1c3c3700\",\"status\":\"Pending\",\"result\":null,\"progress\":0.7}",
7058-
"status": 200,
7059-
"statusText": "OK",
7060-
"headers": {
7061-
"connection": "keep-alive",
7062-
"content-type": "application/json",
7063-
"retry-after": "1",
7064-
"strict-transport-security": "max-age=31536000; includeSubDomains"
7065-
}
7066-
}
7067-
},
7068-
"e44536068e0d85fea147002c94e3a7c62b82dd8c8314f69a4ae777b49056b657": {
7069-
"url": "https://api.us1.bfl.ai/v1/get_result?id=a00fbfe4-1abd-4d54-966a-71cb1c3c3700&uuid=b0e31b03-3229-4ed5-a90f-066b718bded0",
7070-
"init": {
7071-
"headers": {
7072-
"Content-Type": "application/json"
7073-
}
7074-
},
7075-
"response": {
7076-
"body": "{\"id\":\"a00fbfe4-1abd-4d54-966a-71cb1c3c3700\",\"status\":\"Ready\",\"result\":{\"sample\":\"https://delivery-us1.bfl.ai/results/ff9ee696c18a4faeb09835b997ed711b/sample.jpeg?se=2025-02-12T14%3A32%3A39Z&sp=r&sv=2024-11-04&sr=b&rsct=image/jpeg&sig=zJ%2BxSXMHsDd9Jn/r0FONvWSzKXYtrFk0SLLf8zrhXO0%3D\",\"prompt\":\"A raccoon driving a truck\",\"seed\":8817,\"start_time\":1739370157.0408669,\"end_time\":1739370159.3932223,\"duration\":2.352355480194092},\"progress\":null}",
7077-
"status": 200,
7078-
"statusText": "OK",
7079-
"headers": {
7080-
"connection": "keep-alive",
7081-
"content-type": "application/json",
7082-
"retry-after": "1",
7083-
"strict-transport-security": "max-age=31536000; includeSubDomains"
7084-
}
7085-
}
7086-
},
7087-
"2bec44b6259bd25573ac1008a7d017f30bc541fc55de3906e882a46ef7f39e0e": {
7088-
"url": "https://delivery-us1.bfl.ai/results/ff9ee696c18a4faeb09835b997ed711b/sample.jpeg?se=2025-02-12T14%3A32%3A39Z&sp=r&sv=2024-11-04&sr=b&rsct=image/jpeg&sig=zJ%2BxSXMHsDd9Jn/r0FONvWSzKXYtrFk0SLLf8zrhXO0%3D",
7089-
"init": {},
7090-
"response": {
7091-
"body": "",
7092-
"status": 200,
7093-
"statusText": "OK",
7094-
"headers": {
7095-
"accept-ranges": "bytes",
7096-
"connection": "keep-alive",
7097-
"content-md5": "NpZjwRHVW54BWXabyXtu+A==",
7098-
"content-type": "image/jpeg",
7099-
"etag": "\"0x8DD4B70B47817DA\"",
7100-
"last-modified": "Wed, 12 Feb 2025 14:22:39 GMT"
7101-
}
7102-
}
7103-
},
71047029
"b320223c78e20541a47c961d89d24f507b0b0257224d91cd05744c93f2d67d2c": {
71057030
"url": "https://api.us1.bfl.ai/v1/flux-dev",
71067031
"init": {
@@ -7111,7 +7036,7 @@
71117036
"body": "{\"height\":256,\"width\":256,\"num_inference_steps\":4,\"seed\":8817,\"prompt\":\"A raccoon driving a truck\"}"
71127037
},
71137038
"response": {
7114-
"body": "{\"id\":\"c85a9b84-5a08-494d-914d-c7e844b5f860\",\"polling_url\":\"https://api.us1.bfl.ai/v1/get_result?id=c85a9b84-5a08-494d-914d-c7e844b5f860\"}",
7039+
"body": "{\"id\":\"9cd5d992-3184-4e16-bd72-e000f7b1182a\",\"polling_url\":\"https://api.us1.bfl.ai/v1/get_result?id=9cd5d992-3184-4e16-bd72-e000f7b1182a\"}",
71157040
"status": 200,
71167041
"statusText": "OK",
71177042
"headers": {
@@ -7121,15 +7046,15 @@
71217046
}
71227047
}
71237048
},
7124-
"8a7ee89f8c572d3f15f0871711e33990fa324d3b985dbc046804a4f6d32bd901": {
7125-
"url": "https://api.us1.bfl.ai/v1/get_result?id=c85a9b84-5a08-494d-914d-c7e844b5f860&uuid=d72d49ca-c0fd-4a7e-9a53-9d0d170dd146",
7049+
"9b83ba327d80e12141b3d61f08ae13af8582aa52cc5e8e9f5f860749bea3b4c0": {
7050+
"url": "https://api.us1.bfl.ai/v1/get_result?id=9cd5d992-3184-4e16-bd72-e000f7b1182a&attempt=0",
71267051
"init": {
71277052
"headers": {
71287053
"Content-Type": "application/json"
71297054
}
71307055
},
71317056
"response": {
7132-
"body": "{\"id\":\"c85a9b84-5a08-494d-914d-c7e844b5f860\",\"status\":\"Pending\",\"result\":null,\"progress\":0.7}",
7057+
"body": "{\"id\":\"9cd5d992-3184-4e16-bd72-e000f7b1182a\",\"status\":\"Pending\",\"result\":null,\"progress\":0.7}",
71337058
"status": 200,
71347059
"statusText": "OK",
71357060
"headers": {
@@ -7140,15 +7065,15 @@
71407065
}
71417066
}
71427067
},
7143-
"c91732b5925027a0f973fddea50a84ca3e38e5ad29ae6c5c5d586407d801e7a3": {
7144-
"url": "https://api.us1.bfl.ai/v1/get_result?id=c85a9b84-5a08-494d-914d-c7e844b5f860&uuid=fd2be19f-f4f0-4a7c-a299-4a8605406244",
7068+
"0c3cc43124071a2bf53a619a9bce037c14e1ed790e8cce40db45389dbaee6b4e": {
7069+
"url": "https://api.us1.bfl.ai/v1/get_result?id=9cd5d992-3184-4e16-bd72-e000f7b1182a&attempt=1",
71457070
"init": {
71467071
"headers": {
71477072
"Content-Type": "application/json"
71487073
}
71497074
},
71507075
"response": {
7151-
"body": "{\"id\":\"c85a9b84-5a08-494d-914d-c7e844b5f860\",\"status\":\"Ready\",\"result\":{\"sample\":\"https://delivery-us1.bfl.ai/results/a33e5ec1823247c5806922105a13b5ac/sample.jpeg?se=2025-02-12T14%3A39%3A28Z&sp=r&sv=2024-11-04&sr=b&rsct=image/jpeg&sig=Gny3WJ6TtaabMBY64JsAUfYUFnhqFBxOeG1TEqSQYPg%3D\",\"prompt\":\"A raccoon driving a truck\",\"seed\":8817,\"start_time\":1739370565.7599242,\"end_time\":1739370568.203259,\"duration\":2.4433348178863525},\"progress\":null}",
7076+
"body": "{\"id\":\"9cd5d992-3184-4e16-bd72-e000f7b1182a\",\"status\":\"Ready\",\"result\":{\"sample\":\"https://delivery-us1.bfl.ai/results/5965f3f68d50412c9d62c08480d7cd75/sample.jpeg?se=2025-02-12T15%3A25%3A59Z&sp=r&sv=2024-11-04&sr=b&rsct=image/jpeg&sig=ZQfYFNXVQLTxwXJb/2HPPb6fl5ITyJukYiYsBY15iBs%3D\",\"prompt\":\"A raccoon driving a truck\",\"seed\":8817,\"start_time\":1739373357.096922,\"end_time\":1739373359.4733694,\"duration\":2.3764474391937256},\"progress\":null}",
71527077
"status": 200,
71537078
"statusText": "OK",
71547079
"headers": {
@@ -7159,8 +7084,8 @@
71597084
}
71607085
}
71617086
},
7162-
"5134396a85d723dddd3ad6bfd52fbecc73036197ca34e5921fdaf747f5763436": {
7163-
"url": "https://delivery-us1.bfl.ai/results/a33e5ec1823247c5806922105a13b5ac/sample.jpeg?se=2025-02-12T14%3A39%3A28Z&sp=r&sv=2024-11-04&sr=b&rsct=image/jpeg&sig=Gny3WJ6TtaabMBY64JsAUfYUFnhqFBxOeG1TEqSQYPg%3D",
7087+
"999dc957255935037c9b76833430b679add51c628940a97289dd3e6f0944e60f": {
7088+
"url": "https://delivery-us1.bfl.ai/results/5965f3f68d50412c9d62c08480d7cd75/sample.jpeg?se=2025-02-12T15%3A25%3A59Z&sp=r&sv=2024-11-04&sr=b&rsct=image/jpeg&sig=ZQfYFNXVQLTxwXJb/2HPPb6fl5ITyJukYiYsBY15iBs%3D",
71647089
"init": {},
71657090
"response": {
71667091
"body": "",
@@ -7169,10 +7094,10 @@
71697094
"headers": {
71707095
"accept-ranges": "bytes",
71717096
"connection": "keep-alive",
7172-
"content-md5": "is3WLSIOLTgK68I2T1ui4g==",
7097+
"content-md5": "ZzxARdjL4KeKFdZDh6Wk3A==",
71737098
"content-type": "image/jpeg",
7174-
"etag": "\"0x8DD4B71A833FC0C\"",
7175-
"last-modified": "Wed, 12 Feb 2025 14:29:28 GMT"
7099+
"etag": "\"0x8DD4B7827EE36A3\"",
7100+
"last-modified": "Wed, 12 Feb 2025 15:15:59 GMT"
71767101
}
71777102
}
71787103
}

0 commit comments

Comments
 (0)