b7c8eecca7ab0493410a288dced2defb4eee6d3b

Author
Julien Chaumond <julien@huggingface.co>
Committer
GitHub <noreply@github.com>
Date

Message

Use autoload=true for the single /props call (#1)

Previously we called /props with autoload=false and only retried with
autoload=true on 400/404. The fallback was the only path that ever
succeeded when the model wasn't already loaded, so collapse to a single
autoload=true call.

Co-authored-by: julien-agent <Agents+cyolo@huggingface.co>

Diff

 1diff --git a/index.ts b/index.ts
 2index 810cf748099a07deda55979da499586c90e249f7..372a02715726f0479d66e7c604afe37fc24ac6d9 100644
 3--- a/index.ts
 4+++ b/index.ts
 5@@ -149,13 +149,10 @@ export default async function (pi: ExtensionAPI) {
 6 		pendingContext.add(modelId);
 7 		const controller = new AbortController();
 8 		const timer = setTimeout(() => controller.abort(), PROPS_TIMEOUT_MS);
 9-		const propsBase = `${baseUrl.replace(/\/v1$/, "")}/props?model=${encodeURIComponent(modelId)}&autoload=`;
10+		const propsUrl = `${baseUrl.replace(/\/v1$/, "")}/props?model=${encodeURIComponent(modelId)}&autoload=true`;
11 
12 		try {
13-			let response = await fetch(`${propsBase}false`, { signal: controller.signal });
14-			if (response.status === 400 || response.status === 404) {
15-				response = await fetch(`${propsBase}true`, { signal: controller.signal });
16-			}
17+			const response = await fetch(propsUrl, { signal: controller.signal });
18 			if (!response.ok) {
19 				ctx.ui.notify(`[llama-cpp] /props for ${modelId} returned ${response.status}`, "error");
20 				return;