Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
5ca5202
1
Parent(s):
e674d19
fix
Browse files- .env +6 -6
- Dockerfile +3 -0
- src/config.mts +19 -0
- src/index.mts +1 -19
- src/providers/image-generation/generateImageSDXL.mts +3 -2
.env
CHANGED
@@ -8,22 +8,22 @@ VC_STORAGE_PATH="/data/"
|
|
8 |
|
9 |
#--------------------- AUTH SECRETS AND ACCESS TOKENS -------------
|
10 |
# The access token required to send some queries to VideoChain
|
11 |
-
VC_SECRET_ACCESS_TOKEN="<USE YOUR OWN>"
|
12 |
|
13 |
# The access token required to send queries to some sub-servers
|
14 |
-
VC_MICROSERVICE_SECRET_TOKEN="<USE YOUR OWN>"
|
15 |
|
16 |
# OpenAI API key used to call OpenAI API services
|
17 |
-
VC_OPENAI_API_KEY="<USE YOUR OWN>"
|
18 |
|
19 |
# Hugging Face API key used to call Hugging Face spaces
|
20 |
-
VC_HF_API_TOKEN="<USE YOUR OWN>"
|
21 |
|
22 |
# Replicate API token
|
23 |
-
VC_REPLICATE_API_TOKEN="<USE YOUR OWN>"
|
24 |
|
25 |
#--------------------- LLM INFERENCE SERVERS ----------------------
|
26 |
-
VC_INFERENCE_ENDPOINT_URL="<USE YOUR OWN>"
|
27 |
|
28 |
#--------------------- SDXL INFERENCE SERVERS ---------------------
|
29 |
VC_SDXL_SPACE_API_URL_1="https://jbilcke-hf-image-server-1.hf.space"
|
|
|
8 |
|
9 |
#--------------------- AUTH SECRETS AND ACCESS TOKENS -------------
|
10 |
# The access token required to send some queries to VideoChain
|
11 |
+
#VC_SECRET_ACCESS_TOKEN="<USE YOUR OWN>"
|
12 |
|
13 |
# The access token required to send queries to some sub-servers
|
14 |
+
#VC_MICROSERVICE_SECRET_TOKEN="<USE YOUR OWN>"
|
15 |
|
16 |
# OpenAI API key used to call OpenAI API services
|
17 |
+
#VC_OPENAI_API_KEY="<USE YOUR OWN>"
|
18 |
|
19 |
# Hugging Face API key used to call Hugging Face spaces
|
20 |
+
#VC_HF_API_TOKEN="<USE YOUR OWN>"
|
21 |
|
22 |
# Replicate API token
|
23 |
+
#VC_REPLICATE_API_TOKEN="<USE YOUR OWN>"
|
24 |
|
25 |
#--------------------- LLM INFERENCE SERVERS ----------------------
|
26 |
+
#VC_INFERENCE_ENDPOINT_URL="<USE YOUR OWN>"
|
27 |
|
28 |
#--------------------- SDXL INFERENCE SERVERS ---------------------
|
29 |
VC_SDXL_SPACE_API_URL_1="https://jbilcke-hf-image-server-1.hf.space"
|
Dockerfile
CHANGED
@@ -29,6 +29,9 @@ WORKDIR $HOME/app
|
|
29 |
# where available (npm@5+)
|
30 |
COPY --chown=user package*.json $HOME/app
|
31 |
|
|
|
|
|
|
|
32 |
RUN npm install
|
33 |
|
34 |
|
|
|
29 |
# where available (npm@5+)
|
30 |
COPY --chown=user package*.json $HOME/app
|
31 |
|
32 |
+
# make sure the .env is copied as well
|
33 |
+
COPY --chown=user .env $HOME/app
|
34 |
+
|
35 |
RUN npm install
|
36 |
|
37 |
|
src/config.mts
CHANGED
@@ -1,4 +1,23 @@
|
|
1 |
import path from "node:path"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
export const storagePath = `${process.env.VC_STORAGE_PATH || './sandbox'}`
|
4 |
|
|
|
1 |
import path from "node:path"
|
2 |
+
import fs from "node:fs"
|
3 |
+
|
4 |
+
import dotenv from "dotenv"
|
5 |
+
|
6 |
+
dotenv.config()
|
7 |
+
|
8 |
+
try {
|
9 |
+
if (fs.existsSync(".env.local")) {
|
10 |
+
const result = dotenv.config({ path: ".env.local" })
|
11 |
+
console.log("using .env.local")
|
12 |
+
process.env = {
|
13 |
+
...process.env,
|
14 |
+
...result.parsed,
|
15 |
+
}
|
16 |
+
}
|
17 |
+
} catch (err) {
|
18 |
+
// do nothing
|
19 |
+
console.log("using .env")
|
20 |
+
}
|
21 |
|
22 |
export const storagePath = `${process.env.VC_STORAGE_PATH || './sandbox'}`
|
23 |
|
src/index.mts
CHANGED
@@ -1,27 +1,10 @@
|
|
1 |
import { createReadStream, existsSync } from "node:fs"
|
2 |
import path from "node:path"
|
3 |
-
import fs from "node:fs"
|
4 |
|
5 |
import { validate as uuidValidate } from "uuid"
|
6 |
import express from "express"
|
7 |
|
8 |
-
import
|
9 |
-
|
10 |
-
dotenv.config()
|
11 |
-
|
12 |
-
try {
|
13 |
-
if (fs.existsSync(".env.local")) {
|
14 |
-
const result = dotenv.config({ path: ".env.local" })
|
15 |
-
console.log("using .env.local")
|
16 |
-
process.env = {
|
17 |
-
...process.env,
|
18 |
-
...result.parsed,
|
19 |
-
}
|
20 |
-
}
|
21 |
-
} catch (err) {
|
22 |
-
// do nothing
|
23 |
-
console.log("using .env")
|
24 |
-
}
|
25 |
|
26 |
import { Video, VideoStatus, VideoAPIRequest, RenderRequest, RenderedScene, ImageAnalysisRequest, ImageAnalysisResponse, SoundAnalysisResponse, SoundAnalysisRequest } from "./types.mts"
|
27 |
|
@@ -29,7 +12,6 @@ import { parseVideoRequest } from "./utils/requests/parseVideoRequest.mts"
|
|
29 |
import { savePendingVideo } from "./scheduler/savePendingVideo.mts"
|
30 |
import { getVideo } from "./scheduler/getVideo.mts"
|
31 |
import { main } from "./main.mts"
|
32 |
-
import { completedFilesDirFilePath } from "./config.mts"
|
33 |
import { markVideoAsToDelete } from "./scheduler/markVideoAsToDelete.mts"
|
34 |
import { markVideoAsToAbort } from "./scheduler/markVideoAsToAbort.mts"
|
35 |
import { markVideoAsToPause } from "./scheduler/markVideoAsToPause.mts"
|
|
|
1 |
import { createReadStream, existsSync } from "node:fs"
|
2 |
import path from "node:path"
|
|
|
3 |
|
4 |
import { validate as uuidValidate } from "uuid"
|
5 |
import express from "express"
|
6 |
|
7 |
+
import { completedFilesDirFilePath } from "./config.mts"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
import { Video, VideoStatus, VideoAPIRequest, RenderRequest, RenderedScene, ImageAnalysisRequest, ImageAnalysisResponse, SoundAnalysisResponse, SoundAnalysisRequest } from "./types.mts"
|
10 |
|
|
|
12 |
import { savePendingVideo } from "./scheduler/savePendingVideo.mts"
|
13 |
import { getVideo } from "./scheduler/getVideo.mts"
|
14 |
import { main } from "./main.mts"
|
|
|
15 |
import { markVideoAsToDelete } from "./scheduler/markVideoAsToDelete.mts"
|
16 |
import { markVideoAsToAbort } from "./scheduler/markVideoAsToAbort.mts"
|
17 |
import { markVideoAsToPause } from "./scheduler/markVideoAsToPause.mts"
|
src/providers/image-generation/generateImageSDXL.mts
CHANGED
@@ -4,8 +4,7 @@ import { generateSeed } from "../../utils/misc/generateSeed.mts"
|
|
4 |
import { getValidNumber } from "../../utils/validators/getValidNumber.mts"
|
5 |
|
6 |
// TODO add a system to mark failed instances as "unavailable" for a couple of minutes
|
7 |
-
|
8 |
-
|
9 |
|
10 |
// note: to reduce costs I use the small A10s (not the large)
|
11 |
// anyway, we will soon not need to use this cloud anymore
|
@@ -33,6 +32,8 @@ const instances: string[] = [
|
|
33 |
|
34 |
const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`
|
35 |
|
|
|
|
|
36 |
export async function generateImageSDXLAsBase64(options: {
|
37 |
positivePrompt: string;
|
38 |
negativePrompt?: string;
|
|
|
4 |
import { getValidNumber } from "../../utils/validators/getValidNumber.mts"
|
5 |
|
6 |
// TODO add a system to mark failed instances as "unavailable" for a couple of minutes
|
7 |
+
console.log("process.env:", process.env)
|
|
|
8 |
|
9 |
// note: to reduce costs I use the small A10s (not the large)
|
10 |
// anyway, we will soon not need to use this cloud anymore
|
|
|
32 |
|
33 |
const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`
|
34 |
|
35 |
+
console.log("DEBUG:", JSON.stringify({ instances, secretToken }, null, 2))
|
36 |
+
|
37 |
export async function generateImageSDXLAsBase64(options: {
|
38 |
positivePrompt: string;
|
39 |
negativePrompt?: string;
|