Skip to content

Commit 1fba570

Browse files
committed
Simplify dockerfile, fix config update on changes in settings
1 parent cce3add commit 1fba570

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

Dockerfile

+1-15
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,14 @@ RUN cd ./packages/litlytics && bun install --frozen-lockfile && bun run build
1111
RUN bun install --frozen-lockfile --ignore-scripts
1212

1313
# build app
14-
FROM base AS build
15-
ENV CI=true
16-
ENV NODE_ENV=production
17-
18-
WORKDIR /app
1914
COPY . .
2015
RUN bun run build
2116

2217
# run app
23-
FROM node:22-slim AS runner
24-
ENV CI=true
25-
ENV NODE_ENV=production
26-
2718
WORKDIR /app
2819

29-
COPY --from=base /app/node_modules /app/node_modules
30-
COPY --from=build /app/build /app/build
31-
COPY --from=build /app/public /app/public
32-
COPY . .
33-
3420
EXPOSE 3000
3521
ENV HOSTNAME=0.0.0.0
3622
ENV PORT=3000
3723

38-
CMD ["npm", "run", "start"]
24+
CMD ["bun", "run", "start"]

app/store/WithLitLytics.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ export function WithLitLytics({ children }: { children: React.ReactNode }) {
5959
ll.setWebEngine(webllm.engine);
6060
}, [isInited, config, webllm, setIsInited, setLitlytics, setConfig]);
6161

62+
// update config / llm on changes
63+
useEffect(() => {
64+
// assign updated config
65+
const cfg = litlytics.exportConfig();
66+
if (
67+
cfg.provider !== config.provider ||
68+
cfg.model !== config.model ||
69+
cfg.llmKey !== config.llmKey
70+
) {
71+
litlytics.importConfig(config);
72+
}
73+
// assign webllm engine
74+
if (litlytics.getEngine() !== webllm.engine) {
75+
litlytics.setWebEngine(webllm.engine);
76+
}
77+
}, [config, webllm, litlytics]);
78+
6279
return (
6380
<LitLyticsContext.Provider value={{ litlytics }}>
6481
{children}

packages/litlytics/litlytics.ts

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ export class LitLytics {
119119
this._pipeline = config.pipeline ?? this._pipeline ?? emptyPipeline;
120120
};
121121

122+
getEngine = (): MLCEngine | undefined => {
123+
return this._engine;
124+
};
125+
122126
setWebEngine = (engine?: MLCEngine) => {
123127
this._engine = engine;
124128
};

0 commit comments

Comments
 (0)