mirror of
https://github.com/Anil-matcha/Open-Generative-AI.git
synced 2026-05-07 01:17:18 +00:00
Bundles three changes that were originally landed as stacked PRs into peer branches and never reached main. Combined here as a single PR targeting main. worker/index.js (new) --------------------- Long-lived Node process that: - Polls Postgres every 2s for batches in status='running'. - Claims queued jobs with SELECT ... FOR UPDATE SKIP LOCKED (single worker today, ready for N-worker scale tomorrow with no further code change). - Re-uploads local-only trainer images (/api/uploads/...) to MuAPI's /upload_file once and caches the resulting CDN URL on the trainer row so future jobs reuse it. - Submits POST /api/v1/<batch.model> with prompt, images_list, aspect_ratio, duration, quality. - Polls /api/v1/predictions/:id/result, extracts videoUrl from outputs[0]/url/output.url/video_url on success. - Backoff: min(10 * 3^retries, 300)s. After retries >= 3, status= 'failed', waiting for manual Retry from the UI. - Recovery on boot: re-queues anything left in 'submitting' from a crashed run; 'polling' jobs keep their muapiRequestId. Configuration: MUAPI_API_KEY (required to do work), MUAPI_BASE_URL (default https://api.muapi.ai), WORKER_TICK_MS (default 2000), UPLOAD_DIR (default /data/uploads). worker/package.json: { "type": "module" } so plain Node 20 runs the ESM imports. Dockerfile: copy /app/worker into the runner stage. docker-compose.override.yml: replace placeholder with the real 'npx prisma generate && node worker/index.js'. lib/promptTemplate.js (new) + worker integration ------------------------------------------------ renderPrompt({trainer, studio, job}) wraps each row's raw practice description in a fixed narrative template that pins identity, biomechanics, environment, lighting, clothing, expression, video style, and a list of forbidden behaviours (no camera movement, no cuts, no limb warping, no pose distortion, etc). duration, aspect_ratio, and quality remain SEPARATE fields in the MuAPI request body; they are never injected into the prompt text. lib/csvParser.js: stops appending 'Start position: ... Camera: ...' into the stored prompt. Just stores the raw practice description; startPosition + cameraAngle remain available as their own columns for the renderer to consume. components/SectionSwitcher.jsx (new) ------------------------------------ Two-pill switcher (Studio · Batch) rendered in the top-left of every shell. Active pill is yellow on black. Click writes the choice to localStorage so the home hub can highlight 'Last used'. StandaloneShell, BatchShell, BatchDetail headers all updated to host the switcher next to the logo. The redundant '← Studio' link in BatchShell's right-side actions is removed since the switcher replaces it. app/page.js + components/HomeHub.jsx ------------------------------------ / used to redirect to /studio. Now serves a hub with two cards: Batch (CSV-driven automation) and Studio (one-off generations). The card the user last opened gets a yellow accent + 'Last used' tag from localStorage. Stub-package copy ----------------- packages/ai-agent and packages/workflow-ui description strings and runtime 'feature unavailable' notices: removed organization-specific phrasing in favour of generic 'this fork' wording.
41 lines
1.1 KiB
Docker
41 lines
1.1 KiB
Docker
# syntax=docker/dockerfile:1.6
|
|
|
|
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
RUN apk add --no-cache libc6-compat
|
|
COPY package.json package-lock.json ./
|
|
COPY packages ./packages
|
|
RUN npm ci --legacy-peer-deps
|
|
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/packages ./packages
|
|
COPY . .
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/packages ./packages
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/lib ./lib
|
|
COPY --from=builder /app/worker ./worker
|
|
COPY --from=builder /app/package.json ./
|
|
COPY --from=builder /app/next.config.mjs ./
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
CMD ["npm", "start"]
|