@ossy/media-tasks 1.23.3 → 1.23.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/media-tasks",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.4",
|
|
4
4
|
"description": "Changestream-triggered media processing tasks (image resize, AI descriptors)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
],
|
|
29
29
|
"author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
|
|
30
30
|
"license": "MIT",
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f5b2f3495d91b046b7357771ee7b0d3c7f29fcc6"
|
|
32
32
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import OpenAiSDK from 'openai'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
let _openai = null
|
|
4
|
+
function getOpenAi() {
|
|
5
|
+
if (!_openai) _openai = new OpenAiSDK({
|
|
6
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
7
|
+
organization: process.env.OPENAI_ORGANIZATION,
|
|
8
|
+
})
|
|
9
|
+
return _openai
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
export class OpenAi {
|
|
9
13
|
static async getVisualContentDescriptors(imageSrc) {
|
|
@@ -15,7 +19,7 @@ export class OpenAi {
|
|
|
15
19
|
-alt: A short text that describes the image, suitable for alt text
|
|
16
20
|
`
|
|
17
21
|
|
|
18
|
-
const response = await
|
|
22
|
+
const response = await getOpenAi().chat.completions.create({
|
|
19
23
|
model: 'gpt-4o-mini',
|
|
20
24
|
max_tokens: 4000,
|
|
21
25
|
messages: [
|
|
@@ -39,7 +43,7 @@ export class OpenAi {
|
|
|
39
43
|
|
|
40
44
|
const textString = response?.choices?.[0]?.message?.content
|
|
41
45
|
|
|
42
|
-
return
|
|
46
|
+
return getOpenAi().chat.completions.create({
|
|
43
47
|
model: 'gpt-4-turbo-preview',
|
|
44
48
|
max_tokens: 4000,
|
|
45
49
|
response_format: { type: 'json_object' },
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import sharp from 'sharp'
|
|
2
|
-
|
|
3
1
|
const Sizes = [
|
|
4
2
|
{ width: 24, height: 24, name: 'thumbnailSmall' },
|
|
5
3
|
{ width: 48, height: 48, name: 'thumbnailLarge' },
|
|
@@ -21,6 +19,7 @@ export const metadata = {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
export default async function ({ event, sdk }) {
|
|
22
|
+
const { default: sharp } = await import('sharp')
|
|
24
23
|
const resourceId = event.aggregateId
|
|
25
24
|
|
|
26
25
|
console.log(`[resize-common-web] starting for resource ${resourceId}`)
|