@aigne/aigne-hub 0.9.4 → 0.9.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.6](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.9.5...aigne-hub-v0.9.6) (2025-09-18)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @aigne/gemini bumped to 0.13.5
11
+
12
+ ## [0.9.5](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.9.4...aigne-hub-v0.9.5) (2025-09-18)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **models:** convert local image to base64 for image model ([#517](https://github.com/AIGNE-io/aigne-framework/issues/517)) ([c0bc971](https://github.com/AIGNE-io/aigne-framework/commit/c0bc971087ef6e1caa641a699aed391a24feb40d))
18
+ * **models:** convert local image to base64 for image model ([#517](https://github.com/AIGNE-io/aigne-framework/issues/517)) ([c0bc971](https://github.com/AIGNE-io/aigne-framework/commit/c0bc971087ef6e1caa641a699aed391a24feb40d))
19
+
20
+
21
+ ### Dependencies
22
+
23
+ * The following workspace dependencies were updated
24
+ * dependencies
25
+ * @aigne/anthropic bumped to 0.13.4
26
+ * @aigne/bedrock bumped to 0.10.4
27
+ * @aigne/core bumped to 1.60.3
28
+ * @aigne/deepseek bumped to 0.7.45
29
+ * @aigne/doubao bumped to 1.0.40
30
+ * @aigne/gemini bumped to 0.13.4
31
+ * @aigne/ideogram bumped to 0.3.15
32
+ * @aigne/ollama bumped to 0.7.45
33
+ * @aigne/open-router bumped to 0.7.45
34
+ * @aigne/openai bumped to 0.15.4
35
+ * @aigne/poe bumped to 1.0.25
36
+ * @aigne/transport bumped to 0.15.8
37
+ * @aigne/xai bumped to 0.7.45
38
+ * devDependencies
39
+ * @aigne/test-utils bumped to 0.5.52
40
+
3
41
  ## [0.9.4](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.9.3...aigne-hub-v0.9.4) (2025-09-16)
4
42
 
5
43
 
@@ -9,6 +9,7 @@ const ufo_1 = require("ufo");
9
9
  const blocklet_js_1 = require("./utils/blocklet.js");
10
10
  const constants_js_1 = require("./utils/constants.js");
11
11
  const type_js_1 = require("./utils/type.js");
12
+ const AIGNE_HUB_DEFAULT_IMAGE_MIME = "image/png";
12
13
  class AIGNEHubImageModel extends core_1.ImageModel {
13
14
  options;
14
15
  constructor(options) {
@@ -56,6 +57,39 @@ class AIGNEHubImageModel extends core_1.ImageModel {
56
57
  BLOCKLET_APP_PID ||
57
58
  ABT_NODE_DID ||
58
59
  `@aigne/aigne-hub:${typeof process !== "undefined" ? index_js_1.nodejs.os.hostname() : "unknown"}`;
60
+ // Convert local image to base64
61
+ if (input.image) {
62
+ const images = Array.isArray(input.image) ? input.image : [input.image];
63
+ input.image = await Promise.all(images.map(async (image) => {
64
+ if (image.startsWith("http")) {
65
+ try {
66
+ const response = await this.downloadFile(image);
67
+ const buffer = await response.arrayBuffer();
68
+ const mime = response.headers.get("content-type") || AIGNE_HUB_DEFAULT_IMAGE_MIME;
69
+ const base64 = Buffer.from(buffer).toString("base64");
70
+ return `data:${mime};base64,${base64}`;
71
+ }
72
+ catch {
73
+ return image;
74
+ }
75
+ }
76
+ if (image.startsWith("file://")) {
77
+ const filePath = image.replace("file://", "");
78
+ if (index_js_1.nodejs.fsSync.existsSync(filePath)) {
79
+ const mime = AIGNE_HUB_DEFAULT_IMAGE_MIME;
80
+ const base64 = await index_js_1.nodejs.fs.readFile(filePath, "base64");
81
+ return `data:${mime};base64,${base64}`;
82
+ }
83
+ throw new Error(`Local file not found: ${filePath}`);
84
+ }
85
+ if (index_js_1.nodejs.fsSync.existsSync(image)) {
86
+ const mime = AIGNE_HUB_DEFAULT_IMAGE_MIME;
87
+ const base64 = await index_js_1.nodejs.fs.readFile(image, "base64");
88
+ return `data:${mime};base64,${base64}`;
89
+ }
90
+ return image;
91
+ }));
92
+ }
59
93
  const response = await (await this.client).__invoke(undefined, {
60
94
  ...input,
61
95
  modelOptions: {
@@ -6,6 +6,7 @@ import { joinURL } from "ufo";
6
6
  import { getAIGNEHubMountPoint } from "./utils/blocklet.js";
7
7
  import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_IMAGE_MODEL, AIGNE_HUB_URL } from "./utils/constants.js";
8
8
  import { aigneHubModelOptionsSchema } from "./utils/type.js";
9
+ const AIGNE_HUB_DEFAULT_IMAGE_MIME = "image/png";
9
10
  export class AIGNEHubImageModel extends ImageModel {
10
11
  options;
11
12
  constructor(options) {
@@ -53,6 +54,39 @@ export class AIGNEHubImageModel extends ImageModel {
53
54
  BLOCKLET_APP_PID ||
54
55
  ABT_NODE_DID ||
55
56
  `@aigne/aigne-hub:${typeof process !== "undefined" ? nodejs.os.hostname() : "unknown"}`;
57
+ // Convert local image to base64
58
+ if (input.image) {
59
+ const images = Array.isArray(input.image) ? input.image : [input.image];
60
+ input.image = await Promise.all(images.map(async (image) => {
61
+ if (image.startsWith("http")) {
62
+ try {
63
+ const response = await this.downloadFile(image);
64
+ const buffer = await response.arrayBuffer();
65
+ const mime = response.headers.get("content-type") || AIGNE_HUB_DEFAULT_IMAGE_MIME;
66
+ const base64 = Buffer.from(buffer).toString("base64");
67
+ return `data:${mime};base64,${base64}`;
68
+ }
69
+ catch {
70
+ return image;
71
+ }
72
+ }
73
+ if (image.startsWith("file://")) {
74
+ const filePath = image.replace("file://", "");
75
+ if (nodejs.fsSync.existsSync(filePath)) {
76
+ const mime = AIGNE_HUB_DEFAULT_IMAGE_MIME;
77
+ const base64 = await nodejs.fs.readFile(filePath, "base64");
78
+ return `data:${mime};base64,${base64}`;
79
+ }
80
+ throw new Error(`Local file not found: ${filePath}`);
81
+ }
82
+ if (nodejs.fsSync.existsSync(image)) {
83
+ const mime = AIGNE_HUB_DEFAULT_IMAGE_MIME;
84
+ const base64 = await nodejs.fs.readFile(image, "base64");
85
+ return `data:${mime};base64,${base64}`;
86
+ }
87
+ return image;
88
+ }));
89
+ }
56
90
  const response = await (await this.client).__invoke(undefined, {
57
91
  ...input,
58
92
  modelOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/aigne-hub",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "AIGNE Hub SDK for integrating with Hub AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -35,33 +35,33 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@smithy/node-http-handler": "^4.1.0",
38
+ "@smithy/node-http-handler": "^4.2.1",
39
39
  "https-proxy-agent": "^7.0.6",
40
40
  "ufo": "^1.6.1",
41
41
  "zod": "^3.25.67",
42
- "@aigne/anthropic": "^0.13.3",
43
- "@aigne/bedrock": "^0.10.3",
44
- "@aigne/core": "^1.60.2",
45
- "@aigne/deepseek": "^0.7.44",
46
- "@aigne/doubao": "^1.0.39",
47
- "@aigne/ideogram": "^0.3.14",
48
- "@aigne/gemini": "^0.13.3",
49
- "@aigne/ollama": "^0.7.44",
50
- "@aigne/open-router": "^0.7.44",
51
- "@aigne/openai": "^0.15.3",
42
+ "@aigne/anthropic": "^0.13.4",
43
+ "@aigne/bedrock": "^0.10.4",
44
+ "@aigne/core": "^1.60.3",
45
+ "@aigne/deepseek": "^0.7.45",
46
+ "@aigne/doubao": "^1.0.40",
47
+ "@aigne/gemini": "^0.13.5",
48
+ "@aigne/ideogram": "^0.3.15",
49
+ "@aigne/ollama": "^0.7.45",
50
+ "@aigne/open-router": "^0.7.45",
51
+ "@aigne/openai": "^0.15.4",
52
52
  "@aigne/platform-helpers": "^0.6.2",
53
- "@aigne/poe": "^1.0.24",
54
- "@aigne/transport": "^0.15.7",
55
- "@aigne/xai": "^0.7.44"
53
+ "@aigne/poe": "^1.0.25",
54
+ "@aigne/transport": "^0.15.8",
55
+ "@aigne/xai": "^0.7.45"
56
56
  },
57
57
  "devDependencies": {
58
- "@types/bun": "^1.2.18",
58
+ "@types/bun": "^1.2.22",
59
59
  "detect-port": "^2.1.0",
60
- "hono": "^4.8.4",
60
+ "hono": "^4.9.7",
61
61
  "npm-run-all": "^4.1.5",
62
62
  "rimraf": "^6.0.1",
63
- "typescript": "^5.8.3",
64
- "@aigne/test-utils": "^0.5.51"
63
+ "typescript": "^5.9.2",
64
+ "@aigne/test-utils": "^0.5.52"
65
65
  },
66
66
  "scripts": {
67
67
  "lint": "tsc --noEmit",