Skip to content

Commit de75009

Browse files
juliethecaoCopilot
andauthored
fix(frontend): use observe: "response" to access HuggingFace response headers and body
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Julie Cao <116243642+juliethecao@users.noreply.github.com>
1 parent 339130b commit de75009

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,18 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
356356
this.cdr.detectChanges();
357357

358358
this.subscription = this.http
359-
.get<
360-
HuggingFaceModelOption[]
361-
>(`${AppSettings.getApiEndpoint()}/huggingface/models?task=${encodeURIComponent(tag)}`)
359+
.get<HuggingFaceModelOption[]>(
360+
`${AppSettings.getApiEndpoint()}/huggingface/models?task=${encodeURIComponent(tag)}`,
361+
{ observe: "response" }
362+
)
363+
.pipe(finalize(() => inFlightByTag.delete(tag)))
362364
.subscribe({
363365
next: resp => {
364366
const models = resp.body ?? [];
365367
if (resp.headers.get(TRUNCATED_HEADER) === "true") {
366368
truncatedByTag.add(tag);
367369
}
368370
allModelsByTag.set(tag, models);
369-
inFlightByTag.delete(tag);
370371
this.loading = false;
371372
this.truncated = truncatedByTag.has(tag);
372373
this.allModels = models;
@@ -376,7 +377,6 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
376377
console.error(`Failed to load HuggingFace models for task '${tag}':`, err);
377378
const msg = "Failed to load models. Click retry to try again.";
378379
errorByTag.set(tag, msg);
379-
inFlightByTag.delete(tag);
380380
this.loading = false;
381381
this.errorMessage = msg;
382382
this.cdr.detectChanges();

0 commit comments

Comments
 (0)