From 454e5f6f5e832558e66a90bbd171c070aaeedc46 Mon Sep 17 00:00:00 2001 From: Service Account Date: Tue, 24 Oct 2023 06:54:25 +0700 Subject: [PATCH 01/20] feat(adr-008) Initial commit --- adr/adr-008-Extensible-Jan-with-Docker.md | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 adr/adr-008-Extensible-Jan-with-Docker.md diff --git a/adr/adr-008-Extensible-Jan-with-Docker.md b/adr/adr-008-Extensible-Jan-with-Docker.md new file mode 100644 index 000000000..7b13864a2 --- /dev/null +++ b/adr/adr-008-Extensible-Jan-with-Docker.md @@ -0,0 +1,36 @@ +# ADR 008: Extensible-Jan-with-Docker + +## Changelog + +- 2023-10-24: Initial draft + +## Authors + +- @vuonghoainam + +## Status +Proposed + +## Context + +What is the issue that we're seeing that is motivating this decision or change? +- The A.I world is moving fast with multiple runtime/ prebaked environment. We or the builder cannot cover just everything but rather we should adopt it and facillitate it as much as possible within Jan. +- For `Run your own A.I`: Builder can build app on Jan (NodeJS env) and connect to external endpoint which serves the real A.I + - e.g 1: Nitro acting as proxy to `triton-inference-server` running within a Docker container controlled by Jan app + - e.g 2: Original models can be in many formats (pytorch, paddlepaddle). In order to run it with the most optimized version locally, there must be a step to transpile the model ([Ollama import model](https://github.com/jmorganca/ollama/blob/main/docs/import.md), Tensorrt). Btw Jan can prebuilt it and let user pull but later +- For `Build your own A.I`: User can fine tune model locally (of course Jan help it with remote but later) + +## Decision + +What is the change that we're proposing and/or doing? +- Add Docker client as Core module - [Docker node](https://github.com/apocas/dockerode) +- 2 example A.I app (adr-002) to demonstrate it and actually use! + +## Consequences + +What becomes easier or more difficult to do because of this change? +- We can extend limitlessly :D + +## Alternatives + +## Reference From fffeaf5bc96277e6834e01c307661d07a4702913 Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 14:32:48 +0700 Subject: [PATCH 02/20] Change to load nitron on windows and linux from bash/shell script --- plugins/inference-plugin/module.ts | 4 ++-- plugins/inference-plugin/nitro/nitro_start_linux.sh | 6 ++++++ plugins/inference-plugin/nitro/nitro_start_windows.bat | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 plugins/inference-plugin/nitro/nitro_start_linux.sh create mode 100755 plugins/inference-plugin/nitro/nitro_start_windows.bat diff --git a/plugins/inference-plugin/module.ts b/plugins/inference-plugin/module.ts index b0318bd03..0ddddc37e 100644 --- a/plugins/inference-plugin/module.ts +++ b/plugins/inference-plugin/module.ts @@ -34,14 +34,14 @@ const initModel = (fileName) => { if (process.platform === "win32") { // Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries - binaryName = "nitro_windows_amd64_cuda.exe"; + binaryName = "nitro_start_windows.bat"; } else if (process.platform === "darwin") { // Mac OS platform binaryName = process.arch === "arm64" ? "nitro_mac_arm64" : "nitro_mac_intel"; } else { // Linux // Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries - binaryName = "nitro_linux_amd64_cuda"; // For other platforms + binaryName = "nitro_start_linux.sh"; // For other platforms } const binaryPath = path.join(binaryFolder, binaryName); diff --git a/plugins/inference-plugin/nitro/nitro_start_linux.sh b/plugins/inference-plugin/nitro/nitro_start_linux.sh new file mode 100755 index 000000000..19ac36f21 --- /dev/null +++ b/plugins/inference-plugin/nitro/nitro_start_linux.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +#!/bin/bash + +# Attempt to run the nitro_linux_amd64_cuda file and if it fails, run nitro_linux_amd64 +./nitro_linux_amd64_cuda || (echo "nitro_linux_amd64_cuda encountered an error, attempting to run nitro_linux_amd64..." && ./nitro_linux_amd64) diff --git a/plugins/inference-plugin/nitro/nitro_start_windows.bat b/plugins/inference-plugin/nitro/nitro_start_windows.bat new file mode 100755 index 000000000..4f7cb4247 --- /dev/null +++ b/plugins/inference-plugin/nitro/nitro_start_windows.bat @@ -0,0 +1,10 @@ +@echo off + +rem Attempt to run nitro_windows_amd64_cuda.exe +nitro_windows_amd64_cuda.exe + +rem Check the exit code of the previous command +if %errorlevel% neq 0 ( + echo nitro_windows_amd64_cuda.exe encountered an error, attempting to run nitro_windows_amd64.exe... + nitro_windows_amd64.exe +) From 1ce823bd4343bec56b16b4f29cfc81fc111a6680 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Wed, 25 Oct 2023 14:46:33 +0700 Subject: [PATCH 03/20] Enable link color blue on docusaurus markdown --- docs/src/styles/tweaks.scss | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/src/styles/tweaks.scss b/docs/src/styles/tweaks.scss index 9def1c493..3b5e425e3 100644 --- a/docs/src/styles/tweaks.scss +++ b/docs/src/styles/tweaks.scss @@ -80,11 +80,8 @@ @apply border-gray-200 dark:border-gray-800; } -[class*="docMainContainer_"], -[class*="docSidebarContainer_"] { - table { - a { - @apply text-blue-600 dark:text-blue-400; - } +.theme-doc-markdown { + a { + @apply text-blue-600 dark:text-blue-400; } } From 1765d944e6e41c41bc6eb9250ae17e15f6b75f12 Mon Sep 17 00:00:00 2001 From: Louis <133622055+louis-jan@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:50:39 +0700 Subject: [PATCH 04/20] fix: bring back install plugin manually function (#448) --- .../Settings/CorePlugins/PluginsCatalog.tsx | 138 +++++++++++------- .../CorePlugins/PreferencePlugins/index.tsx | 4 +- 2 files changed, 87 insertions(+), 55 deletions(-) diff --git a/web/screens/Settings/CorePlugins/PluginsCatalog.tsx b/web/screens/Settings/CorePlugins/PluginsCatalog.tsx index 74dd2d827..595239ead 100644 --- a/web/screens/Settings/CorePlugins/PluginsCatalog.tsx +++ b/web/screens/Settings/CorePlugins/PluginsCatalog.tsx @@ -19,6 +19,7 @@ const PluginCatalog = () => { const [pluginCatalog, setPluginCatalog] = useState([]) const [isLoading, setIsLoading] = useState(false) const experimentRef = useRef(null) + const fileInputRef = useRef(null) /** * Loads the plugin catalog module from a CDN and sets it as the plugin catalog state. @@ -63,8 +64,7 @@ const PluginCatalog = () => { */ const install = async (e: any) => { e.preventDefault() - //@ts-ignore - const pluginFile = new FormData(e.target).get('plugin-file').path + const pluginFile = e.target.files?.[0].path // Send the filename of the to be installed plugin // to the main process for installation @@ -116,65 +116,97 @@ const PluginCatalog = () => { * Its to be used to display the plugin file name of the selected file. * @param event - The change event object. */ - // const handleFileChange = (event: React.ChangeEvent) => { - // const file = event.target.files?.[0] - // if (file) { - // setFileName(file.name) - // } else { - // setFileName('') - // } - // } + const handleFileChange = (event: React.ChangeEvent) => { + const file = event.target.files?.[0] + if (file) { + install(event) + } + } return (
- {pluginCatalog?.map((item, i) => { - const isActivePlugin = activePlugins.some((x) => x.name === item.name) - const updateVersionPlugins = Number( - activePlugins - .filter((p) => p.name === item.name)[0] - ?.version.replaceAll('.', '') + {(pluginCatalog ?? []) + .concat( + activePlugins?.filter( + (e) => !(pluginCatalog ?? []).some((p) => p.name === e.name) + ) ?? [] ) - return ( -
-
-
-
- {formatPluginsName(item.name)} -
-

- v{item.version} + .map((item, i) => { + const isActivePlugin = activePlugins.some((x) => x.name === item.name) + const updateVersionPlugins = Number( + activePlugins + .filter((p) => p.name === item.name)[0] + ?.version.replaceAll('.', '') + ) + return ( +

+
+
+
+ {formatPluginsName(item.name)} +
+

+ v{item.version} +

+
+

+ {item.description}

+ {isActivePlugin && + item.version.replaceAll('.', '') < updateVersionPlugins && ( + + )}
-

- {item.description} -

- {isActivePlugin && - item.version.replaceAll('.', '') < updateVersionPlugins && ( - - )} + { + if (e === true) { + downloadTarball(item.name) + } else { + uninstall(item.name) + } + }} + />
- { - if (e === true) { - downloadTarball(item.name) - } else { - uninstall(item.name) - } - }} - /> + ) + })} + {/* Manual Installation */} +
+
+
+
+ Manual Installation +
- ) - })} +

+ Select a plugin file to install (.tgz) +

+
+
+ + +
+
{isLoading && (
diff --git a/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx b/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx index 713ecc01b..841acc38a 100644 --- a/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx +++ b/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx @@ -39,12 +39,12 @@ const PreferencePlugins = (props: Props) => { Setting: {e.preferenceName}
- + {e.preferenceDescription}
v.key === e.preferenceKey From be01dcb8591c6a5e839c5107a53dbdf2f6daf505 Mon Sep 17 00:00:00 2001 From: Louis <133622055+louis-jan@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:51:03 +0700 Subject: [PATCH 05/20] fix: model is started but the indicator is not stopped loading (#446) * fix: model is started but the indicator is not stopped loading * chore: show loading indicator on the loading model row only * Update README.md --------- Co-authored-by: hiento09 <136591877+hiento09@users.noreply.github.com> --- plugins/data-plugin/README.md | 2 +- web/app/_components/ModelActionButton/index.tsx | 15 +++++---------- web/app/_components/ModelRow/index.tsx | 6 ++++-- web/hooks/useStartStopModel.ts | 8 +++----- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/plugins/data-plugin/README.md b/plugins/data-plugin/README.md index 42caeb1aa..2197d9ad2 100644 --- a/plugins/data-plugin/README.md +++ b/plugins/data-plugin/README.md @@ -5,4 +5,4 @@ - index.ts: Main entry point for the plugin. - module.ts: Defines the plugin module which would be executed by the main node process. - package.json: Defines the plugin metadata. -- tsconfig.json: Defines the typescript configuration. \ No newline at end of file +- tsconfig.json: Defines the typescript configuration. diff --git a/web/app/_components/ModelActionButton/index.tsx b/web/app/_components/ModelActionButton/index.tsx index c1a7c64e0..346d0afc2 100644 --- a/web/app/_components/ModelActionButton/index.tsx +++ b/web/app/_components/ModelActionButton/index.tsx @@ -1,9 +1,6 @@ -import React, { useState } from 'react' +import React from 'react' import { Button } from '@uikit' import ModelActionMenu from '../ModelActionMenu' -import { useAtomValue } from 'jotai' - -import { stateModel } from '@helpers/atoms/Model.atom' export enum ModelActionType { Start = 'Start', @@ -25,26 +22,24 @@ const modelActionMapper: Record = { type Props = { disabled?: boolean + loading?: boolean type: ModelActionType onActionClick: (type: ModelActionType) => void onDeleteClick: () => void } const ModelActionButton: React.FC = ({ - disabled = false, + disabled, + loading, type, onActionClick, onDeleteClick, }) => { const styles = modelActionMapper[type] - // const { startingModel } = useStartStopModel() const onClick = () => { onActionClick(type) } - - const state = useAtomValue(stateModel) - return (
@@ -54,7 +49,7 @@ const ModelActionButton: React.FC = ({ size="sm" themes={styles.title === 'Start' ? 'accent' : 'default'} onClick={() => onClick()} - loading={state.loading} + loading={loading} > {styles.title} Model diff --git a/web/app/_components/ModelRow/index.tsx b/web/app/_components/ModelRow/index.tsx index f0bd4a283..fd7479982 100644 --- a/web/app/_components/ModelRow/index.tsx +++ b/web/app/_components/ModelRow/index.tsx @@ -4,7 +4,7 @@ import { useAtomValue } from 'jotai' import ModelActionButton, { ModelActionType } from '../ModelActionButton' import useStartStopModel from '@hooks/useStartStopModel' import useDeleteModel from '@hooks/useDeleteModel' -import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom' +import { activeAssistantModelAtom, stateModel } from '@helpers/atoms/Model.atom' import { toGigabytes } from '@utils/converter' type Props = { @@ -12,9 +12,10 @@ type Props = { } const ModelRow: React.FC = ({ model }) => { - const { loading, startModel, stopModel } = useStartStopModel() + const { startModel, stopModel } = useStartStopModel() const activeModel = useAtomValue(activeAssistantModelAtom) const { deleteModel } = useDeleteModel() + const { loading, model: currentModelState } = useAtomValue(stateModel) let status = ModelStatus.Installed if (activeModel && activeModel._id === model._id) { @@ -58,6 +59,7 @@ const ModelRow: React.FC = ({ model }) => { (false) const setStateModel = useSetAtom(stateModel) const startModel = async (modelId: string) => { @@ -24,12 +23,11 @@ export default function useStartStopModel() { if (!model) { alert(`Model ${modelId} not found! Please re-download the model first.`) setStateModel((prev) => ({ ...prev, loading: false })) - } + } const currentTime = Date.now() console.debug('Init model: ', model._id) const res = await executeSerial(InferenceService.InitModel, model._id) - if (res?.error) { const errorMessage = `Failed to init model: ${res.error}` console.error(errorMessage) @@ -40,7 +38,7 @@ export default function useStartStopModel() { ) setActiveModel(model) } - setLoading(false) + setStateModel((prev) => ({ ...prev, loading: false })) } const stopModel = async (modelId: string) => { @@ -52,5 +50,5 @@ export default function useStartStopModel() { }, 500) } - return { loading, startModel, stopModel } + return { startModel, stopModel } } From b121495ff45a37dcdab42ff416496d1c56cfb261 Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 08:55:35 +0000 Subject: [PATCH 06/20] janhq/jan: Update tag build 1.0.13 for inference-plugin --- plugins/inference-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inference-plugin/package.json b/plugins/inference-plugin/package.json index 1b68fd4da..c13f7bafe 100644 --- a/plugins/inference-plugin/package.json +++ b/plugins/inference-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/inference-plugin", - "version": "1.0.12", + "version": "1.0.13", "description": "Inference Plugin, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.", "icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/command-line.svg", "main": "dist/index.js", From ac1a2402746b6252af9cf7802952ddfbdc50a1cd Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 15:56:36 +0700 Subject: [PATCH 07/20] Change tag data-plugin to 1.0.10 --- plugins/data-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index c6c5577a8..a1499a6f0 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/data-plugin", - "version": "1.0.9", + "version": "1.0.10", "description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.", "icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg", "main": "dist/esm/index.js", From 7212fdb143003c6cb256acb115be14a8a062e261 Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 17:57:28 +0700 Subject: [PATCH 08/20] data-plugin force leveldown to 6.1.1 --- .github/workflows/jan-plugins.yml | 2 +- plugins/data-plugin/README.md | 2 +- plugins/data-plugin/package.json | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jan-plugins.yml b/.github/workflows/jan-plugins.yml index e60685410..4b36bdead 100644 --- a/.github/workflows/jan-plugins.yml +++ b/.github/workflows/jan-plugins.yml @@ -88,7 +88,7 @@ jobs: do echo $dir cd $dir - npm install && npm run build && ../../.github/scripts/auto-sign.sh + npm install && npm run postinstall && ../../.github/scripts/auto-sign.sh if [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME != $GITHUB_REPOSITORY ]]; then npm publish --access public fi diff --git a/plugins/data-plugin/README.md b/plugins/data-plugin/README.md index 2197d9ad2..42caeb1aa 100644 --- a/plugins/data-plugin/README.md +++ b/plugins/data-plugin/README.md @@ -5,4 +5,4 @@ - index.ts: Main entry point for the plugin. - module.ts: Defines the plugin module which would be executed by the main node process. - package.json: Defines the plugin metadata. -- tsconfig.json: Defines the typescript configuration. +- tsconfig.json: Defines the typescript configuration. \ No newline at end of file diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index a1499a6f0..9b81750d2 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -12,7 +12,7 @@ ], "scripts": { "build": "tsc -b ./config/tsconfig.esm.json && tsc -b ./config/tsconfig.cjs.json && webpack --config webpack.config.js", - "postinstall": "rimraf *.tgz --glob && npm run build", + "postinstall": "npx npm-force-resolutions && rimraf *.tgz --glob && npm run build", "build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install" }, "exports": { @@ -45,6 +45,9 @@ "pouchdb-find": "^8.0.1", "pouchdb-node": "^8.0.1" }, + "resolutions": { + "leveldown": "6.1.1" + }, "bundleDependencies": [ "pouchdb-node", "pouchdb-find" From cecdd77308962c01c28b2d775205eddcfda1e81e Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 11:03:12 +0000 Subject: [PATCH 09/20] janhq/jan: Update tag build 1.0.11 for data-plugin --- plugins/data-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index 9b81750d2..ec0916446 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/data-plugin", - "version": "1.0.10", + "version": "1.0.11", "description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.", "icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg", "main": "dist/esm/index.js", From ca5723b36e2d49135c8254de6dfb50894d48f537 Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 18:47:11 +0700 Subject: [PATCH 10/20] data-plugin force leveldown back to 5.6.0 and rebuild for darwin arm64 --- plugins/data-plugin/README.md | 2 +- plugins/data-plugin/package.json | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/data-plugin/README.md b/plugins/data-plugin/README.md index 42caeb1aa..2197d9ad2 100644 --- a/plugins/data-plugin/README.md +++ b/plugins/data-plugin/README.md @@ -5,4 +5,4 @@ - index.ts: Main entry point for the plugin. - module.ts: Defines the plugin module which would be executed by the main node process. - package.json: Defines the plugin metadata. -- tsconfig.json: Defines the typescript configuration. \ No newline at end of file +- tsconfig.json: Defines the typescript configuration. diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index ec0916446..bebc69202 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -12,7 +12,7 @@ ], "scripts": { "build": "tsc -b ./config/tsconfig.esm.json && tsc -b ./config/tsconfig.cjs.json && webpack --config webpack.config.js", - "postinstall": "npx npm-force-resolutions && rimraf *.tgz --glob && npm run build", + "postinstall": "npm install leveldown@5.6.0 --build-from-source --arch=arm64 && rimraf *.tgz --glob && npm run build", "build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install" }, "exports": { @@ -41,13 +41,9 @@ ], "dependencies": { "@janhq/core": "^0.1.7", - "leveldown": "^6.1.1", "pouchdb-find": "^8.0.1", "pouchdb-node": "^8.0.1" }, - "resolutions": { - "leveldown": "6.1.1" - }, "bundleDependencies": [ "pouchdb-node", "pouchdb-find" From 99b80792c6b6fbb7b2db1512072ae99fb100f6bb Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 11:54:12 +0000 Subject: [PATCH 11/20] janhq/jan: Update tag build 1.0.12 for data-plugin --- plugins/data-plugin/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index bebc69202..79a1ad143 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/data-plugin", - "version": "1.0.11", + "version": "1.0.12", "description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.", "icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg", "main": "dist/esm/index.js", @@ -41,6 +41,7 @@ ], "dependencies": { "@janhq/core": "^0.1.7", + "leveldown": "^5.6.0", "pouchdb-find": "^8.0.1", "pouchdb-node": "^8.0.1" }, From ed373214522a9460ae26b37c857db15683d74aad Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 19:38:15 +0700 Subject: [PATCH 12/20] Use electron-rebuild to build leveldown@5.6.0 for darwin arm64 --- plugins/data-plugin/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index bebc69202..f73c04673 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -12,7 +12,7 @@ ], "scripts": { "build": "tsc -b ./config/tsconfig.esm.json && tsc -b ./config/tsconfig.cjs.json && webpack --config webpack.config.js", - "postinstall": "npm install leveldown@5.6.0 --build-from-source --arch=arm64 && rimraf *.tgz --glob && npm run build", + "postinstall": "electron-rebuild -f -w leveldown@5.6.0 --arch=arm64 && rimraf *.tgz --glob && npm run build", "build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install" }, "exports": { @@ -41,6 +41,7 @@ ], "dependencies": { "@janhq/core": "^0.1.7", + "electron-rebuild": "^3.2.9", "pouchdb-find": "^8.0.1", "pouchdb-node": "^8.0.1" }, From 724205d67cfc25f52e138df0358e90733b894747 Mon Sep 17 00:00:00 2001 From: hiento09 <136591877+hiento09@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:42:11 +0700 Subject: [PATCH 13/20] Update README.md From d90015082cc43662b077f6fdd9c84d27cf8afa67 Mon Sep 17 00:00:00 2001 From: hiento09 <136591877+hiento09@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:43:07 +0700 Subject: [PATCH 14/20] Update README.md From b7d978cacddba725a4b6153dabebaf8e280d62a5 Mon Sep 17 00:00:00 2001 From: hiento09 <136591877+hiento09@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:44:03 +0700 Subject: [PATCH 15/20] Update data-plugin to auto-increase version --- plugins/data-plugin/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/data-plugin/README.md b/plugins/data-plugin/README.md index 2197d9ad2..c2fd319d2 100644 --- a/plugins/data-plugin/README.md +++ b/plugins/data-plugin/README.md @@ -6,3 +6,4 @@ - module.ts: Defines the plugin module which would be executed by the main node process. - package.json: Defines the plugin metadata. - tsconfig.json: Defines the typescript configuration. + From 74e381202d2cfc5cef23f87b49ea1d23abdc0d50 Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 12:46:47 +0000 Subject: [PATCH 16/20] janhq/jan: Update tag build 1.0.13 for data-plugin --- plugins/data-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index 5d0f5dbb8..65e26719a 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/data-plugin", - "version": "1.0.12", + "version": "1.0.13", "description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.", "icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg", "main": "dist/esm/index.js", From 9e96787761bbbc38b3b4671f0a3a14d034430d4d Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 19:49:32 +0700 Subject: [PATCH 17/20] specific electron version --- plugins/data-plugin/README.md | 1 - plugins/data-plugin/package.json | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/data-plugin/README.md b/plugins/data-plugin/README.md index c2fd319d2..2197d9ad2 100644 --- a/plugins/data-plugin/README.md +++ b/plugins/data-plugin/README.md @@ -6,4 +6,3 @@ - module.ts: Defines the plugin module which would be executed by the main node process. - package.json: Defines the plugin metadata. - tsconfig.json: Defines the typescript configuration. - diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index 65e26719a..ebf401479 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -12,7 +12,7 @@ ], "scripts": { "build": "tsc -b ./config/tsconfig.esm.json && tsc -b ./config/tsconfig.cjs.json && webpack --config webpack.config.js", - "postinstall": "electron-rebuild -f -w leveldown@5.6.0 --arch=arm64 && rimraf *.tgz --glob && npm run build", + "postinstall": "electron-rebuild -f -w leveldown@5.6.0 --arch=arm64 -v 26.2.1 && rimraf *.tgz --glob && npm run build", "build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install" }, "exports": { @@ -41,6 +41,7 @@ ], "dependencies": { "@janhq/core": "^0.1.7", + "electron": "26.2.1", "electron-rebuild": "^3.2.9", "pouchdb-find": "^8.0.1", "pouchdb-node": "^8.0.1" From c0da5d00265cafe56aa8c405b7fedf8c5de4f0b5 Mon Sep 17 00:00:00 2001 From: Service Account Date: Wed, 25 Oct 2023 12:58:12 +0000 Subject: [PATCH 18/20] janhq/jan: Update tag build 1.0.14 for data-plugin --- plugins/data-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index ebf401479..0756f8cc8 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/data-plugin", - "version": "1.0.13", + "version": "1.0.14", "description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.", "icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg", "main": "dist/esm/index.js", From 9903b033b05803643e72bc437a4896af7ddb768d Mon Sep 17 00:00:00 2001 From: Louis <133622055+louis-jan@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:59:28 +0700 Subject: [PATCH 19/20] fix: correct app version display (#452) --- plugins/inference-plugin/index.ts | 5 +- plugins/inference-plugin/module.ts | 70 +++++++++---------- .../_components/ConversationalList/index.tsx | 2 +- .../_components/CreateBotContainer/index.tsx | 3 +- web/app/_components/HistoryItem/index.tsx | 2 +- web/app/_components/LeftRibbonNav/index.tsx | 2 +- web/app/_components/ModelTable/index.tsx | 2 +- web/containers/BottomBar/index.tsx | 4 +- web/containers/Providers/index.tsx | 6 +- web/containers/Sidebar/Left.tsx | 4 +- web/helpers/EventListenerWrapper.tsx | 2 +- web/hooks/useCreateBot.ts | 5 +- web/hooks/useDeleteBot.ts | 5 +- web/hooks/useGetAppVersion.ts | 2 +- web/hooks/useGetBots.ts | 7 +- web/hooks/useGetDownloadedModels.ts | 6 +- web/hooks/useGetSystemResources.ts | 2 +- web/hooks/useUpdateBot.ts | 5 +- web/next.config.js | 9 ++- .../ExploreModels/ExploreModelList/index.tsx | 2 +- .../Settings/CorePlugins/PluginsCatalog.tsx | 14 +++- .../CorePlugins/PreferencePlugins/index.tsx | 2 +- web/services/pluginService.ts | 9 +-- web/types/index.d.ts | 2 +- 24 files changed, 95 insertions(+), 77 deletions(-) diff --git a/plugins/inference-plugin/index.ts b/plugins/inference-plugin/index.ts index 04ed4b0f0..525e7e009 100644 --- a/plugins/inference-plugin/index.ts +++ b/plugins/inference-plugin/index.ts @@ -67,7 +67,7 @@ function requestInference( } subscriber.complete(); }) - .catch(subscriber.error); + .catch((err) => subscriber.error(err)); }); } @@ -143,7 +143,8 @@ async function handleMessageRequest(data: NewMessageRequest) { }, error: async (err) => { message.message = - message.message.trim() + "\n" + "Error occurred: " + err; + message.message.trim() + "\n" + "Error occurred: " + err.message; + events.emit(EventName.OnMessageResponseUpdate, message); // TODO: Common collections should be able to access via core functions instead of store await store.updateOne("messages", message._id, message); }, diff --git a/plugins/inference-plugin/module.ts b/plugins/inference-plugin/module.ts index 0ddddc37e..b851f0c4e 100644 --- a/plugins/inference-plugin/module.ts +++ b/plugins/inference-plugin/module.ts @@ -14,53 +14,49 @@ const initModel = (fileName) => { if (!fileName) { reject("Model not found, please download again."); } - if (subprocess) { - console.error("A subprocess is already running. Attempt to kill then reinit."); - killSubprocess(); - } resolve(fileName); }) - // Kill port process if it is already in use - .then((fileName) => - tcpPortUsed - .waitUntilFree(PORT, 200, 3000) - .catch(() => killPortProcess(PORT)) - .then(() => fileName) - ) // Spawn Nitro subprocess to load model .then(() => { - let binaryFolder = path.join(__dirname, "nitro"); // Current directory by default - let binaryName; + return tcpPortUsed.check(PORT, "127.0.0.1").then((inUse) => { + if (!inUse) { + let binaryFolder = path.join(__dirname, "nitro"); // Current directory by default + let binaryName; - if (process.platform === "win32") { - // Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries - binaryName = "nitro_start_windows.bat"; - } else if (process.platform === "darwin") { - // Mac OS platform - binaryName = process.arch === "arm64" ? "nitro_mac_arm64" : "nitro_mac_intel"; - } else { - // Linux - // Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries - binaryName = "nitro_start_linux.sh"; // For other platforms - } + if (process.platform === "win32") { + // Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries + binaryName = "nitro_start_windows.bat"; + } else if (process.platform === "darwin") { + // Mac OS platform + binaryName = + process.arch === "arm64" + ? "nitro_mac_arm64" + : "nitro_mac_intel"; + } else { + // Linux + // Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries + binaryName = "nitro_start_linux.sh"; // For other platforms + } - const binaryPath = path.join(binaryFolder, binaryName); + const binaryPath = path.join(binaryFolder, binaryName); - // Execute the binary - subprocess = spawn(binaryPath, { cwd: binaryFolder }); + // Execute the binary + subprocess = spawn(binaryPath, { cwd: binaryFolder }); - // Handle subprocess output - subprocess.stdout.on("data", (data) => { - console.log(`stdout: ${data}`); - }); + // Handle subprocess output + subprocess.stdout.on("data", (data) => { + console.log(`stdout: ${data}`); + }); - subprocess.stderr.on("data", (data) => { - console.error(`stderr: ${data}`); - }); + subprocess.stderr.on("data", (data) => { + console.error(`stderr: ${data}`); + }); - subprocess.on("close", (code) => { - console.log(`child process exited with code ${code}`); - subprocess = null; + subprocess.on("close", (code) => { + console.log(`child process exited with code ${code}`); + subprocess = null; + }); + } }); }) .then(() => tcpPortUsed.waitUntilUsed(PORT, 300, 30000)) diff --git a/web/app/_components/ConversationalList/index.tsx b/web/app/_components/ConversationalList/index.tsx index 6a49318fb..827874923 100644 --- a/web/app/_components/ConversationalList/index.tsx +++ b/web/app/_components/ConversationalList/index.tsx @@ -14,7 +14,7 @@ const ConversationalList: React.FC = ({ models }) => (
- {models.map((item) => ( + {models?.map((item) => ( ))}
diff --git a/web/app/_components/CreateBotContainer/index.tsx b/web/app/_components/CreateBotContainer/index.tsx index 52111e21f..2ba2946ad 100644 --- a/web/app/_components/CreateBotContainer/index.tsx +++ b/web/app/_components/CreateBotContainer/index.tsx @@ -13,15 +13,14 @@ import DraggableProgressBar from '../DraggableProgressBar' import { useSetAtom } from 'jotai' import { activeBotAtom } from '@helpers/atoms/Bot.atom' import { - leftSideBarExpandStateAtom, rightSideBarExpandStateAtom, } from '@helpers/atoms/SideBarExpand.atom' import { MainViewState, setMainViewStateAtom, } from '@helpers/atoms/MainView.atom' -import { executeSerial } from '../../../../electron/core/plugin-manager/execution/extension-manager' import { DataService } from '@janhq/core' +import { executeSerial } from '@services/pluginService' const CreateBotContainer: React.FC = () => { const { downloadedModels } = useGetDownloadedModels() diff --git a/web/app/_components/HistoryItem/index.tsx b/web/app/_components/HistoryItem/index.tsx index 118ebf501..ebf0a4f84 100644 --- a/web/app/_components/HistoryItem/index.tsx +++ b/web/app/_components/HistoryItem/index.tsx @@ -1,7 +1,6 @@ import React from 'react' import { useAtomValue, useSetAtom } from 'jotai' import { ModelManagementService } from '@janhq/core' -import { executeSerial } from '../../../../electron/core/plugin-manager/execution/extension-manager' import { getActiveConvoIdAtom, setActiveConvoIdAtom, @@ -13,6 +12,7 @@ import { } from '@helpers/atoms/MainView.atom' import { displayDate } from '@utils/datetime' import { twMerge } from 'tailwind-merge' +import { executeSerial } from '@services/pluginService' type Props = { conversation: Conversation diff --git a/web/app/_components/LeftRibbonNav/index.tsx b/web/app/_components/LeftRibbonNav/index.tsx index 327cd730e..c315d0682 100644 --- a/web/app/_components/LeftRibbonNav/index.tsx +++ b/web/app/_components/LeftRibbonNav/index.tsx @@ -59,7 +59,7 @@ const LeftRibbonNav: React.FC = () => { const onBotListClick = async () => { const bots = await getAllBots() - if (bots.length === 0) { + if (bots?.length === 0) { alert('You have no bot') return } diff --git a/web/app/_components/ModelTable/index.tsx b/web/app/_components/ModelTable/index.tsx index eaa6273f2..c3f0d96cf 100644 --- a/web/app/_components/ModelTable/index.tsx +++ b/web/app/_components/ModelTable/index.tsx @@ -20,7 +20,7 @@ const ModelTable: React.FC = ({ models }) => ( - {models.map((model) => ( + {models?.map((model) => ( ))} diff --git a/web/containers/BottomBar/index.tsx b/web/containers/BottomBar/index.tsx index 6526b7137..e10c14d29 100644 --- a/web/containers/BottomBar/index.tsx +++ b/web/containers/BottomBar/index.tsx @@ -5,12 +5,14 @@ import { useAtomValue } from 'jotai' import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom' import { formatDownloadPercentage } from '@utils/converter' import { activeAssistantModelAtom, stateModel } from '@helpers/atoms/Model.atom' +import useGetAppVersion from '@hooks/useGetAppVersion' const BottomBar = () => { const activeModel = useAtomValue(activeAssistantModelAtom) const stateModelStartStop = useAtomValue(stateModel) const { ram, cpu } = useGetSystemResources() const modelDownloadStates = useAtomValue(modelDownloadStateAtom) + const appVersion = useGetAppVersion() const downloadStates: DownloadState[] = [] for (const [, value] of Object.entries(modelDownloadStates)) { @@ -51,7 +53,7 @@ const BottomBar = () => {
-

Jan v0.2.0

+

Jan {appVersion?.version ?? ''}

) diff --git a/web/containers/Providers/index.tsx b/web/containers/Providers/index.tsx index 72a24b9e1..e0d28a8b8 100644 --- a/web/containers/Providers/index.tsx +++ b/web/containers/Providers/index.tsx @@ -13,13 +13,9 @@ import { activationPoints, extensionPoints, } from '../../../electron/core/plugin-manager/execution/index' -import { - isCorePluginInstalled, - setupBasePlugins, -} from '@services/pluginService' import EventListenerWrapper from '@helpers/EventListenerWrapper' import { setupCoreServices } from '@services/coreService' -import { executeSerial } from '../../../electron/core/plugin-manager/execution/extension-manager' +import { executeSerial, isCorePluginInstalled, setupBasePlugins } from '@services/pluginService' const Providers = (props: PropsWithChildren) => { const [setupCore, setSetupCore] = useState(false) diff --git a/web/containers/Sidebar/Left.tsx b/web/containers/Sidebar/Left.tsx index be2d9c0b9..e837058f3 100644 --- a/web/containers/Sidebar/Left.tsx +++ b/web/containers/Sidebar/Left.tsx @@ -36,8 +36,8 @@ export const SidebarLeft = () => { const onBotListClick = async () => { const bots = await getAllBots() - if (bots.length === 0) { - alert('You have no bot') + if (!bots || bots?.length === 0) { + alert('You have not created any bot') return } diff --git a/web/helpers/EventListenerWrapper.tsx b/web/helpers/EventListenerWrapper.tsx index d15c95d13..a75a9bb68 100644 --- a/web/helpers/EventListenerWrapper.tsx +++ b/web/helpers/EventListenerWrapper.tsx @@ -3,7 +3,6 @@ import { useSetAtom } from 'jotai' import { ReactNode, useEffect } from 'react' import { appDownloadProgress } from './JotaiWrapper' -import { executeSerial } from '../../electron/core/plugin-manager/execution/extension-manager' import { ModelManagementService } from '@janhq/core' import { setDownloadStateAtom, @@ -12,6 +11,7 @@ import { import { getDownloadedModels } from '../hooks/useGetDownloadedModels' import { downloadedModelAtom } from './atoms/DownloadedModel.atom' import EventHandler from './EventHandler' +import { executeSerial } from '@services/pluginService' type Props = { children: ReactNode diff --git a/web/hooks/useCreateBot.ts b/web/hooks/useCreateBot.ts index c54db71fe..46503de7b 100644 --- a/web/hooks/useCreateBot.ts +++ b/web/hooks/useCreateBot.ts @@ -1,9 +1,10 @@ -import { executeSerial } from '../../electron/core/plugin-manager/execution/extension-manager' +import { DataService } from '@janhq/core' +import { executeSerial } from '@services/pluginService' export default function useCreateBot() { const createBot = async (bot: Bot) => { try { - await executeSerial('createBot', bot) + await executeSerial(DataService.CreateBot, bot) } catch (err) { alert(err) console.error(err) diff --git a/web/hooks/useDeleteBot.ts b/web/hooks/useDeleteBot.ts index e253970da..8d7f6abed 100644 --- a/web/hooks/useDeleteBot.ts +++ b/web/hooks/useDeleteBot.ts @@ -1,7 +1,8 @@ import { useSetAtom } from 'jotai' -import { executeSerial } from '../../electron/core/plugin-manager/execution/extension-manager' import { activeBotAtom } from '@helpers/atoms/Bot.atom' import { rightSideBarExpandStateAtom } from '@helpers/atoms/SideBarExpand.atom' +import { executeSerial } from '@services/pluginService' +import { DataService } from '@janhq/core' export default function useDeleteBot() { const setActiveBot = useSetAtom(activeBotAtom) @@ -9,7 +10,7 @@ export default function useDeleteBot() { const deleteBot = async (botId: string): Promise<'success' | 'failed'> => { try { - await executeSerial('deleteBot', botId) + await executeSerial(DataService.DeleteBot, botId) setRightPanelVisibility(false) setActiveBot(undefined) return 'success' diff --git a/web/hooks/useGetAppVersion.ts b/web/hooks/useGetAppVersion.ts index e89de231f..cdcd12e3e 100644 --- a/web/hooks/useGetAppVersion.ts +++ b/web/hooks/useGetAppVersion.ts @@ -8,7 +8,7 @@ export default function useGetAppVersion() { }, []) const getAppVersion = () => { - window.electronAPI.appVersion().then((version: string | undefined) => { + window.coreAPI?.appVersion().then((version: string | undefined) => { setVersion(version ?? '') }) } diff --git a/web/hooks/useGetBots.ts b/web/hooks/useGetBots.ts index aa1c02fb4..e35e76478 100644 --- a/web/hooks/useGetBots.ts +++ b/web/hooks/useGetBots.ts @@ -1,9 +1,10 @@ -import { executeSerial } from '../../electron/core/plugin-manager/execution/extension-manager' +import { DataService } from '@janhq/core' +import { executeSerial } from '@services/pluginService' export default function useGetBots() { const getAllBots = async (): Promise => { try { - const bots = await executeSerial('getBots') + const bots = await executeSerial(DataService.GetBots) return bots } catch (err) { alert(`Failed to get bots: ${err}`) @@ -14,7 +15,7 @@ export default function useGetBots() { const getBotById = async (botId: string): Promise => { try { - const bot: Bot = await executeSerial('getBotById', botId) + const bot: Bot = await executeSerial(DataService.GetBotById, botId) return bot } catch (err) { alert(`Failed to get bot ${botId}: ${err}`) diff --git a/web/hooks/useGetDownloadedModels.ts b/web/hooks/useGetDownloadedModels.ts index d77ab810d..1474c55a0 100644 --- a/web/hooks/useGetDownloadedModels.ts +++ b/web/hooks/useGetDownloadedModels.ts @@ -1,8 +1,9 @@ import { useEffect } from 'react' -import { executeSerial } from '../../electron/core/plugin-manager/execution/extension-manager' import { ModelManagementService } from '@janhq/core' import { useAtom } from 'jotai' import { downloadedModelAtom } from '@helpers/atoms/DownloadedModel.atom' +import { extensionPoints } from '../../electron/core/plugin-manager/execution' +import { executeSerial } from '@services/pluginService' export function useGetDownloadedModels() { const [downloadedModels, setDownloadedModels] = useAtom(downloadedModelAtom) @@ -17,6 +18,9 @@ export function useGetDownloadedModels() { } export async function getDownloadedModels(): Promise { + if (!extensionPoints.get(ModelManagementService.GetFinishedDownloadModels)) { + return [] + } const downloadedModels: AssistantModel[] = await executeSerial( ModelManagementService.GetFinishedDownloadModels ) diff --git a/web/hooks/useGetSystemResources.ts b/web/hooks/useGetSystemResources.ts index 0e77882a5..a6f751f76 100644 --- a/web/hooks/useGetSystemResources.ts +++ b/web/hooks/useGetSystemResources.ts @@ -1,9 +1,9 @@ import { useEffect, useState } from 'react' -import { executeSerial } from '../../electron/core/plugin-manager/execution/extension-manager' import { extensionPoints } from '../../electron/core/plugin-manager/execution' import { SystemMonitoringService } from '@janhq/core' import { useSetAtom } from 'jotai' import { totalRamAtom } from '@helpers/atoms/SystemBar.atom' +import { executeSerial } from '@services/pluginService' export default function useGetSystemResources() { const [ram, setRam] = useState(0) const [cpu, setCPU] = useState(0) diff --git a/web/hooks/useUpdateBot.ts b/web/hooks/useUpdateBot.ts index 5eff88e70..b913ab394 100644 --- a/web/hooks/useUpdateBot.ts +++ b/web/hooks/useUpdateBot.ts @@ -1,4 +1,5 @@ -import { executeSerial } from '../../electron/core/plugin-manager/execution/extension-manager' +import { DataService } from '@janhq/core' +import { executeSerial } from '@services/pluginService' export default function useUpdateBot() { const updateBot = async ( @@ -15,7 +16,7 @@ export default function useUpdateBot() { } } - await executeSerial('updateBot', bot) + await executeSerial(DataService.UpdateBot, bot) console.debug('Bot updated', JSON.stringify(bot, null, 2)) } catch (err) { alert(`Update bot error: ${err}`) diff --git a/web/next.config.js b/web/next.config.js index dde766300..318b3108b 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -21,7 +21,14 @@ const nextConfig = { // do some stuff here config.optimization.minimize = false config.optimization.minimizer = [] - config.plugins = [...config.plugins, new webpack.DefinePlugin({})] + config.plugins = [ + ...config.plugins, + new webpack.DefinePlugin({ + PLUGIN_CATALOG: JSON.stringify( + 'https://cdn.jsdelivr.net/npm/@janhq/plugin-catalog@latest/dist/index.js' + ), + }), + ] return config }, } diff --git a/web/screens/ExploreModels/ExploreModelList/index.tsx b/web/screens/ExploreModels/ExploreModelList/index.tsx index 6c3acee71..0f5f08da8 100644 --- a/web/screens/ExploreModels/ExploreModelList/index.tsx +++ b/web/screens/ExploreModels/ExploreModelList/index.tsx @@ -12,7 +12,7 @@ const ExploreModelList: React.FC = () => { return (
- {models.map((item) => ( + {models?.map((item) => ( ))}
diff --git a/web/screens/Settings/CorePlugins/PluginsCatalog.tsx b/web/screens/Settings/CorePlugins/PluginsCatalog.tsx index 595239ead..53e2d5ff5 100644 --- a/web/screens/Settings/CorePlugins/PluginsCatalog.tsx +++ b/web/screens/Settings/CorePlugins/PluginsCatalog.tsx @@ -25,9 +25,17 @@ const PluginCatalog = () => { * Loads the plugin catalog module from a CDN and sets it as the plugin catalog state. */ useEffect(() => { - executeSerial(DataService.GetPluginManifest).then((data) => { - setPluginCatalog(data) - }) + // Load plugin manifest from plugin if any + if (extensionPoints.get(DataService.GetPluginManifest)) { + executeSerial(DataService.GetPluginManifest).then((data) => { + setPluginCatalog(data) + }) + } else { + // Fallback to app default manifest + import( + /* webpackIgnore: true */ PLUGIN_CATALOG + `?t=${Date.now()}` + ).then((data) => setPluginCatalog(data.default)) + } }, []) /** diff --git a/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx b/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx index 841acc38a..fbf5dc625 100644 --- a/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx +++ b/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx @@ -1,4 +1,4 @@ -import React, { Children } from 'react' +import React from 'react' import { execute } from '../../../../../electron/core/plugin-manager/execution/extension-manager' type Props = { diff --git a/web/services/pluginService.ts b/web/services/pluginService.ts index 812bc3a79..d885e6d8d 100644 --- a/web/services/pluginService.ts +++ b/web/services/pluginService.ts @@ -8,10 +8,11 @@ import { DataService, InferenceService, ModelManagementService, + StoreService, } from '@janhq/core' export const isCorePluginInstalled = () => { - if (!extensionPoints.get(DataService.GetConversations)) { + if (!extensionPoints.get(StoreService.CreateCollection)) { return false } if (!extensionPoints.get(InferenceService.InitModel)) { @@ -32,7 +33,7 @@ export const setupBasePlugins = async () => { const basePlugins = await window.electronAPI.basePlugins() if ( - !extensionPoints.get(DataService.GetConversations) || + !extensionPoints.get(StoreService.CreateCollection) || !extensionPoints.get(InferenceService.InitModel) || !extensionPoints.get(ModelManagementService.DownloadModel) ) { @@ -45,7 +46,7 @@ export const setupBasePlugins = async () => { export const execute = (name: CoreService, args?: any) => { if (!extensionPoints.get(name)) { - alert('Missing extension for function: ' + name) + // alert('Missing extension for function: ' + name) return undefined } return extensionPoints.execute(name, args) @@ -53,7 +54,7 @@ export const execute = (name: CoreService, args?: any) => { export const executeSerial = (name: CoreService, args?: any) => { if (!extensionPoints.get(name)) { - alert('Missing extension for function: ' + name) + // alert('Missing extension for function: ' + name) return Promise.resolve(undefined) } return extensionPoints.executeSerial(name, args) diff --git a/web/types/index.d.ts b/web/types/index.d.ts index 07e261a3c..3d19bd540 100644 --- a/web/types/index.d.ts +++ b/web/types/index.d.ts @@ -1,7 +1,7 @@ export {} -declare const PLUGIN_CATALOGS: string[] declare global { + declare const PLUGIN_CATALOG: string interface Window { electronAPI?: any | undefined corePlugin?: any | undefined From 0a1302e3013766a6229e56eac3ac0f790b77ed5c Mon Sep 17 00:00:00 2001 From: Service Account Date: Thu, 26 Oct 2023 02:00:59 +0000 Subject: [PATCH 20/20] janhq/jan: Update tag build 1.0.14 for inference-plugin --- plugins/inference-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inference-plugin/package.json b/plugins/inference-plugin/package.json index c13f7bafe..9d2fbd50b 100644 --- a/plugins/inference-plugin/package.json +++ b/plugins/inference-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/inference-plugin", - "version": "1.0.13", + "version": "1.0.14", "description": "Inference Plugin, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.", "icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/command-line.svg", "main": "dist/index.js",