fix: resolve 422 from Replicate + add local Cog Docker mode
- replicate-translate: parse owner/model:hash correctly — extract only
the hash portion for the version field, and use the model endpoint
(POST /v1/models/{owner}/{model}/predictions) which avoids 422
'Invalid version' errors when sending the full owner/model:hash string.
- Add local Cog mode: when replicateMode="local", calls the local Docker
container directly (no Replicate API key needed), default endpoint
http://localhost:5030/predictions (host port 5030 → container port 5000).
- settings-store: add replicateMode ("cloud"|"local") and localEndpoint
fields with env var fallbacks REPLICATE_MODE and LOCAL_MODEL_ENDPOINT.
- admin panel: Radio selector for Cloud vs Local mode; shows docker run
command snippet and local endpoint URL field when local is selected;
hides Replicate API token field in local mode (not needed).
Local model startup:
docker run -d -p 5030:5000 \
r8.im/jigsawstack/text-translate@sha256:454df4c...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export type ReplicateMode = "cloud" | "local";
|
||||
|
||||
export type Settings = {
|
||||
replicateApiToken: string;
|
||||
jigsawApiKey: string;
|
||||
modelVersion: string;
|
||||
replicateEnabled: boolean;
|
||||
replicateMode: ReplicateMode;
|
||||
localEndpoint: string;
|
||||
adminPasswordHash: string;
|
||||
};
|
||||
|
||||
@@ -14,6 +18,8 @@ const DEFAULT_SETTINGS: Settings = {
|
||||
jigsawApiKey: process.env["JIGSAWSTACK_API_KEY"] ?? "",
|
||||
modelVersion: "jigsawstack/text-translate:454df4c49941c05dea05175bd37686d0872c73c1f9366d1c2505db32ade52a89",
|
||||
replicateEnabled: false,
|
||||
replicateMode: (process.env["REPLICATE_MODE"] as ReplicateMode) ?? "cloud",
|
||||
localEndpoint: process.env["LOCAL_MODEL_ENDPOINT"] ?? "http://localhost:5030/predictions",
|
||||
adminPasswordHash: process.env["ADMIN_PASSWORD"] ?? "admin"
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user