Thomas G. Lopes commited on
Commit
7e80e42
·
1 Parent(s): 5e80fac

update and lint

Browse files
e2e/home.test.ts CHANGED
@@ -42,7 +42,7 @@ test.describe.serial("Token Handling and Subsequent Tests", () => {
42
  // Verify token is in localStorage
43
  const storedToken = await page.evaluate(
44
  key => JSON.parse(window.localStorage.getItem(key) ?? ""),
45
- HF_TOKEN_STORAGE_KEY
46
  );
47
  expect(storedToken).toBe(HF_TOKEN);
48
 
 
42
  // Verify token is in localStorage
43
  const storedToken = await page.evaluate(
44
  key => JSON.parse(window.localStorage.getItem(key) ?? ""),
45
+ HF_TOKEN_STORAGE_KEY,
46
  );
47
  expect(storedToken).toBe(HF_TOKEN);
48
 
eslint.config.mts CHANGED
@@ -96,5 +96,5 @@ export default ts.config(
96
  ...globals.node,
97
  },
98
  },
99
- }
100
  );
 
96
  ...globals.node,
97
  },
98
  },
99
+ },
100
  );
package.json CHANGED
@@ -22,7 +22,7 @@
22
  "@eslint/js": "^9.22.0",
23
  "@floating-ui/dom": "^1.6.13",
24
  "@huggingface/hub": "^2.1.0",
25
- "@huggingface/inference": "^4.4.0",
26
  "@huggingface/tasks": "^0.19.8",
27
  "@huggingface/transformers": "^3.5.1",
28
  "@iconify-json/carbon": "^1.2.8",
 
22
  "@eslint/js": "^9.22.0",
23
  "@floating-ui/dom": "^1.6.13",
24
  "@huggingface/hub": "^2.1.0",
25
+ "@huggingface/inference": "^4.5.3",
26
  "@huggingface/tasks": "^0.19.8",
27
  "@huggingface/transformers": "^3.5.1",
28
  "@iconify-json/carbon": "^1.2.8",
pnpm-lock.yaml CHANGED
@@ -34,8 +34,8 @@ importers:
34
  specifier: ^2.1.0
35
  version: 2.1.0
36
  '@huggingface/inference':
37
- specifier: ^4.4.0
38
- version: 4.4.0
39
  '@huggingface/tasks':
40
  specifier: ^0.19.8
41
  version: 0.19.8
@@ -589,20 +589,20 @@ packages:
589
  engines: {node: '>=18'}
590
  hasBin: true
591
 
592
- '@huggingface/inference@4.4.0':
593
- resolution: {integrity: sha512-YpkegUf1Mnrhkh+Tv47yIsA0+OEP73ODdn8GjMOG7Jf86y6MxO8LNGDVUUreg+Y4VgVq//j9j/tmENa8tYR4Dg==}
594
  engines: {node: '>=18'}
595
 
596
  '@huggingface/[email protected]':
597
  resolution: {integrity: sha512-3WXbMFaPkk03LRCM0z0sylmn8ddDm4ubjU7X+Hg4M2GOuMklwoGAFXp9V2keq7vltoB/c7McE5aHUVVddAewsw==}
598
  engines: {node: '>=18'}
599
 
600
- '@huggingface/[email protected].0':
601
- resolution: {integrity: sha512-Ptc03/jGRiYRoi0bUYKZ14MkDslsBRT24oxmsvUlfYrvQMldrxCevhPnT+hfX8awKTT8/f/0ZBBWldoeAcMHdQ==}
602
  engines: {node: '>=18'}
603
 
604
- '@huggingface/[email protected].22':
605
- resolution: {integrity: sha512-jtRXsJZTES01X4gJ5VOUnEm3ONyyfXUcWKObbWkr/SQmjaH/kxtWqc2zVWKaxL4QLoXqXJ+T+Pi5xupMStSudQ==}
606
 
607
  '@huggingface/[email protected]':
608
  resolution: {integrity: sha512-gR88OvYQQ2zu1Dt/tfFRVWJRfsKCdssxJBb8bz3tVd9fh3rneNE/pjkaGyG3oT1VlHv7wEmrqrnkmMcXy8O0rg==}
@@ -3548,16 +3548,16 @@ snapshots:
3548
  dependencies:
3549
  '@huggingface/tasks': 0.19.8
3550
 
3551
- '@huggingface/inference@4.4.0':
3552
  dependencies:
3553
- '@huggingface/jinja': 0.5.0
3554
- '@huggingface/tasks': 0.19.22
3555
 
3556
  '@huggingface/[email protected]': {}
3557
 
3558
- '@huggingface/[email protected].0': {}
3559
 
3560
- '@huggingface/[email protected].22': {}
3561
 
3562
  '@huggingface/[email protected]': {}
3563
 
 
34
  specifier: ^2.1.0
35
  version: 2.1.0
36
  '@huggingface/inference':
37
+ specifier: ^4.5.3
38
+ version: 4.5.3
39
  '@huggingface/tasks':
40
  specifier: ^0.19.8
41
  version: 0.19.8
 
589
  engines: {node: '>=18'}
590
  hasBin: true
591
 
592
+ '@huggingface/inference@4.5.3':
593
+ resolution: {integrity: sha512-SAWKT+e32jSfxwYkRaBQx1rlfgzkHCu0PXbCbOpY0Pvx6Si5wHia2BzZZdwgrpldaRbmFClxmNJy6lfCzQYfOw==}
594
  engines: {node: '>=18'}
595
 
596
  '@huggingface/[email protected]':
597
  resolution: {integrity: sha512-3WXbMFaPkk03LRCM0z0sylmn8ddDm4ubjU7X+Hg4M2GOuMklwoGAFXp9V2keq7vltoB/c7McE5aHUVVddAewsw==}
598
  engines: {node: '>=18'}
599
 
600
+ '@huggingface/[email protected].1':
601
+ resolution: {integrity: sha512-yUZLld4lrM9iFxHCwFQ7D1HW2MWMwSbeB7WzWqFYDWK+rEb+WldkLdAJxUPOmgICMHZLzZGVcVjFh3w/YGubng==}
602
  engines: {node: '>=18'}
603
 
604
+ '@huggingface/[email protected].26':
605
+ resolution: {integrity: sha512-E1+A6RIdfIS32tBjo+ReM61sZ5H3fHUDOH/gGO5uxvapjxaOns1IFtl+ESH8g9Tu+2HRmANoQ4bxli48igRAcA==}
606
 
607
  '@huggingface/[email protected]':
608
  resolution: {integrity: sha512-gR88OvYQQ2zu1Dt/tfFRVWJRfsKCdssxJBb8bz3tVd9fh3rneNE/pjkaGyG3oT1VlHv7wEmrqrnkmMcXy8O0rg==}
 
3548
  dependencies:
3549
  '@huggingface/tasks': 0.19.8
3550
 
3551
+ '@huggingface/inference@4.5.3':
3552
  dependencies:
3553
+ '@huggingface/jinja': 0.5.1
3554
+ '@huggingface/tasks': 0.19.26
3555
 
3556
  '@huggingface/[email protected]': {}
3557
 
3558
+ '@huggingface/[email protected].1': {}
3559
 
3560
+ '@huggingface/[email protected].26': {}
3561
 
3562
  '@huggingface/[email protected]': {}
3563
 
src/lib/attachments/observe.svelte.ts CHANGED
@@ -50,8 +50,8 @@ export const observed: Record<ObservedElements, ObservedData> = $state(
50
  };
51
  return acc;
52
  },
53
- {} as Record<ObservedElements, ObservedData>
54
- )
55
  );
56
 
57
  type ObserveArgs = {
 
50
  };
51
  return acc;
52
  },
53
+ {} as Record<ObservedElements, ObservedData>,
54
+ ),
55
  );
56
 
57
  type ObserveArgs = {
src/lib/components/inference-playground/conversation.svelte CHANGED
@@ -33,7 +33,7 @@
33
  } catch {
34
  // noop
35
  }
36
- }
37
  );
38
 
39
  async function regenMessage(idx: number) {
 
33
  } catch {
34
  // noop
35
  }
36
+ },
37
  );
38
 
39
  async function regenMessage(idx: number) {
src/lib/components/inference-playground/custom-model-config.svelte CHANGED
@@ -68,7 +68,7 @@
68
  if (prev === undefined) testSuccessful = exists;
69
  else testSuccessful = false;
70
  },
71
- { lazy: true }
72
  );
73
 
74
  let testing = $state(false);
 
68
  if (prev === undefined) testSuccessful = exists;
69
  else testSuccessful = false;
70
  },
71
+ { lazy: true },
72
  );
73
 
74
  let testing = $state(false);
src/lib/components/inference-playground/custom-provider-select.svelte CHANGED
@@ -71,7 +71,7 @@
71
  "focus-outline relative flex items-center justify-between gap-6 overflow-hidden rounded-lg border bg-gray-100/80 px-3 py-1.5 leading-tight whitespace-nowrap shadow-sm",
72
  "hover:brightness-95 dark:border-gray-700 dark:bg-gray-800 dark:hover:brightness-110",
73
  select.open && "!custom-outline",
74
- classes
75
  )}
76
  type="button"
77
  >
 
71
  "focus-outline relative flex items-center justify-between gap-6 overflow-hidden rounded-lg border bg-gray-100/80 px-3 py-1.5 leading-tight whitespace-nowrap shadow-sm",
72
  "hover:brightness-95 dark:border-gray-700 dark:bg-gray-800 dark:hover:brightness-110",
73
  select.open && "!custom-outline",
74
+ classes,
75
  )}
76
  type="button"
77
  >
src/lib/components/inference-playground/generation-config.svelte CHANGED
@@ -28,7 +28,7 @@
28
  max_tokens: maxTokens,
29
  },
30
  });
31
- }
32
  );
33
 
34
  type Config = (typeof conversation)["data"]["config"];
 
28
  max_tokens: maxTokens,
29
  },
30
  });
31
+ },
32
  );
33
 
34
  type Config = (typeof conversation)["data"]["config"];
src/lib/components/inference-playground/message.svelte CHANGED
@@ -34,7 +34,7 @@
34
  const canUploadImgs = $derived(
35
  message.role === "user" &&
36
  "pipeline_tag" in conversation.model &&
37
- conversation.model.pipeline_tag === PipelineTag.ImageTextToText
38
  );
39
 
40
  const fileQueue = new AsyncQueue();
 
34
  const canUploadImgs = $derived(
35
  message.role === "user" &&
36
  "pipeline_tag" in conversation.model &&
37
+ conversation.model.pipeline_tag === PipelineTag.ImageTextToText,
38
  );
39
 
40
  const fileQueue = new AsyncQueue();
src/lib/components/inference-playground/project-select.svelte CHANGED
@@ -67,7 +67,7 @@
67
  {...select.trigger}
68
  class={cn(
69
  "relative flex grow items-center justify-between gap-6 overflow-hidden rounded-lg border bg-gray-100/80 px-3 py-1.5 leading-tight whitespace-nowrap shadow-sm",
70
- "hover:brightness-95 dark:border-gray-700 dark:bg-gray-800 dark:hover:brightness-110"
71
  )}
72
  >
73
  <div class="flex items-center gap-1 text-sm">
 
67
  {...select.trigger}
68
  class={cn(
69
  "relative flex grow items-center justify-between gap-6 overflow-hidden rounded-lg border bg-gray-100/80 px-3 py-1.5 leading-tight whitespace-nowrap shadow-sm",
70
+ "hover:brightness-95 dark:border-gray-700 dark:bg-gray-800 dark:hover:brightness-110",
71
  )}
72
  >
73
  <div class="flex items-center gap-1 text-sm">
src/lib/components/inference-playground/provider-select.svelte CHANGED
@@ -89,7 +89,7 @@
89
  class={cn(
90
  "relative flex items-center justify-between gap-6 overflow-hidden rounded-lg border bg-gray-100/80 px-3 py-1.5 leading-tight whitespace-nowrap shadow-sm",
91
  "hover:brightness-95 dark:border-gray-700 dark:bg-gray-800 dark:hover:brightness-110",
92
- classes
93
  )}
94
  >
95
  <div class="flex items-center gap-1 text-sm">
 
89
  class={cn(
90
  "relative flex items-center justify-between gap-6 overflow-hidden rounded-lg border bg-gray-100/80 px-3 py-1.5 leading-tight whitespace-nowrap shadow-sm",
91
  "hover:brightness-95 dark:border-gray-700 dark:bg-gray-800 dark:hover:brightness-110",
92
+ classes,
93
  )}
94
  >
95
  <div class="flex items-center gap-1 text-sm">
src/lib/components/inference-playground/structured-output-modal.svelte CHANGED
@@ -71,7 +71,7 @@
71
  value: parseJsonSchema,
72
  onChange(v) {
73
  const required = Array.from(new Set(v.schema?.required)).filter(name =>
74
- keys(v.schema?.properties ?? {}).includes(name)
75
  );
76
  const validated: Schema = {
77
  schema: {
@@ -138,7 +138,7 @@
138
  const updatedProperties = renameKey(
139
  schemaObj.current.schema?.properties ?? {},
140
  propertyName,
141
- value
142
  );
143
  updateSchemaNested({ properties: updatedProperties });
144
  }
 
71
  value: parseJsonSchema,
72
  onChange(v) {
73
  const required = Array.from(new Set(v.schema?.required)).filter(name =>
74
+ keys(v.schema?.properties ?? {}).includes(name),
75
  );
76
  const validated: Schema = {
77
  schema: {
 
138
  const updatedProperties = renameKey(
139
  schemaObj.current.schema?.properties ?? {},
140
  propertyName,
141
+ value,
142
  );
143
  updateSchemaNested({ properties: updatedProperties });
144
  }
src/lib/components/share-modal.svelte CHANGED
@@ -58,7 +58,7 @@
58
  await sleep(100);
59
  encoded = encodeObject(fullProject);
60
  })();
61
- }
62
  );
63
  let pasted = $state("");
64
 
@@ -160,7 +160,7 @@
160
  ...omit(c, "id", "createdAt"),
161
  projectId,
162
  });
163
- })
164
  );
165
  projects.activeId = projectId;
166
  saving = false;
 
58
  await sleep(100);
59
  encoded = encodeObject(fullProject);
60
  })();
61
+ },
62
  );
63
  let pasted = $state("");
64
 
 
160
  ...omit(c, "id", "createdAt"),
161
  projectId,
162
  });
163
+ }),
164
  );
165
  projects.activeId = projectId;
166
  saving = false;
src/lib/remult.ts CHANGED
@@ -33,7 +33,7 @@ export function initRemultSvelteReactivity() {
33
  export class JsonEntityIndexedDbStorage implements JsonEntityStorage {
34
  constructor(
35
  private dbName: string = "db",
36
- private storeName: string = "jsonStore"
37
  ) {}
38
  supportsRawJson = true;
39
  //@internal
 
33
  export class JsonEntityIndexedDbStorage implements JsonEntityStorage {
34
  constructor(
35
  private dbName: string = "db",
36
+ private storeName: string = "jsonStore",
37
  ) {}
38
  supportsRawJson = true;
39
  //@internal
src/lib/server/providers/index.ts CHANGED
@@ -109,7 +109,7 @@ async function updateCache(provider: string, modelId: string, maxTokens: number)
109
  export async function getMaxTokens(
110
  provider: string,
111
  modelId: string,
112
- apiKey: string | undefined
113
  ): Promise<number | null> {
114
  const cache = await readCache();
115
  const cachedValue = cache[provider]?.[modelId];
 
109
  export async function getMaxTokens(
110
  provider: string,
111
  modelId: string,
112
+ apiKey: string | undefined,
113
  ): Promise<number | null> {
114
  const cache = await readCache();
115
  const cachedValue = cache[provider]?.[modelId];
src/lib/spells/extract.svelte.ts CHANGED
@@ -7,7 +7,7 @@ import type { MaybeGetter } from "$lib/types.js";
7
  */
8
  export function extract<T, D extends T>(
9
  value: MaybeGetter<T>,
10
- defaultValue?: D
11
  ): D extends undefined | null ? T : Exclude<T, undefined | null> | D {
12
  if (isFunction(value)) {
13
  const getter = value;
 
7
  */
8
  export function extract<T, D extends T>(
9
  value: MaybeGetter<T>,
10
+ defaultValue?: D,
11
  ): D extends undefined | null ? T : Exclude<T, undefined | null> | D {
12
  if (isFunction(value)) {
13
  const getter = value;
src/lib/spells/scroll-state.svelte.ts CHANGED
@@ -100,7 +100,7 @@ export class ScrollState {
100
  right: 0,
101
  top: 0,
102
  bottom: 0,
103
- })
104
  );
105
  onScroll = $derived(this.#options.onScroll ?? noop);
106
  onStop = $derived(this.#options.onStop ?? noop);
@@ -108,14 +108,14 @@ export class ScrollState {
108
  this.#options.eventListenerOptions ?? {
109
  capture: false,
110
  passive: true,
111
- }
112
  );
113
  behavior = $derived(extract(this.#options.behavior, "auto"));
114
  onError = $derived(
115
  this.#options.onError ??
116
  ((e: unknown) => {
117
  console.error(e);
118
- })
119
  );
120
 
121
  /** State */
@@ -162,14 +162,14 @@ export class ScrollState {
162
  "scroll",
163
  // throttle ? useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler,
164
  this.onScrollHandler,
165
- this.eventListenerOptions
166
  );
167
 
168
  useEventListener(
169
  () => this.element,
170
  "scrollend",
171
  e => this.onScrollEnd(e),
172
- this.eventListenerOptions
173
  );
174
 
175
  onMount(() => {
 
100
  right: 0,
101
  top: 0,
102
  bottom: 0,
103
+ }),
104
  );
105
  onScroll = $derived(this.#options.onScroll ?? noop);
106
  onStop = $derived(this.#options.onStop ?? noop);
 
108
  this.#options.eventListenerOptions ?? {
109
  capture: false,
110
  passive: true,
111
+ },
112
  );
113
  behavior = $derived(extract(this.#options.behavior, "auto"));
114
  onError = $derived(
115
  this.#options.onError ??
116
  ((e: unknown) => {
117
  console.error(e);
118
+ }),
119
  );
120
 
121
  /** State */
 
162
  "scroll",
163
  // throttle ? useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler,
164
  this.onScrollHandler,
165
+ this.eventListenerOptions,
166
  );
167
 
168
  useEventListener(
169
  () => this.element,
170
  "scrollend",
171
  e => this.onScrollEnd(e),
172
+ this.eventListenerOptions,
173
  );
174
 
175
  onMount(() => {
src/lib/spells/textarea-autosize.svelte.ts CHANGED
@@ -43,7 +43,7 @@ export class TextareaAutosize {
43
 
44
  watch(
45
  () => this.textareaHeight,
46
- () => options?.onResize?.()
47
  );
48
 
49
  useResizeObserver(
@@ -55,7 +55,7 @@ export class TextareaAutosize {
55
 
56
  this.textareaOldWidth = contentRect.width;
57
  this.triggerResize();
58
- }
59
  );
60
 
61
  onDestroy(() => {
 
43
 
44
  watch(
45
  () => this.textareaHeight,
46
+ () => options?.onResize?.(),
47
  );
48
 
49
  useResizeObserver(
 
55
 
56
  this.textareaOldWidth = contentRect.width;
57
  this.triggerResize();
58
+ },
59
  );
60
 
61
  onDestroy(() => {
src/lib/state/checkpoints.svelte.ts CHANGED
@@ -60,7 +60,7 @@ class Checkpoints {
60
  conversations: conversations.for(project.id).map(c => c.data),
61
  timestamp: new Date(),
62
  projectId: project.id,
63
- })
64
  );
65
 
66
  // Hack because dates are formatted to string by save
 
60
  conversations: conversations.for(project.id).map(c => c.data),
61
  timestamp: new Date(),
62
  projectId: project.id,
63
+ }),
64
  );
65
 
66
  // Hack because dates are formatted to string by save
src/lib/state/conversations.svelte.ts CHANGED
@@ -195,7 +195,7 @@ export class ConversationClass {
195
  this.updateMessage({ index, message: streamingMessage });
196
  }
197
  },
198
- this.abortManager.createController()
199
  );
200
  } else {
201
  const { message: newMessage, completion_tokens: newTokensCount } = await handleNonStreamingResponse(this);
@@ -273,7 +273,7 @@ class Conversations {
273
  }
274
 
275
  create = async (
276
- args: { projectId: ProjectEntity["id"]; modelId?: Model["id"] } & Partial<ConversationEntityMembers>
277
  ) => {
278
  const conv = snapshot({
279
  ...getDefaultConversation(args.projectId),
@@ -348,7 +348,7 @@ class Conversations {
348
  await Promise.allSettled(
349
  fromArr.map(async c => {
350
  conversations.create({ ...c.data, projectId: to });
351
- })
352
  );
353
  };
354
 
 
195
  this.updateMessage({ index, message: streamingMessage });
196
  }
197
  },
198
+ this.abortManager.createController(),
199
  );
200
  } else {
201
  const { message: newMessage, completion_tokens: newTokensCount } = await handleNonStreamingResponse(this);
 
273
  }
274
 
275
  create = async (
276
+ args: { projectId: ProjectEntity["id"]; modelId?: Model["id"] } & Partial<ConversationEntityMembers>,
277
  ) => {
278
  const conv = snapshot({
279
  ...getDefaultConversation(args.projectId),
 
348
  await Promise.allSettled(
349
  fromArr.map(async c => {
350
  conversations.create({ ...c.data, projectId: to });
351
+ }),
352
  );
353
  };
354
 
src/lib/utils/object.svelte.ts CHANGED
@@ -88,7 +88,7 @@ export function deepMerge<T extends DeepMergeable, U extends DeepMergeable>(targ
88
  export function renameKey<T extends object>(
89
  obj: T,
90
  oldKey: keyof T,
91
- newKey: string
92
  ): { [K in keyof T as K extends typeof oldKey ? typeof newKey : K]: T[K] } {
93
  const entries = Object.entries(obj);
94
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
 
88
  export function renameKey<T extends object>(
89
  obj: T,
90
  oldKey: keyof T,
91
+ newKey: string,
92
  ): { [K in keyof T as K extends typeof oldKey ? typeof newKey : K]: T[K] } {
93
  const entries = Object.entries(obj);
94
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
src/lib/utils/poll.ts CHANGED
@@ -6,7 +6,7 @@
6
  */
7
  export async function poll<T>(
8
  predicate: () => T | Promise<T>,
9
- options: { interval?: number; maxAttempts?: number } = {}
10
  ): Promise<T | undefined> {
11
  const { interval = 10, maxAttempts = 200 } = options;
12
 
 
6
  */
7
  export async function poll<T>(
8
  predicate: () => T | Promise<T>,
9
+ options: { interval?: number; maxAttempts?: number } = {},
10
  ): Promise<T | undefined> {
11
  const { interval = 10, maxAttempts = 200 } = options;
12
 
src/lib/utils/snippets.ts CHANGED
@@ -64,7 +64,7 @@ function insertPropertiesInternal(
64
  openChar: string, // The opening character, e.g., '{' or '('
65
  closeChar: string, // The closing character, e.g., '}' or ')'
66
  propFormatter: (key: string, formattedValue: string, indent: string) => string,
67
- valueFormatter: (value: unknown, baseIndent: string) => string
68
  ): string {
69
  if (Object.keys(newProperties).length === 0) {
70
  return snippet;
@@ -215,7 +215,7 @@ export function modifySnippet(snippet: string, newProperties: Record<string, unk
215
  "{", // The parameters are in an object literal
216
  "}",
217
  (key, value, indent) => `${indent}${key}: ${value},\n`, // JS object literal style
218
- formatJsJsonValue
219
  );
220
  }
221
  // JS: HuggingFace InferenceClient (non-streaming)
@@ -228,7 +228,7 @@ export function modifySnippet(snippet: string, newProperties: Record<string, unk
228
  "{", // The parameters are in an object literal
229
  "}",
230
  (key, value, indent) => `${indent}${key}: ${value},\n`, // JS object literal style
231
- formatJsJsonValue
232
  );
233
  }
234
  // JS: OpenAI Client
@@ -244,7 +244,7 @@ export function modifySnippet(snippet: string, newProperties: Record<string, unk
244
  "{", // The parameters are in an object literal
245
  "}",
246
  (key, value, indent) => `${indent}${key}: ${value},\n`,
247
- formatJsJsonValue
248
  );
249
  }
250
  // Python: OpenAI or HuggingFace Client using client.chat.completions.create
@@ -259,7 +259,7 @@ export function modifySnippet(snippet: string, newProperties: Record<string, unk
259
  const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
260
  return `${indent}${snakeKey}=${value},\n`;
261
  },
262
- formatPythonValue
263
  );
264
  }
265
  // Python: requests example with query({...})
@@ -272,7 +272,7 @@ export function modifySnippet(snippet: string, newProperties: Record<string, unk
272
  "}",
273
  // Python dict keys are strings, values formatted for Python
274
  (key, formattedValue, indent) => `${indent}"${key}": ${formattedValue},\n`,
275
- formatPythonValue // Use formatPythonValue for the values themselves
276
  );
277
  }
278
  // Shell/curl (JSON content)
@@ -287,7 +287,7 @@ export function modifySnippet(snippet: string, newProperties: Record<string, unk
287
  const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
288
  return `${indent}"${snakeKey}": ${value},\n`;
289
  },
290
- formatJsJsonValue
291
  );
292
  }
293
  return snippet;
 
64
  openChar: string, // The opening character, e.g., '{' or '('
65
  closeChar: string, // The closing character, e.g., '}' or ')'
66
  propFormatter: (key: string, formattedValue: string, indent: string) => string,
67
+ valueFormatter: (value: unknown, baseIndent: string) => string,
68
  ): string {
69
  if (Object.keys(newProperties).length === 0) {
70
  return snippet;
 
215
  "{", // The parameters are in an object literal
216
  "}",
217
  (key, value, indent) => `${indent}${key}: ${value},\n`, // JS object literal style
218
+ formatJsJsonValue,
219
  );
220
  }
221
  // JS: HuggingFace InferenceClient (non-streaming)
 
228
  "{", // The parameters are in an object literal
229
  "}",
230
  (key, value, indent) => `${indent}${key}: ${value},\n`, // JS object literal style
231
+ formatJsJsonValue,
232
  );
233
  }
234
  // JS: OpenAI Client
 
244
  "{", // The parameters are in an object literal
245
  "}",
246
  (key, value, indent) => `${indent}${key}: ${value},\n`,
247
+ formatJsJsonValue,
248
  );
249
  }
250
  // Python: OpenAI or HuggingFace Client using client.chat.completions.create
 
259
  const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
260
  return `${indent}${snakeKey}=${value},\n`;
261
  },
262
+ formatPythonValue,
263
  );
264
  }
265
  // Python: requests example with query({...})
 
272
  "}",
273
  // Python dict keys are strings, values formatted for Python
274
  (key, formattedValue, indent) => `${indent}"${key}": ${formattedValue},\n`,
275
+ formatPythonValue, // Use formatPythonValue for the values themselves
276
  );
277
  }
278
  // Shell/curl (JSON content)
 
287
  const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
288
  return `${indent}"${snakeKey}": ${value},\n`;
289
  },
290
+ formatJsJsonValue,
291
  );
292
  }
293
  return snippet;
src/routes/api/models/+server.ts CHANGED
@@ -145,7 +145,7 @@ export const GET: RequestHandler = async ({ fetch }) => {
145
  } else {
146
  textGenModels = await response.json();
147
  }
148
- })
149
  );
150
  }
151
 
@@ -158,7 +158,7 @@ export const GET: RequestHandler = async ({ fetch }) => {
158
  } else {
159
  imgText2TextModels = await response.json();
160
  }
161
- })
162
  );
163
  }
164
 
@@ -191,7 +191,7 @@ export const GET: RequestHandler = async ({ fetch }) => {
191
  }
192
 
193
  const models: Model[] = [...textGenModels, ...imgText2TextModels].filter(
194
- m => m.inferenceProviderMapping.length > 0
195
  );
196
  models.sort((a, b) => a.id.toLowerCase().localeCompare(b.id.toLowerCase()));
197
 
@@ -209,7 +209,7 @@ export const GET: RequestHandler = async ({ fetch }) => {
209
  console.log(
210
  `Cache updated: ${models.length} models, status: ${cacheStatus}, ` +
211
  `failed tokenizers: ${newFailedTokenizers.length}, ` +
212
- `API failures: text=${newFailedApiCalls.textGeneration}, img=${newFailedApiCalls.imageTextToText}`
213
  );
214
 
215
  return createResponse({ models });
 
145
  } else {
146
  textGenModels = await response.json();
147
  }
148
+ }),
149
  );
150
  }
151
 
 
158
  } else {
159
  imgText2TextModels = await response.json();
160
  }
161
+ }),
162
  );
163
  }
164
 
 
191
  }
192
 
193
  const models: Model[] = [...textGenModels, ...imgText2TextModels].filter(
194
+ m => m.inferenceProviderMapping.length > 0,
195
  );
196
  models.sort((a, b) => a.id.toLowerCase().localeCompare(b.id.toLowerCase()));
197
 
 
209
  console.log(
210
  `Cache updated: ${models.length} models, status: ${cacheStatus}, ` +
211
  `failed tokenizers: ${newFailedTokenizers.length}, ` +
212
+ `API failures: text=${newFailedApiCalls.textGeneration}, img=${newFailedApiCalls.imageTextToText}`,
213
  );
214
 
215
  return createResponse({ models });