@mdgate/ai 0.5.0 → 0.5.1
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/README.md +9 -7
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# @mdgate/ai
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenAI-compatible callbacks for mdgate image, audio, and video conversion. No default endpoint: pass `baseURL`, `apiKey`, and `model`. The prompt is built in.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { create } from '@mdgate/core';
|
|
7
7
|
import { image } from '@mdgate/image';
|
|
8
|
+
import { audio } from '@mdgate/audio';
|
|
8
9
|
import { video } from '@mdgate/video';
|
|
9
10
|
import { ai } from '@mdgate/ai';
|
|
10
11
|
import { pdf } from '@mdgate/pdf';
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
+
const media = ai({
|
|
13
14
|
baseURL: 'https://api.example.com/v1',
|
|
14
15
|
apiKey: process.env.MY_KEY!,
|
|
15
16
|
model: 'my-vision-model',
|
|
@@ -17,13 +18,14 @@ const vision = ai({
|
|
|
17
18
|
|
|
18
19
|
const convert = create([
|
|
19
20
|
pdf(),
|
|
20
|
-
image(
|
|
21
|
-
|
|
21
|
+
image(media.convertImage),
|
|
22
|
+
audio(media.convertAudio),
|
|
23
|
+
video(media.convertVideo),
|
|
22
24
|
]);
|
|
23
25
|
|
|
24
26
|
// Same chat/completions endpoint; audio and video are sent as data URLs.
|
|
25
|
-
await
|
|
26
|
-
await
|
|
27
|
+
await media.convertAudio({ bytes, mime: 'audio/mpeg' });
|
|
28
|
+
await media.convertVideo({ bytes, mime: 'video/mp4' });
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
`baseURL` is the OpenAI-compatible API root (the same value the OpenAI SDK uses). Requests go to `{baseURL}/chat/completions`. Raster images include JPEG, PNG, WebP, GIF, TIFF, HEIC, and BMP. SVG is converted locally by `@mdgate/image`. Video includes MP4, MOV, WebM, Matroska, and AVI.
|
|
31
|
+
`baseURL` is the OpenAI-compatible API root (the same value the OpenAI SDK uses). Requests go to `{baseURL}/chat/completions`. Raster images include JPEG, PNG, WebP, GIF, TIFF, HEIC, and BMP. SVG is converted locally by `@mdgate/image`. Audio includes MP3, WAV, M4A, AAC, Ogg, FLAC, and WebM audio. Video includes MP4, MOV, WebM, Matroska, and AVI.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdgate/ai",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Optional AI helper for mdgate: ai({ baseURL, apiKey, model }).convertImage / convertAudio / convertVideo",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"prepublishOnly": "bun run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mdgate/core": "0.5.
|
|
26
|
-
"@mdgate/image": "0.5.
|
|
27
|
-
"@mdgate/video": "0.5.
|
|
25
|
+
"@mdgate/core": "0.5.1",
|
|
26
|
+
"@mdgate/image": "0.5.1",
|
|
27
|
+
"@mdgate/video": "0.5.1"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
"mdgate",
|
|
37
37
|
"markdown",
|
|
38
38
|
"vision",
|
|
39
|
-
"ocr"
|
|
39
|
+
"ocr",
|
|
40
|
+
"audio",
|
|
41
|
+
"video"
|
|
40
42
|
]
|
|
41
43
|
}
|