mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:21:10 +02:00
fix(local-llm): wrap @mlc-ai/web-llm in dynamic import for Docker builds
Move hasModelInCache to local-llm package with dynamic import wrapper so the browser-only dependency doesn't break server-side builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d574dda6a4
commit
919cb4bf35
3 changed files with 17 additions and 1 deletions
|
|
@ -10,6 +10,7 @@
|
|||
MODELS,
|
||||
type ModelKey,
|
||||
} from '@manacore/local-llm';
|
||||
import { hasModelInCache } from '@manacore/local-llm';
|
||||
import { marked } from 'marked';
|
||||
import { Robot, Trash, PaperPlaneRight, ClockCounterClockwise } from '@manacore/shared-icons';
|
||||
|
||||
|
|
@ -29,7 +30,6 @@
|
|||
if (typeof caches === 'undefined') return;
|
||||
for (const [key, config] of Object.entries(MODELS)) {
|
||||
try {
|
||||
const { hasModelInCache } = await import('@mlc-ai/web-llm');
|
||||
modelCacheStatus[key] = await hasModelInCache(config.modelId);
|
||||
} catch {
|
||||
modelCacheStatus[key] = false;
|
||||
|
|
|
|||
13
packages/local-llm/src/cache.ts
Normal file
13
packages/local-llm/src/cache.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Check if a model is cached in the browser's Cache API.
|
||||
* Wraps @mlc-ai/web-llm's hasModelInCache with a dynamic import
|
||||
* so it doesn't break SSR/Docker builds.
|
||||
*/
|
||||
export async function hasModelInCache(modelId: string): Promise<boolean> {
|
||||
try {
|
||||
const { hasModelInCache: check } = await import('@mlc-ai/web-llm');
|
||||
return await check(modelId);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,9 @@ export type {
|
|||
LoadingStatus,
|
||||
} from './types';
|
||||
|
||||
// Cache utilities
|
||||
export { hasModelInCache } from './cache';
|
||||
|
||||
// Svelte 5 reactive helpers
|
||||
export {
|
||||
getLocalLlmStatus,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue