Skip to content

Commit

Permalink
chore: refactor core folder structure - module based
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Mar 25, 2024
1 parent 77cbdc2 commit 14a6746
Show file tree
Hide file tree
Showing 28 changed files with 51 additions and 56 deletions.
2 changes: 1 addition & 1 deletion core/src/core.ts → core/src/browser/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import { DownloadRequest, FileStat, NetworkConfig, SystemInformation } from './types'
import { DownloadRequest, FileStat, NetworkConfig, SystemInformation } from '../types'

/**
* Execute a extension module function in main process
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import { Assistant, AssistantInterface } from '../index'
import { Assistant, AssistantInterface } from '../../types'
import { BaseExtension, ExtensionTypeEnum } from '../extension'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import { Thread, ThreadInterface, ThreadMessage, MessageInterface } from '../index'
import { Thread, ThreadInterface, ThreadMessage, MessageInterface } from '../../types'
import { BaseExtension, ExtensionTypeEnum } from '../extension'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@ import { getJanDataFolderPath, joinPath } from '../../core'
import { events } from '../../events'
import { BaseExtension } from '../../extension'
import { fs } from '../../fs'
import { MessageRequest, Model, ModelEvent } from '../../types'
import { MessageRequest, Model, ModelEvent } from '../../../types'
import { EngineManager } from './EngineManager'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 1,3 @@
import { log } from '../../core'
import { AIEngine } from './AIEngine'

/**
Expand Down Expand Up @@ -28,7 27,3 @@ export class EngineManager {
return window.core?.engineManager as EngineManager
}
}

/**
* The singleton instance of the ExtensionManager.
*/
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
import { executeOnMain, getJanDataFolderPath, joinPath, systemInformation } from '../../core'
import { events } from '../../events'
import { Model, ModelEvent } from '../../types'
import { Model, ModelEvent } from '../../../types'
import { OAIEngine } from './OAIEngine'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 13,7 @@ import {
ModelInfo,
ThreadContent,
ThreadMessage,
} from '../../types'
} from '../../../types'
import { events } from '../../events'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
import { Observable } from 'rxjs'
import { ModelRuntimeParams } from '../../../types'
import { ModelRuntimeParams } from '../../../../types'
/**
* Sends a request to the inference server to generate a response based on the recent messages.
* @param recentMessages - An array of recent messages to use as context for the inference.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { HuggingFaceInterface, HuggingFaceRepoData, Quantization } from '../types/huggingface'
import { Model } from '../types/model'
import { HuggingFaceInterface, HuggingFaceRepoData, Quantization } from '../../types/huggingface'
import { Model } from '../../types/model'

/**
* Hugging Face extension for converting HF models to GGUF.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import { InferenceInterface, MessageRequest, ThreadMessage } from '../index'
import { InferenceInterface, MessageRequest, ThreadMessage } from '../../types'
import { BaseExtension, ExtensionTypeEnum } from '../extension'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { GpuSetting, ImportingModel, Model, ModelInterface, OptionType } from '../index'
import { GpuSetting, ImportingModel, Model, ModelInterface, OptionType } from '../../types'

/**
* Model extension for managing models.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { GpuSetting, MonitoringInterface, OperatingSystemInfo } from '../index'
import { GpuSetting, MonitoringInterface, OperatingSystemInfo } from '../../types'

/**
* Monitoring extension for system monitoring.
Expand Down
2 changes: 1 addition & 1 deletion core/src/fs.ts → core/src/browser/fs.ts
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import { FileStat } from './types'
import { FileStat } from '../types'

/**
* Writes data to a file at the specified path.
Expand Down
29 changes: 29 additions & 0 deletions core/src/browser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 1,29 @@
/**
* Export Core module
* @module
*/
export * from './core'

/**
* Export Event module.
* @module
*/
export * from './events'

/**
* Export Filesystem module.
* @module
*/
export * from './fs'

/**
* Export Extension module.
* @module
*/
export * from './extension'

/**
* Export all base extensions.
* @module
*/
export * from './extensions'
35 changes: 3 additions & 32 deletions core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 2,13 @@
* Export all types.
* @module
*/
export * from './types/index'
export * from './types'

/**
* Export all routes
*/
export * from './api'

/**
* Export Core module
* @module
*/
export * from './core'

/**
* Export Event module.
* @module
*/
export * from './events'

/**
* Export Filesystem module.
* @module
*/
export * from './fs'

/**
* Export Extension module.
* @module
*/
export * from './extension'

/**
* Export all base extensions.
* Export browser module
* @module
*/
export * from './extensions/index'
export * from './browser'

/**
* Declare global object
Expand Down
2 changes: 1 addition & 1 deletion core/src/node/api/common/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ import {
ExtensionRoute,
FileManagerRoute,
FileSystemRoute,
} from '../../../api'
} from '../../../types/api'
import { Downloader } from '../processors/download'
import { FileSystem } from '../processors/fs'
import { Extension } from '../processors/extension'
Expand Down
2 changes: 1 addition & 1 deletion core/src/node/api/common/handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import { CoreRoutes } from '../../../api'
import { CoreRoutes } from '../../../types/api'
import { RequestAdapter } from './adapter'

export type Handler = (route: string, args: any) => any
Expand Down
2 changes: 1 addition & 1 deletion core/src/node/api/processors/download.ts
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
import { resolve, sep } from 'path'
import { DownloadEvent } from '../../../api'
import { DownloadEvent } from '../../../types/api'
import { normalizeFilePath } from '../../helper/path'
import { getJanDataFolderPath } from '../../helper'
import { DownloadManager } from '../../helper/download'
Expand Down
2 changes: 1 addition & 1 deletion core/src/node/api/restful/app/download.ts
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import { DownloadRoute } from '../../../../api'
import { DownloadRoute } from '../../../../types/api'
import { DownloadManager } from '../../../helper/download'
import { HttpServer } from '../../HttpServer'

Expand Down
2 changes: 1 addition & 1 deletion core/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 5,4 @@ export * from './extension/store'
export * from './api'
export * from './helper'
export * from './../types'
export * from './../api'
export * from '../types/api'
File renamed without changes.
1 change: 1 addition & 0 deletions core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 8,4 @@ export * from './file'
export * from './config'
export * from './huggingface'
export * from './miscellaneous'
export * from './api'
1 change: 0 additions & 1 deletion web/hooks/useActiveModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 7,6 @@ import { toaster } from '@/containers/Toast'

import { LAST_USED_MODEL_ID } from './useRecommendedModel'

import { extensionManager } from '@/extension'
import { downloadedModelsAtom } from '@/helpers/atoms/Model.atom'
import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'

Expand Down

0 comments on commit 14a6746

Please sign in to comment.