utilitas 1999.1.58 → 1999.1.59

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/lib/gen.mjs CHANGED
@@ -48,7 +48,7 @@ const extractVideo = async (data, options) => await convert(
48
48
  data, { input: BASE64, suffix: 'mp4', ...options || {} }
49
49
  );
50
50
 
51
- const generateImage = async (prompt, options) => {
51
+ const image = async (prompt, options) => {
52
52
  let provider = ensureString(options?.provider, { case: 'UP' });
53
53
  if (!provider && clients?.[GEMINI]?.apiKey) { provider = GEMINI; }
54
54
  if (!provider && clients?.[OPENAI]) { provider = OPENAI; }
@@ -82,15 +82,58 @@ const generateImage = async (prompt, options) => {
82
82
  }
83
83
  return resp?.data;
84
84
  case GEMINI:
85
+ // Image editing failed with the following error: imagen-3.0-capability-001 is unavailable.
86
+ // @todo: https://cloud.google.com/vertex-ai/generative-ai/docs/image/overview#feature-launch-stage
87
+ // cat << EOF > request.json
88
+ // {
89
+ // "endpoint": "projects/backend-alpha-97077/locations/us-central1/publishers/google/models/imagen-3.0-capability-001",
90
+ // "instances": [
91
+ // {
92
+ // "prompt": "ENTER PROMPT HERE",
93
+ // "referenceImages": [
94
+ // {
95
+ // "referenceId": 1,
96
+ // "referenceType": "REFERENCE_TYPE_SUBJECT",
97
+ // "referenceImage": {
98
+ // "bytesBase64Encoded":
99
+ // },
100
+ // "subjectImageConfig" {
101
+ // "subjectDescription": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
102
+ // "subjectType": "SUBJECT_TYPE_DEFAULT"
103
+ // }
104
+ // }
105
+ // ],
106
+ // }
107
+ // ],
108
+ // "parameters": {
109
+ // "aspectRatio": "1:1",
110
+ // "sampleCount": 4,
111
+ // "negativePrompt": "",
112
+ // "enhancePrompt": false,
113
+ // "personGeneration": "",
114
+ // "safetySetting": "",
115
+ // "addWatermark": true,
116
+ // "includeRaiReason": true,
117
+ // "language": "auto",
118
+ // }
119
+ // }
120
+ // curl \
121
+ // -X POST \
122
+ // -H "Content-Type: application/json" \
123
+ // -H "Authorization: Bearer $(gcloud auth print-access-token)" \
124
+ // "https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/google/models/${MODEL_ID}:predict" -d '@request.json'
125
+ // ARGs: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api?authuser=4#rest_1
85
126
  var resp = await (await fetch(
86
127
  'https://generativelanguage.googleapis.com/v1beta/models/'
87
128
  + `${IMAGEN_MODEL}:predict?key=${client.apiKey}`, {
88
129
  method: 'POST', headers: { 'Content-Type': 'application/json' },
89
130
  body: JSON.stringify({
90
131
  instances: [{ prompt }], parameters: {
91
- sampleCount: n, aspectRatio: '16:9',
132
+ // "1:1" (default), "3:4", "4:3", "9:16", and "16:9"
133
+ aspectRatio: '16:9', includeRaiReason: true,
134
+ personGeneration: 'allow_adult', sampleCount: n,
92
135
  ...options?.params || {},
93
- }, // "1:1" (default), "3:4", "4:3", "9:16", and "16:9"
136
+ },
94
137
  })
95
138
  })).json();
96
139
  assert(!resp?.error, resp?.error?.message || ERROR_GENERATING);
@@ -140,7 +183,7 @@ const getGeminiVideo = async (jobId, accessToken) => {
140
183
  return resp?.response?.videos;
141
184
  };
142
185
 
143
- const generateVideo = async (prompt, options) => {
186
+ const video = async (prompt, options) => {
144
187
  let provider = ensureString(options?.provider, { case: 'UP' });
145
188
  if (!provider
146
189
  && clients?.[GEMINI]?.credentials
@@ -198,8 +241,7 @@ const generateVideo = async (prompt, options) => {
198
241
  export default init;
199
242
  export {
200
243
  _NEED,
201
- generateImage,
202
- generateVideo,
203
- getGeminiVideo,
244
+ image,
204
245
  init,
246
+ video,
205
247
  };
package/lib/manifest.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1999.1.58",
4
+ "version": "1999.1.59",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1999.1.58",
4
+ "version": "1999.1.59",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",