Skip to content

Commit

Permalink
OmniTool 1.0.2 Update
Browse files Browse the repository at this point in the history
Bug Fixes:
- Handled exceptions gracefully in name to rgb block.
- Fixed issue where imported recipes could not be saved.
- Fixed issue where the preview of an image block caused an error when importing a recipe from file.
- Fixed issue where images were not embedded during a recipe export and unknown blocks were not recreated during recipe import.

Deprecation:
- Deprecated pocketbase and skipped pocketdb checks.

Upgrade:
- Upgraded yarn to version 4.1.

Additional Feature:
- Added a status badge.
  • Loading branch information
manu-sapiens committed Feb 19, 2024
1 parent efdf0c7 commit 032df26
Show file tree
Hide file tree
Showing 13 changed files with 1,841 additions and 1,756 deletions.
672 changes: 336 additions & 336 deletions .yarn/releases/yarn-4.0.2.cjs → .yarn/releases/yarn-4.1.0.cjs
100755 → 100644

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"

yarnPath: .yarn/releases/yarn-4.0.2.cjs
yarnPath: .yarn/releases/yarn-4.1.0.cjs
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
![GitHub last commit](https://img.shields.io/github/last-commit/omnitool-ai/omnitool?color=red)
![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Follama-webui%2Follama-wbui&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)
[![Discord](https://img.shields.io/badge/Discord-Omnitool-blue?logo=discord&logoColor=white)](https://discord.gg/EMYBZnyjAJ)
[![Publish release](https://github.com/omnitool-ai/omnitool/actions/workflows/publish-release.yml/badge.svg?branch=main)](https://github.com/omnitool-ai/omnitool/actions/workflows/publish-release.yml)

*Discover, Learn, Evaluate and Build with thousands of Generative AI Models.*

Expand Down
27 changes: 4 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "omnitool",
"version": "1.0.1",
"packageManager": "yarn@4.0.2",
"version": "1.0.2",
"packageManager": "yarn@4.1.0",
"private": true,
"workspaces": [
"packages/omni-sdk",
Expand All @@ -11,8 +11,7 @@
"packages/omni-server"
],
"engines": {
"node": ">=18.18.0",
"pocketbase": "0.16.6"
"node": ">=18.18.0"
},
"scripts": {
"build:prod": "yarn workspace omni-shared build:prod && yarn workspace omni-sdk build:prod && yarn workspace omni-sockets build:prod && yarn workspace omni-client-services build:prod && yarn workspace omni-web build:prod && yarn workspace omni-server build:prod",
Expand All @@ -30,25 +29,7 @@
},
"dependenciesBin": {
"updates_base_url": "https://github.com/omnitool-ai/omnitool/releases/download/latest",
"root_dir": ".local.bin",
"pocketbase": {
"admin": "[email protected]",
"base_url": "https://github.com/pocketbase/pocketbase/releases/download/v##version##",
"zipfile": {
"win32": {
"x64": "pocketbase_##version##_windows_amd64.zip",
"arm64": "pocketbase_##version##_windows_arm64.zip"
},
"darwin": {
"x64": "pocketbase_##version##_darwin_amd64.zip",
"arm64": "pocketbase_##version##_darwin_arm64.zip"
},
"linux": {
"x64": "pocketbase_##version##_linux_amd64.zip",
"arm64": "pocketbase_##version##_linux_arm64.zip"
}
}
}
"root_dir": ".local.bin"
},
"dependencies": {
"@ungap/structured-clone": "^1.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "omni-sdk",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"type": "module",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
105 changes: 80 additions & 25 deletions packages/omni-server/dist/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var KVStorage = class {
if (opts.view) {
source = opts.view;
}
let sql = "SELECT key, value, valueType, expiry, seq, tags FROM " + source + " WHERE key LIKE ? AND deleted = 0";
let sql = "SELECT key, value, valueType, blob, expiry, seq, tags FROM " + source + " WHERE key LIKE ? AND deleted = 0";
const args = [partialKeyMatchPattern];
if (opts.expiryType && ["permanent", "temporary"].includes(opts.expiryType)) {
if (opts.expiryType === "permanent") {
Expand Down Expand Up @@ -247,7 +247,8 @@ var KVStorage = class {
seq: row.seq,
expiry: row.expiry && row.expiry < 9007199254740991 ? row.expiry : void 0,
valueType: row.valueType,
tags: row.tags?.split(",").filter((tag) => tag.trim()) ?? []
tags: row.tags?.split(",").filter((tag) => tag.trim()) ?? [],
blob: row.blob
}));
} catch (error) {
this.parent?.error("Error occurred while getting values:", error);
Expand Down Expand Up @@ -2885,17 +2886,21 @@ block3.addOutput(block3.createOutput("Red", "number").toOmniIO());
block3.addOutput(block3.createOutput("Green", "number").toOmniIO());
block3.addOutput(block3.createOutput("Blue", "number").toOmniIO());
block3.setMacro(OmniComponentMacroTypes16.EXEC, async (payload, ctx) => {
const colorName = payload["Color Name"];
const [red, green, blue] = convert.keyword.rgb(colorName);
const hexString = convert.rgb.hex(red, green, blue);
const rgbString = `rgb(${red},${green},${blue})`;
return {
"Hex String": `#${hexString}`,
"RGB String": rgbString,
Red: red,
Green: green,
Blue: blue
};
try {
const colorName = payload["Color Name"];
const [red, green, blue] = convert.keyword.rgb(colorName);
const hexString = convert.rgb.hex(red, green, blue);
const rgbString = `rgb(${red},${green},${blue})`;
return {
"Hex String": `#${hexString}`,
"RGB String": rgbString,
Red: red,
Green: green,
Blue: blue
};
} catch (e) {
return {};
}
});
var NameToRgbBlock = block3.toJSON();
var name_to_rgb_default = NameToRgbBlock;
Expand Down Expand Up @@ -15055,6 +15060,27 @@ var WorkflowIntegration = class extends APIIntegration {
return clonedWorkflow;
}
}
// Saves a workflow if it does not exist
async saveWorkflowIfNotExists(workflow, user) {
const userId = typeof user === "object" ? user.id : user;
const realUser = typeof user === "object" ? user : await this.app.services.get("db").get(`user:${userId}`);
if (realUser) {
const existingWorkflow = await this.getRecipe(workflow.id, userId, true);
if (existingWorkflow != null) {
return existingWorkflow;
} else {
return await this.createWorkflow(
{
meta: workflow.meta,
rete: workflow.rete
},
realUser
);
}
} else {
throw new Error(`User ${userId} not found`);
}
}
// Updates an existing workflow (but does not change the owner!)
async updateWorkflow(workflowId, update, user, opts) {
const userId = typeof user === "object" ? user.id : user;
Expand Down Expand Up @@ -15221,6 +15247,8 @@ var WorkflowIntegration = class extends APIIntegration {
omnilog10.debug("Resource", resource.data ? resource.data.length : "null");
if (resource) {
exportFile.set(n.data[inputKey], resource.data);
} else {
console.error(`Resource ${n.data[inputKey]} not found`);
}
}
}
Expand All @@ -15240,33 +15268,60 @@ var WorkflowIntegration = class extends APIIntegration {
dbPath: this.config.tempExportDir ?? "./data.local/tmp"
});
await kv.initFromBuffer(resource.data);
const newFidMap = /* @__PURE__ */ new Map();
const cdnEntries = kv.getAny("fid://");
for (const kvPair of cdnEntries) {
const cdnResource = await this.app.cdn.put(kvPair.value, { userId });
const key = kvPair.key.replace("fid://", "");
newFidMap.set(key, cdnResource);
console.log(`found in kv storate: key = ${key} and stored its cdnResource: ${JSON.stringify(cdnResource)}`);
}
const kvEntries = kv.getAny("wf:");
if (!kvEntries || kvEntries.length === 0) {
throw new Error("No workflows to be imported");
const error_message = "No workflows to be imported";
console.error(error_message);
throw new Error(error_message);
}
const result = [];
for (const kvPair of kvEntries) {
const workflow = kvPair.value;
const blockNames = Array.from(new Set(Object.values(workflow.rete.nodes).map((n) => n.name)));
const blocks2 = (await this.app.blocks.getInstances(blockNames, userId, void 0))?.blocks;
const blocks2 = (await this.app.blocks.getInstances(blockNames, userId, "missing_block"))?.blocks;
let error_list = "";
for (const node of Object.values(workflow.rete.nodes)) {
const block7 = blocks2.find((b) => b.name === node.name);
if (!block7) {
throw new Error(`Block ${node.name} not found`);
}
for (const inputKey of Object.keys(block7.inputs)) {
if (["image", "file", "audio", "video", "document"].includes(block7.inputs[inputKey].customSocket)) {
if (node.data[inputKey] && typeof node.data[inputKey] === "string" && node.data[inputKey].startsWith("fid:")) {
const keyValue = kv.get(node.data[inputKey]);
if (keyValue !== void 0) {
const resource2 = await this.app.cdn.put(node.data[inputKey].replace("fid://", ""), { userId });
node.data[inputKey] = `fid://${resource2.fid}`;
const error_message = `Block ${node.name} not found`;
console.error(error_message);
error_list += error_message + "\n";
} else {
for (const inputKey of Object.keys(block7.inputs)) {
if (["image", "file", "audio", "video", "document"].includes(block7.inputs[inputKey].customSocket)) {
if (node.data[inputKey] && typeof node.data[inputKey] === "string" && node.data[inputKey].startsWith("fid:")) {
const key = node.data[inputKey].replace("fid://", "");
const cdnResource = newFidMap.get(key);
const newFid = cdnResource.fid;
if (newFid) {
node.data[inputKey] = `fid://${newFid}`;
if (node.data.preview) {
node.data.preview = [cdnResource];
}
} else {
const error = `Resource key ${key} not found in kv ${JSON.stringify(newFidMap)}
`;
error_list += error;
console.error(error);
}
}
}
}
}
}
result.push(workflow);
if (error_list !== "") {
console.error(error_list);
}
const saved_workflow = await this.saveWorkflowIfNotExists(workflow, userId);
result.push(saved_workflow);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omni-server",
"version": "1.0.1",
"version": "1.0.2",
"packageManager": "[email protected]",
"main": "./dist/run.js",
"engines": {
Expand Down
32 changes: 18 additions & 14 deletions packages/omni-server/src/blocks/DefaultBlocks/name_to_rgb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,24 @@ block.addOutput(block.createOutput('Green', 'number').toOmniIO());
block.addOutput(block.createOutput('Blue', 'number').toOmniIO());

block.setMacro(OmniComponentMacroTypes.EXEC, async (payload: any, ctx: WorkerContext) => {
const colorName = payload['Color Name'];

// Convert color name to RGB using color-convert
const [red, green, blue] = convert.keyword.rgb(colorName);
const hexString = convert.rgb.hex(red, green, blue);
const rgbString = `rgb(${red},${green},${blue})`;

return {
'Hex String': `#${hexString}`,
'RGB String': rgbString,
Red: red,
Green: green,
Blue: blue
};
try {
const colorName = payload['Color Name'];

// Convert color name to RGB using color-convert
const [red, green, blue] = convert.keyword.rgb(colorName);
const hexString = convert.rgb.hex(red, green, blue);
const rgbString = `rgb(${red},${green},${blue})`;
return {
'Hex String': `#${hexString}`,
'RGB String': rgbString,
Red: red,
Green: green,
Blue: blue
};
}
catch(e) {
return {}
}
});

const NameToRgbBlock = block.toJSON();
Expand Down
7 changes: 5 additions & 2 deletions packages/omni-server/src/core/KVStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class KVStorage implements IKVStorage {
if (opts.view) {
source = opts.view;
}
let sql = 'SELECT key, value, valueType, expiry, seq, tags FROM ' + source + ' WHERE key LIKE ? AND deleted = 0';
let sql = 'SELECT key, value, valueType, blob, expiry, seq, tags FROM ' + source + ' WHERE key LIKE ? AND deleted = 0';
const args: any[] = [partialKeyMatchPattern];

// --- Expiry handling ---
Expand Down Expand Up @@ -324,6 +324,7 @@ class KVStorage implements IKVStorage {
seq: number;
expiry?: number;
valueType: string;
blob: Buffer;
}>;

count = result.length;
Expand All @@ -338,7 +339,9 @@ class KVStorage implements IKVStorage {
seq: row.seq as number,
expiry: row.expiry && row.expiry < 9007199254740991 ? (row.expiry as number) : undefined,
valueType: row.valueType,
tags: row.tags?.split(',').filter((tag: string) => tag.trim()) ?? []
tags: row.tags?.split(',').filter((tag: string) => tag.trim()) ?? [],
blob: row.blob

}));
} catch (error) {
this.parent?.error('Error occurred while getting values:', error);
Expand Down
Loading

0 comments on commit 032df26

Please sign in to comment.