@slopmachine/core 0.1.12 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
- package/src/index.ts +82 -3
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,12 @@ interface SlopImageOptions {
|
|
|
29
29
|
* E.g., if prompt is "A photo of a {color} dog", pass { color: "brown" }.
|
|
30
30
|
*/
|
|
31
31
|
variables?: Record<string, string | number | undefined | null>;
|
|
32
|
+
/**
|
|
33
|
+
* The target quality ("fast" or "high"). Only affects new generations and is ignored for caching.
|
|
34
|
+
* Ignored if `model` is provided.
|
|
35
|
+
* Defaults to "fast".
|
|
36
|
+
*/
|
|
37
|
+
quality?: "fast" | "high";
|
|
32
38
|
/**
|
|
33
39
|
* The base URL for the Slop Machine API.
|
|
34
40
|
* Defaults to the production URL. Useful for testing against local deployments.
|
|
@@ -73,6 +79,12 @@ interface SlopVideoOptions {
|
|
|
73
79
|
* Must be between 4 and 8. Defaults to 4.
|
|
74
80
|
*/
|
|
75
81
|
duration?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The target quality ("fast" or "high"). Only affects new generations and is ignored for caching.
|
|
84
|
+
* Ignored if `model` is provided.
|
|
85
|
+
* Defaults to "fast".
|
|
86
|
+
*/
|
|
87
|
+
quality?: "fast" | "high";
|
|
76
88
|
/**
|
|
77
89
|
* The base URL for the Slop Machine API.
|
|
78
90
|
* Defaults to the production URL. Useful for testing against local deployments.
|
|
@@ -80,5 +92,37 @@ interface SlopVideoOptions {
|
|
|
80
92
|
baseUrl?: string;
|
|
81
93
|
}
|
|
82
94
|
declare function buildVideoUrl(options: SlopVideoOptions): string;
|
|
95
|
+
interface SlopTextOptions {
|
|
96
|
+
/**
|
|
97
|
+
* The unique identifier of your Slop Machine bucket.
|
|
98
|
+
*/
|
|
99
|
+
bucketId: string;
|
|
100
|
+
/**
|
|
101
|
+
* The specific version of the prompt/settings to use.
|
|
102
|
+
* If omitted, the latest version will be used.
|
|
103
|
+
*/
|
|
104
|
+
version?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Result ID to retrieve a specific previously generated text
|
|
107
|
+
* instead of generating a new one.
|
|
108
|
+
*/
|
|
109
|
+
resultId?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The AI model to use for generation.
|
|
112
|
+
* Overrides the default model specified in the bucket settings.
|
|
113
|
+
*/
|
|
114
|
+
model?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Dynamic variables to interpolate into the prompt.
|
|
117
|
+
* E.g., if prompt is "A story about a {color} dog", pass { color: "brown" }.
|
|
118
|
+
*/
|
|
119
|
+
variables?: Record<string, string | number | undefined | null>;
|
|
120
|
+
/**
|
|
121
|
+
* The base URL for the Slop Machine API.
|
|
122
|
+
* Defaults to the production URL. Useful for testing against local deployments.
|
|
123
|
+
*/
|
|
124
|
+
baseUrl?: string;
|
|
125
|
+
}
|
|
126
|
+
declare function buildTextUrl(options: SlopTextOptions): string;
|
|
83
127
|
|
|
84
|
-
export { type ImageAspectRatio, type SlopImageOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildVideoUrl, interpolatePrompt };
|
|
128
|
+
export { type ImageAspectRatio, type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ interface SlopImageOptions {
|
|
|
29
29
|
* E.g., if prompt is "A photo of a {color} dog", pass { color: "brown" }.
|
|
30
30
|
*/
|
|
31
31
|
variables?: Record<string, string | number | undefined | null>;
|
|
32
|
+
/**
|
|
33
|
+
* The target quality ("fast" or "high"). Only affects new generations and is ignored for caching.
|
|
34
|
+
* Ignored if `model` is provided.
|
|
35
|
+
* Defaults to "fast".
|
|
36
|
+
*/
|
|
37
|
+
quality?: "fast" | "high";
|
|
32
38
|
/**
|
|
33
39
|
* The base URL for the Slop Machine API.
|
|
34
40
|
* Defaults to the production URL. Useful for testing against local deployments.
|
|
@@ -73,6 +79,12 @@ interface SlopVideoOptions {
|
|
|
73
79
|
* Must be between 4 and 8. Defaults to 4.
|
|
74
80
|
*/
|
|
75
81
|
duration?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The target quality ("fast" or "high"). Only affects new generations and is ignored for caching.
|
|
84
|
+
* Ignored if `model` is provided.
|
|
85
|
+
* Defaults to "fast".
|
|
86
|
+
*/
|
|
87
|
+
quality?: "fast" | "high";
|
|
76
88
|
/**
|
|
77
89
|
* The base URL for the Slop Machine API.
|
|
78
90
|
* Defaults to the production URL. Useful for testing against local deployments.
|
|
@@ -80,5 +92,37 @@ interface SlopVideoOptions {
|
|
|
80
92
|
baseUrl?: string;
|
|
81
93
|
}
|
|
82
94
|
declare function buildVideoUrl(options: SlopVideoOptions): string;
|
|
95
|
+
interface SlopTextOptions {
|
|
96
|
+
/**
|
|
97
|
+
* The unique identifier of your Slop Machine bucket.
|
|
98
|
+
*/
|
|
99
|
+
bucketId: string;
|
|
100
|
+
/**
|
|
101
|
+
* The specific version of the prompt/settings to use.
|
|
102
|
+
* If omitted, the latest version will be used.
|
|
103
|
+
*/
|
|
104
|
+
version?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Result ID to retrieve a specific previously generated text
|
|
107
|
+
* instead of generating a new one.
|
|
108
|
+
*/
|
|
109
|
+
resultId?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The AI model to use for generation.
|
|
112
|
+
* Overrides the default model specified in the bucket settings.
|
|
113
|
+
*/
|
|
114
|
+
model?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Dynamic variables to interpolate into the prompt.
|
|
117
|
+
* E.g., if prompt is "A story about a {color} dog", pass { color: "brown" }.
|
|
118
|
+
*/
|
|
119
|
+
variables?: Record<string, string | number | undefined | null>;
|
|
120
|
+
/**
|
|
121
|
+
* The base URL for the Slop Machine API.
|
|
122
|
+
* Defaults to the production URL. Useful for testing against local deployments.
|
|
123
|
+
*/
|
|
124
|
+
baseUrl?: string;
|
|
125
|
+
}
|
|
126
|
+
declare function buildTextUrl(options: SlopTextOptions): string;
|
|
83
127
|
|
|
84
|
-
export { type ImageAspectRatio, type SlopImageOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildVideoUrl, interpolatePrompt };
|
|
128
|
+
export { type ImageAspectRatio, type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
buildImageUrl: () => buildImageUrl,
|
|
24
|
+
buildTextUrl: () => buildTextUrl,
|
|
24
25
|
buildVideoUrl: () => buildVideoUrl,
|
|
25
26
|
interpolatePrompt: () => interpolatePrompt
|
|
26
27
|
});
|
|
@@ -44,6 +45,7 @@ function buildImageUrl(options) {
|
|
|
44
45
|
resultId,
|
|
45
46
|
aspectRatio = "1:1",
|
|
46
47
|
model,
|
|
48
|
+
quality = "fast",
|
|
47
49
|
variables = {},
|
|
48
50
|
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage"
|
|
49
51
|
} = options;
|
|
@@ -61,6 +63,11 @@ function buildImageUrl(options) {
|
|
|
61
63
|
if (resultId) {
|
|
62
64
|
params.set("resultId", resultId);
|
|
63
65
|
}
|
|
66
|
+
if (quality && quality !== "fast") {
|
|
67
|
+
params.set("quality", quality);
|
|
68
|
+
} else if (quality === "fast") {
|
|
69
|
+
params.set("quality", "fast");
|
|
70
|
+
}
|
|
64
71
|
if (Object.keys(variables).length > 0) {
|
|
65
72
|
params.set("variables", JSON.stringify(variables));
|
|
66
73
|
}
|
|
@@ -73,6 +80,7 @@ function buildVideoUrl(options) {
|
|
|
73
80
|
resultId,
|
|
74
81
|
aspectRatio = "16:9",
|
|
75
82
|
model,
|
|
83
|
+
quality = "fast",
|
|
76
84
|
variables = {},
|
|
77
85
|
duration = 4,
|
|
78
86
|
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo"
|
|
@@ -91,8 +99,32 @@ function buildVideoUrl(options) {
|
|
|
91
99
|
if (resultId) {
|
|
92
100
|
params.set("resultId", resultId);
|
|
93
101
|
} else {
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
params.set("quality", "fast");
|
|
103
|
+
}
|
|
104
|
+
if (Object.keys(variables).length > 0) {
|
|
105
|
+
params.set("variables", JSON.stringify(variables));
|
|
106
|
+
}
|
|
107
|
+
return `${baseUrl}?${params.toString()}`;
|
|
108
|
+
}
|
|
109
|
+
function buildTextUrl(options) {
|
|
110
|
+
const {
|
|
111
|
+
bucketId,
|
|
112
|
+
version,
|
|
113
|
+
resultId,
|
|
114
|
+
model,
|
|
115
|
+
variables = {},
|
|
116
|
+
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText"
|
|
117
|
+
} = options;
|
|
118
|
+
const params = new URLSearchParams();
|
|
119
|
+
params.set("bucketId", bucketId);
|
|
120
|
+
if (model) {
|
|
121
|
+
params.set("model", model);
|
|
122
|
+
}
|
|
123
|
+
if (version) {
|
|
124
|
+
params.set("version", String(version));
|
|
125
|
+
}
|
|
126
|
+
if (resultId) {
|
|
127
|
+
params.set("resultId", resultId);
|
|
96
128
|
}
|
|
97
129
|
if (Object.keys(variables).length > 0) {
|
|
98
130
|
params.set("variables", JSON.stringify(variables));
|
|
@@ -102,6 +134,7 @@ function buildVideoUrl(options) {
|
|
|
102
134
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
135
|
0 && (module.exports = {
|
|
104
136
|
buildImageUrl,
|
|
137
|
+
buildTextUrl,
|
|
105
138
|
buildVideoUrl,
|
|
106
139
|
interpolatePrompt
|
|
107
140
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n quality = \"fast\",\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n version,\n resultId,\n model,\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n"],"mappings":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AO,IAAI,OAAO,SAAS,CAAC;AACxC;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ function buildImageUrl(options) {
|
|
|
18
18
|
resultId,
|
|
19
19
|
aspectRatio = "1:1",
|
|
20
20
|
model,
|
|
21
|
+
quality = "fast",
|
|
21
22
|
variables = {},
|
|
22
23
|
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage"
|
|
23
24
|
} = options;
|
|
@@ -35,6 +36,11 @@ function buildImageUrl(options) {
|
|
|
35
36
|
if (resultId) {
|
|
36
37
|
params.set("resultId", resultId);
|
|
37
38
|
}
|
|
39
|
+
if (quality && quality !== "fast") {
|
|
40
|
+
params.set("quality", quality);
|
|
41
|
+
} else if (quality === "fast") {
|
|
42
|
+
params.set("quality", "fast");
|
|
43
|
+
}
|
|
38
44
|
if (Object.keys(variables).length > 0) {
|
|
39
45
|
params.set("variables", JSON.stringify(variables));
|
|
40
46
|
}
|
|
@@ -47,6 +53,7 @@ function buildVideoUrl(options) {
|
|
|
47
53
|
resultId,
|
|
48
54
|
aspectRatio = "16:9",
|
|
49
55
|
model,
|
|
56
|
+
quality = "fast",
|
|
50
57
|
variables = {},
|
|
51
58
|
duration = 4,
|
|
52
59
|
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo"
|
|
@@ -65,8 +72,32 @@ function buildVideoUrl(options) {
|
|
|
65
72
|
if (resultId) {
|
|
66
73
|
params.set("resultId", resultId);
|
|
67
74
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
params.set("quality", "fast");
|
|
76
|
+
}
|
|
77
|
+
if (Object.keys(variables).length > 0) {
|
|
78
|
+
params.set("variables", JSON.stringify(variables));
|
|
79
|
+
}
|
|
80
|
+
return `${baseUrl}?${params.toString()}`;
|
|
81
|
+
}
|
|
82
|
+
function buildTextUrl(options) {
|
|
83
|
+
const {
|
|
84
|
+
bucketId,
|
|
85
|
+
version,
|
|
86
|
+
resultId,
|
|
87
|
+
model,
|
|
88
|
+
variables = {},
|
|
89
|
+
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText"
|
|
90
|
+
} = options;
|
|
91
|
+
const params = new URLSearchParams();
|
|
92
|
+
params.set("bucketId", bucketId);
|
|
93
|
+
if (model) {
|
|
94
|
+
params.set("model", model);
|
|
95
|
+
}
|
|
96
|
+
if (version) {
|
|
97
|
+
params.set("version", String(version));
|
|
98
|
+
}
|
|
99
|
+
if (resultId) {
|
|
100
|
+
params.set("resultId", resultId);
|
|
70
101
|
}
|
|
71
102
|
if (Object.keys(variables).length > 0) {
|
|
72
103
|
params.set("variables", JSON.stringify(variables));
|
|
@@ -75,6 +106,7 @@ function buildVideoUrl(options) {
|
|
|
75
106
|
}
|
|
76
107
|
export {
|
|
77
108
|
buildImageUrl,
|
|
109
|
+
buildTextUrl,
|
|
78
110
|
buildVideoUrl,
|
|
79
111
|
interpolatePrompt
|
|
80
112
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n quality = \"fast\",\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n version,\n resultId,\n model,\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n"],"mappings":";AAuDO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AACtC,UAAM,QAAQ,UAAU,GAAG;AAC3B,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,aAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAEO,SAAS,cAAc,SAAmC;AAC/D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,UAAU;AAAA,IACV,YAAY,CAAC;AAAA,IACb,UAAU;AAAA,EACZ,IAAI;AAEJ,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,YAAY,QAAQ;AAE/B,MAAI,aAAa;AACf,WAAO,IAAI,eAAe,WAAW;AAAA,EACvC;AAEA,MAAI,OAAO;AACT,WAAO,IAAI,SAAS,KAAK;AAA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AAA,IACA;AAAA,IACA,YAAY,CAAC;AAAA,IACb,UAAU;AAAA,EACZ,IAAI;AAEJ,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,YAAY,QAAQ;AAE/B,MAAI,OAAO;AACT,WAAO,IAAI,SAAS,KAAK;AAAA,EAC3B;AACA,MAAI,SAAS;AACX,WAAO,IAAI,WAAW,OAAO,OAAO,CAAC;AAAA,EACvC;AACA,MAAI,UAAU;AACZ,WAAO,IAAI,YAAY,QAAQ;AAAA,EACjC;AAEA,MAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACrC,WAAO,IAAI,aAAa,KAAK,UAAU,SAAS,CAAC;AAAA,EACnD;AAEA,SAAO,GAAG,OAAO,IAAI,OAAO,SAAS,CAAC;AACxC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slopmachine/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
|
+
"description": "The official Core / VanillaJS SDK for Slop Machine",
|
|
5
|
+
"llms": "https://slopmachine-dev.github.io/slopmachine-sdk/llms.txt",
|
|
6
|
+
"llmsFull": "https://slopmachine-dev.github.io/slopmachine-sdk/llms-full.txt",
|
|
4
7
|
"main": "dist/index.js",
|
|
5
8
|
"module": "dist/index.mjs",
|
|
6
9
|
"types": "dist/index.d.ts",
|
|
@@ -23,5 +26,6 @@
|
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"tsup": "^8.0.0",
|
|
25
28
|
"typescript": "^5.0.0"
|
|
26
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT"
|
|
27
31
|
}
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,12 @@ export interface SlopImageOptions {
|
|
|
40
40
|
* E.g., if prompt is "A photo of a {color} dog", pass { color: "brown" }.
|
|
41
41
|
*/
|
|
42
42
|
variables?: Record<string, string | number | undefined | null>;
|
|
43
|
+
/**
|
|
44
|
+
* The target quality ("fast" or "high"). Only affects new generations and is ignored for caching.
|
|
45
|
+
* Ignored if `model` is provided.
|
|
46
|
+
* Defaults to "fast".
|
|
47
|
+
*/
|
|
48
|
+
quality?: "fast" | "high";
|
|
43
49
|
/**
|
|
44
50
|
* The base URL for the Slop Machine API.
|
|
45
51
|
* Defaults to the production URL. Useful for testing against local deployments.
|
|
@@ -71,6 +77,7 @@ export function buildImageUrl(options: SlopImageOptions): string {
|
|
|
71
77
|
resultId,
|
|
72
78
|
aspectRatio = "1:1",
|
|
73
79
|
model,
|
|
80
|
+
quality = "fast",
|
|
74
81
|
variables = {},
|
|
75
82
|
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage",
|
|
76
83
|
} = options;
|
|
@@ -91,6 +98,11 @@ export function buildImageUrl(options: SlopImageOptions): string {
|
|
|
91
98
|
if (resultId) {
|
|
92
99
|
params.set("resultId", resultId);
|
|
93
100
|
}
|
|
101
|
+
if (quality && quality !== "fast") {
|
|
102
|
+
params.set("quality", quality);
|
|
103
|
+
} else if (quality === "fast") {
|
|
104
|
+
params.set("quality", "fast");
|
|
105
|
+
}
|
|
94
106
|
|
|
95
107
|
if (Object.keys(variables).length > 0) {
|
|
96
108
|
params.set("variables", JSON.stringify(variables));
|
|
@@ -136,6 +148,12 @@ export interface SlopVideoOptions {
|
|
|
136
148
|
* Must be between 4 and 8. Defaults to 4.
|
|
137
149
|
*/
|
|
138
150
|
duration?: number;
|
|
151
|
+
/**
|
|
152
|
+
* The target quality ("fast" or "high"). Only affects new generations and is ignored for caching.
|
|
153
|
+
* Ignored if `model` is provided.
|
|
154
|
+
* Defaults to "fast".
|
|
155
|
+
*/
|
|
156
|
+
quality?: "fast" | "high";
|
|
139
157
|
/**
|
|
140
158
|
* The base URL for the Slop Machine API.
|
|
141
159
|
* Defaults to the production URL. Useful for testing against local deployments.
|
|
@@ -150,6 +168,7 @@ export function buildVideoUrl(options: SlopVideoOptions): string {
|
|
|
150
168
|
resultId,
|
|
151
169
|
aspectRatio = "16:9",
|
|
152
170
|
model,
|
|
171
|
+
quality = "fast",
|
|
153
172
|
variables = {},
|
|
154
173
|
duration = 4,
|
|
155
174
|
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo",
|
|
@@ -171,9 +190,69 @@ export function buildVideoUrl(options: SlopVideoOptions): string {
|
|
|
171
190
|
if (resultId) {
|
|
172
191
|
params.set("resultId", resultId);
|
|
173
192
|
} else {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
params.set("quality", "fast");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (Object.keys(variables).length > 0) {
|
|
197
|
+
params.set("variables", JSON.stringify(variables));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return `${baseUrl}?${params.toString()}`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface SlopTextOptions {
|
|
204
|
+
/**
|
|
205
|
+
* The unique identifier of your Slop Machine bucket.
|
|
206
|
+
*/
|
|
207
|
+
bucketId: string;
|
|
208
|
+
/**
|
|
209
|
+
* The specific version of the prompt/settings to use.
|
|
210
|
+
* If omitted, the latest version will be used.
|
|
211
|
+
*/
|
|
212
|
+
version?: number;
|
|
213
|
+
/**
|
|
214
|
+
* Result ID to retrieve a specific previously generated text
|
|
215
|
+
* instead of generating a new one.
|
|
216
|
+
*/
|
|
217
|
+
resultId?: string;
|
|
218
|
+
/**
|
|
219
|
+
* The AI model to use for generation.
|
|
220
|
+
* Overrides the default model specified in the bucket settings.
|
|
221
|
+
*/
|
|
222
|
+
model?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Dynamic variables to interpolate into the prompt.
|
|
225
|
+
* E.g., if prompt is "A story about a {color} dog", pass { color: "brown" }.
|
|
226
|
+
*/
|
|
227
|
+
variables?: Record<string, string | number | undefined | null>;
|
|
228
|
+
/**
|
|
229
|
+
* The base URL for the Slop Machine API.
|
|
230
|
+
* Defaults to the production URL. Useful for testing against local deployments.
|
|
231
|
+
*/
|
|
232
|
+
baseUrl?: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function buildTextUrl(options: SlopTextOptions): string {
|
|
236
|
+
const {
|
|
237
|
+
bucketId,
|
|
238
|
+
version,
|
|
239
|
+
resultId,
|
|
240
|
+
model,
|
|
241
|
+
variables = {},
|
|
242
|
+
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText",
|
|
243
|
+
} = options;
|
|
244
|
+
|
|
245
|
+
const params = new URLSearchParams();
|
|
246
|
+
params.set("bucketId", bucketId);
|
|
247
|
+
|
|
248
|
+
if (model) {
|
|
249
|
+
params.set("model", model);
|
|
250
|
+
}
|
|
251
|
+
if (version) {
|
|
252
|
+
params.set("version", String(version));
|
|
253
|
+
}
|
|
254
|
+
if (resultId) {
|
|
255
|
+
params.set("resultId", resultId);
|
|
177
256
|
}
|
|
178
257
|
|
|
179
258
|
if (Object.keys(variables).length > 0) {
|