machineuser commited on
Commit
980d629
1 Parent(s): 0f711ba

Sync widgets demo

Browse files
packages/widgets/src/lib/components/InferenceWidget/shared/helpers.ts CHANGED
@@ -1,6 +1,6 @@
1
  import type { ModelData, WidgetExampleAttribute } from "@huggingface/tasks";
2
  import { parseJSON } from "../../../utils/ViewUtils.js";
3
- import type { ModelLoadInfo, TableData } from "./types.js";
4
  import { LoadState } from "./types.js";
5
 
6
  const KEYS_TEXT: WidgetExampleAttribute[] = ["text", "context", "candidate_labels"];
@@ -173,11 +173,21 @@ export async function getModelLoadInfo(
173
  const response = await fetch(`${url}/status/${repoId}`, {
174
  credentials: includeCredentials ? "include" : "same-origin",
175
  });
176
- const output = await response.json();
 
 
 
 
 
177
  if (response.ok && typeof output === "object" && output.loaded !== undefined) {
178
  // eslint-disable-next-line @typescript-eslint/naming-convention
179
- const { state, compute_type } = output;
180
- return { compute_type, state };
 
 
 
 
 
181
  } else {
182
  console.warn(response.status, output.error);
183
  return { state: LoadState.Error };
 
1
  import type { ModelData, WidgetExampleAttribute } from "@huggingface/tasks";
2
  import { parseJSON } from "../../../utils/ViewUtils.js";
3
+ import { ComputeType, type ModelLoadInfo, type TableData } from "./types.js";
4
  import { LoadState } from "./types.js";
5
 
6
  const KEYS_TEXT: WidgetExampleAttribute[] = ["text", "context", "candidate_labels"];
 
173
  const response = await fetch(`${url}/status/${repoId}`, {
174
  credentials: includeCredentials ? "include" : "same-origin",
175
  });
176
+ const output: {
177
+ state: LoadState;
178
+ compute_type: ComputeType | Record<ComputeType, { [key in ComputeType]?: string } & { count: number }>;
179
+ loaded: boolean;
180
+ error: Error;
181
+ } = await response.json();
182
  if (response.ok && typeof output === "object" && output.loaded !== undefined) {
183
  // eslint-disable-next-line @typescript-eslint/naming-convention
184
+ const compute_type =
185
+ typeof output.compute_type === "string"
186
+ ? output.compute_type
187
+ : output.compute_type["gpu"]
188
+ ? ComputeType.GPU
189
+ : ComputeType.CPU;
190
+ return { compute_type, state: output.state };
191
  } else {
192
  console.warn(response.status, output.error);
193
  return { state: LoadState.Error };
packages/widgets/src/routes/+page.svelte CHANGED
@@ -77,6 +77,11 @@
77
  },
78
  ],
79
  },
 
 
 
 
 
80
  {
81
  id: "microsoft/phi-2",
82
  pipeline_tag: "text-generation",
 
77
  },
78
  ],
79
  },
80
+ {
81
+ id: "google/gemma-7b",
82
+ pipeline_tag: "text-generation",
83
+ inference: InferenceDisplayability.Yes,
84
+ },
85
  {
86
  id: "microsoft/phi-2",
87
  pipeline_tag: "text-generation",