@tryhamster/gerbil 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/browser/index.d.ts.map +1 -1
  2. package/dist/browser/index.js +10 -0
  3. package/dist/browser/index.js.map +1 -1
  4. package/dist/cli.mjs +7 -7
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/frameworks/express.mjs +1 -1
  7. package/dist/frameworks/fastify.mjs +1 -1
  8. package/dist/frameworks/hono.mjs +1 -1
  9. package/dist/frameworks/next.d.mts +2 -2
  10. package/dist/frameworks/next.mjs +1 -1
  11. package/dist/frameworks/trpc.mjs +1 -1
  12. package/dist/{gerbil-DU1aRO6v.d.mts → gerbil-CSk3AHNN.d.mts} +10 -9
  13. package/dist/{gerbil-DU1aRO6v.d.mts.map → gerbil-CSk3AHNN.d.mts.map} +1 -1
  14. package/dist/gerbil-DrV6iNcD.mjs +4 -0
  15. package/dist/{gerbil-Cgmb4Dit.mjs → gerbil-DtREprR_.mjs} +32 -10
  16. package/dist/gerbil-DtREprR_.mjs.map +1 -0
  17. package/dist/gpu/hooks.d.mts +16 -1
  18. package/dist/gpu/hooks.d.mts.map +1 -1
  19. package/dist/gpu/hooks.mjs +29 -4
  20. package/dist/gpu/hooks.mjs.map +1 -1
  21. package/dist/gpu/index.d.mts +1 -1
  22. package/dist/gpu/index.mjs +2 -2
  23. package/dist/{gpu-kQVLpV3n.mjs → gpu-NPdk7pmr.mjs} +221 -25
  24. package/dist/gpu-NPdk7pmr.mjs.map +1 -0
  25. package/dist/{index-ElJKy9i9.d.mts → index-B56xBiR2.d.mts} +96 -4
  26. package/dist/index-B56xBiR2.d.mts.map +1 -0
  27. package/dist/index.d.mts +2 -2
  28. package/dist/index.d.mts.map +1 -1
  29. package/dist/index.mjs +4 -4
  30. package/dist/integrations/ai-sdk.mjs +1 -1
  31. package/dist/integrations/langchain.mjs +1 -1
  32. package/dist/integrations/llamaindex.mjs +1 -1
  33. package/dist/integrations/mcp.d.mts +2 -2
  34. package/dist/integrations/mcp.mjs +4 -4
  35. package/dist/{mcp-DTusP2m5.mjs → mcp-XU4quJ9w.mjs} +3 -3
  36. package/dist/{mcp-DTusP2m5.mjs.map → mcp-XU4quJ9w.mjs.map} +1 -1
  37. package/dist/moonshine-stt-BRTnAoQ8.mjs +4 -0
  38. package/dist/{moonshine-stt-9wc6t11v.mjs → moonshine-stt-BYbYwSz2.mjs} +301 -13
  39. package/dist/moonshine-stt-BYbYwSz2.mjs.map +1 -0
  40. package/dist/{one-liner-Bk5x7gYH.mjs → one-liner-1WoJGLlZ.mjs} +2 -2
  41. package/dist/{one-liner-Bk5x7gYH.mjs.map → one-liner-1WoJGLlZ.mjs.map} +1 -1
  42. package/dist/{repl-DV6l-jT8.mjs → repl-B41yROa-.mjs} +3 -3
  43. package/dist/skills/index.d.mts +4 -4
  44. package/dist/skills/index.mjs +3 -3
  45. package/dist/{skills-BhcwnL2l.mjs → skills-C9RgR8qU.mjs} +2 -2
  46. package/dist/{skills-BhcwnL2l.mjs.map → skills-C9RgR8qU.mjs.map} +1 -1
  47. package/dist/tune/index.mjs +1 -1
  48. package/package.json +1 -1
  49. package/dist/gerbil-BFk5jV0h.mjs +0 -4
  50. package/dist/gerbil-Cgmb4Dit.mjs.map +0 -1
  51. package/dist/gpu-kQVLpV3n.mjs.map +0 -1
  52. package/dist/index-ElJKy9i9.d.mts.map +0 -1
  53. package/dist/moonshine-stt-9wc6t11v.mjs.map +0 -1
  54. package/dist/moonshine-stt-B7rDn6Q9.mjs +0 -4
@@ -143,7 +143,7 @@ async function decodeImage(src) {
143
143
  };
144
144
  }
145
145
  function useEngine(options = {}) {
146
- const { model: modelOption, maxSeqLen, dtype = "auto", autoLoad = false, enableVision = false, embedding = false, loadingTimeout = 3e5, onReady, onError } = options;
146
+ const { model: modelOption, maxSeqLen, dtype = "auto", autoLoad = false, enableVision = false, embedding = false, adapter = null, loadingTimeout = 3e5, onReady, onError } = options;
147
147
  const model = resolveDefaultRepo({
148
148
  repo: modelOption,
149
149
  embedding,
@@ -153,6 +153,7 @@ function useEngine(options = {}) {
153
153
  const stoppedRef = useRef(false);
154
154
  const timeoutRef = useRef(null);
155
155
  const heldKeyRef = useRef(null);
156
+ const appliedAdapterRef = useRef(null);
156
157
  const failedKeyRef = useRef(null);
157
158
  const [isLoading, setIsLoading] = useState(false);
158
159
  const [loadingProgress, setLoadingProgress] = useState(null);
@@ -394,17 +395,39 @@ function useEngine(options = {}) {
394
395
  return () => {
395
396
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
396
397
  engineRef.current = null;
398
+ appliedAdapterRef.current = null;
397
399
  if (heldKeyRef.current) {
398
400
  releaseSharedEngine(heldKeyRef.current);
399
401
  heldKeyRef.current = null;
400
402
  }
401
403
  };
402
404
  }, []);
405
+ useEffect(() => {
406
+ if (!isReady) return;
407
+ const engine = engineRef.current;
408
+ if (!engine || typeof engine.loadAdapter !== "function") return;
409
+ const target = adapter ?? null;
410
+ if (appliedAdapterRef.current === target) return;
411
+ let cancelled = false;
412
+ engine.loadAdapter(target).then(() => {
413
+ if (!cancelled) appliedAdapterRef.current = target;
414
+ }).catch((e) => {
415
+ if (!cancelled) fail(e);
416
+ });
417
+ return () => {
418
+ cancelled = true;
419
+ };
420
+ }, [
421
+ adapter,
422
+ isReady,
423
+ fail
424
+ ]);
403
425
  useEffect(() => {
404
426
  if (heldKeyRef.current === modelKey) return;
405
427
  failedKeyRef.current = null;
406
428
  if (heldKeyRef.current === null) return;
407
429
  engineRef.current = null;
430
+ appliedAdapterRef.current = null;
408
431
  releaseSharedEngine(heldKeyRef.current);
409
432
  heldKeyRef.current = null;
410
433
  setIsReady(false);
@@ -549,7 +572,7 @@ function useAgent(options) {
549
572
  * ```
550
573
  */
551
574
  function useAutocomplete(options) {
552
- const { model, debounceMs = 550, minChars = 8, maxTokens = 16, temperature = .3, autoLoad = false, maxSeqLen } = options;
575
+ const { model, debounceMs = 550, minChars = 8, maxTokens = 16, temperature = .3, repetitionPenalty = 1.25, autoLoad = false, maxSeqLen } = options;
553
576
  const engine = useEngine({
554
577
  model,
555
578
  autoLoad,
@@ -571,7 +594,8 @@ function useAutocomplete(options) {
571
594
  if (engine.error) return;
572
595
  const out = await engine.autocomplete(text, {
573
596
  maxTokens,
574
- temperature
597
+ temperature,
598
+ repetitionPenalty
575
599
  });
576
600
  if (requestedForRef.current !== text) return;
577
601
  if (out) setSuggestion(out);
@@ -583,7 +607,8 @@ function useAutocomplete(options) {
583
607
  engine,
584
608
  minChars,
585
609
  maxTokens,
586
- temperature
610
+ temperature,
611
+ repetitionPenalty
587
612
  ]);
588
613
  const onInput = useCallback((text) => {
589
614
  setSuggestion("");