@ossy/media-tasks 1.33.0 → 1.35.0
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 +3 -3
- package/src/openai.integration.js +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/media-tasks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"description": "Changestream-triggered media processing tasks (image resize, AI descriptors)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"typecheck": "echo \"No TypeScript in media-tasks package\" && exit 0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ossy/observability": "^1.
|
|
18
|
+
"@ossy/observability": "^1.3.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"openai": ">=4",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
],
|
|
32
32
|
"author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
|
|
33
33
|
"license": "MIT",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "c6697078268867d88553ca0bac08faad5cea1546"
|
|
35
35
|
}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import OpenAiSDK from 'openai'
|
|
2
2
|
|
|
3
|
+
export const id = 'openai'
|
|
4
|
+
|
|
5
|
+
export const credentials = ['OPENAI_API_KEY']
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns an OpenAI client configured from env vars.
|
|
9
|
+
* Tasks receive this via `integrations.get('openai')`.
|
|
10
|
+
*
|
|
11
|
+
* @param {{ env: NodeJS.ProcessEnv }} opts
|
|
12
|
+
* @returns {import('openai').OpenAI}
|
|
13
|
+
*/
|
|
14
|
+
export async function connect({ env }) {
|
|
15
|
+
return new OpenAiSDK({
|
|
16
|
+
apiKey: env.OPENAI_API_KEY,
|
|
17
|
+
organization: env.OPENAI_ORGANIZATION,
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
3
21
|
let _openai = null
|
|
4
22
|
function getOpenAi() {
|
|
5
23
|
if (!_openai) _openai = new OpenAiSDK({
|