Skip to content

Commit

Permalink
chore: update core services and module export (janhq#376)
Browse files Browse the repository at this point in the history
* chore: update core services and module export

* Correct version of plugins (janhq#374)

Co-authored-by: Hien To <[email protected]>

* janhq/jan: Update tag build 1.0.2 for data-plugin

* janhq/jan: Update tag build 1.0.2 for inference-plugin

* janhq/jan: Update tag build 1.0.2 for model-management-plugin

* janhq/jan: Update tag build 1.0.2 for monitoring-plugin

* janhq/jan: Update tag build 1.0.2 for openai-plugin

* chore: update web to use @janhq/core module

---------

Co-authored-by: hiento09 <[email protected]>
Co-authored-by: Hien To <[email protected]>
Co-authored-by: Service Account <[email protected]>
  • Loading branch information
4 people authored Oct 17, 2023
1 parent c220d7c commit b460426
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 47 deletions.
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
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
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"@janhq/plugin-core": "^0.1.8",
"@janhq/core": "^0.1.1",
"@tailwindcss/typography": "^0.5.9",
"@types/react": "18.2.15",
"@types/react-dom": "18.2.7",
Expand Down

0 comments on commit b460426

Please sign in to comment.