repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
jan
github_2023
janhq
typescript
openFileExplorer
const openFileExplorer: (path: string) => Promise<any> = (path) => globalThis.core.api?.openFileExplorer(path)
/** * Opens the file explorer at a specific path. * @param {string} path - The path to open in the file explorer. * @returns {Promise<any>} A promise that resolves when the file explorer is opened. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L59-L60
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
joinPath
const joinPath: (paths: string[]) => Promise<string> = (paths) => globalThis.core.api?.joinPath(paths)
/** * Joins multiple paths together. * @param paths - The paths to join. * @returns {Promise<string>} A promise that resolves with the joined path. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L67-L68
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
dirName
const dirName: (path: string) => Promise<string> = (path) => globalThis.core.api?.dirName(path)
/** * Get dirname of a file path. * @param path - The file path to retrieve dirname. * @returns {Promise<string>} A promise that resolves the dirname. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L75-L76
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
baseName
const baseName: (paths: string) => Promise<string> = (path) => globalThis.core.api?.baseName(path)
/** * Retrieve the basename from an url. * @param path - The path to retrieve. * @returns {Promise<string>} A promise that resolves with the basename. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L83-L84
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
openExternalUrl
const openExternalUrl: (url: string) => Promise<any> = (url) => globalThis.core.api?.openExternalUrl(url)
/** * Opens an external URL in the default web browser. * * @param {string} url - The URL to open. * @returns {Promise<any>} - A promise that resolves when the URL has been successfully opened. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L92-L93
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
getResourcePath
const getResourcePath: () => Promise<string> = () => globalThis.core.api?.getResourcePath()
/** * Gets the resource path of the application. * * @returns {Promise<string>} - A promise that resolves with the resource path. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L100-L101
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
getUserHomePath
const getUserHomePath = (): Promise<string> => globalThis.core.api?.getUserHomePath()
/** * Gets the user's home path. * @returns return user's home path */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L107-L108
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
log
const log: (message: string, fileName?: string) => void = (message, fileName) => globalThis.core.api?.log(message, fileName)
/** * Log to file from browser processes. * * @param message - Message to log. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L115-L116
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
isSubdirectory
const isSubdirectory: (from: string, to: string) => Promise<boolean> = ( from: string, to: string ) => globalThis.core.api?.isSubdirectory(from, to)
/** * Check whether the path is a subdirectory of another path. * * @param from - The path to check. * @param to - The path to check against. * * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating whether the path is a subdirectory. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L126-L129
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
systemInformation
const systemInformation: () => Promise<SystemInformation> = () => globalThis.core.api?.systemInformation()
/** * Get system information * @returns {Promise<any>} - A promise that resolves with the system information. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L135-L136
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
showToast
const showToast: (title: string, message: string) => void = (title, message) => globalThis.core.api?.showToast(title, message)
/** * Show toast message from browser processes. * @param title * @param message * @returns */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L144-L145
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
on
const on: (eventName: string, handler: Function) => void = (eventName, handler) => { globalThis.core?.events?.on(eventName, handler) }
/** * Adds an observer for an event. * * @param eventName The name of the event to observe. * @param handler The handler function to call when the event is observed. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/events.ts#L7-L9
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
off
const off: (eventName: string, handler: Function) => void = (eventName, handler) => { globalThis.core?.events?.off(eventName, handler) }
/** * Removes an observer for an event. * * @param eventName The name of the event to stop observing. * @param handler The handler function to call when the event is observed. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/events.ts#L17-L19
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
emit
const emit: (eventName: string, object: any) => void = (eventName, object) => { globalThis.core?.events?.emit(eventName, object) }
/** * Emits an event. * * @param eventName The name of the event to emit. * @param object The object to pass to the event callback. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/events.ts#L27-L29
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
writeFileSync
const writeFileSync = (...args: any[]) => globalThis.core.api?.writeFileSync(...args)
/** * Writes data to a file at the specified path. * @returns {Promise<any>} A Promise that resolves when the file is written successfully. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L7-L7
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
writeBlob
const writeBlob: (path: string, data: string) => Promise<any> = (path, data) => globalThis.core.api?.writeBlob(path, data)
/** * Writes blob data to a file at the specified path. * @param path - The path to file. * @param data - The blob data. * @returns */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L15-L16
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
readFileSync
const readFileSync = (...args: any[]) => globalThis.core.api?.readFileSync(...args)
/** * Reads the contents of a file at the specified path. * @returns {Promise<any>} A Promise that resolves with the contents of the file. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L22-L22
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
existsSync
const existsSync = (...args: any[]) => globalThis.core.api?.existsSync(...args)
/** * Check whether the file exists * @param {string} path * @returns {boolean} A boolean indicating whether the path is a file. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L28-L28
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
readdirSync
const readdirSync = (...args: any[]) => globalThis.core.api?.readdirSync(...args)
/** * List the directory files * @returns {Promise<any>} A Promise that resolves with the contents of the directory. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L33-L33
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
mkdir
const mkdir = (...args: any[]) => globalThis.core.api?.mkdir(...args)
/** * Creates a directory at the specified path. * @returns {Promise<any>} A Promise that resolves when the directory is created successfully. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L38-L38
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
rm
const rm = (...args: any[]) => globalThis.core.api?.rm(...args, { recursive: true, force: true })
/** * Removes a directory at the specified path. * @returns {Promise<any>} A Promise that resolves when the directory is removed successfully. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L44-L44
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
unlinkSync
const unlinkSync = (...args: any[]) => globalThis.core.api?.unlinkSync(...args)
/** * Deletes a file from the local file system. * @param {string} path - The path of the file to delete. * @returns {Promise<any>} A Promise that resolves when the file is deleted. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L51-L51
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
appendFileSync
const appendFileSync = (...args: any[]) => globalThis.core.api?.appendFileSync(...args)
/** * Appends data to a file at the specified path. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L56-L56
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
getGgufFiles
const getGgufFiles: (paths: string[]) => Promise<any> = ( paths) => globalThis.core.api?.getGgufFiles(paths)
/** * Gets the list of gguf files in a directory * * @param path - The paths to the file. * @returns {Promise<{any}>} - A promise that resolves with the list of gguf and non-gguf files */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L67-L68
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
fileStat
const fileStat: (path: string, outsideJanDataFolder?: boolean) => Promise<FileStat | undefined> = ( path, outsideJanDataFolder ) => globalThis.core.api?.fileStat(path, outsideJanDataFolder)
/** * Gets the file's stats. * * @param path - The path to the file. * @param outsideJanDataFolder - Whether the file is outside the Jan data folder. * @returns {Promise<FileStat>} - A promise that resolves with the file's stats. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/fs.ts#L77-L80
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
EngineManager.register
register<T extends AIEngine>(engine: T) { this.engines.set(engine.provider, engine) }
/** * Registers an engine. * @param engine - The engine to register. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/extensions/engines/EngineManager.ts#L14-L16
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
EngineManager.get
get<T extends AIEngine>(provider: string): T | undefined { // Backward compatible provider // nitro is migrated to cortex if ( [ InferenceEngine.nitro, InferenceEngine.cortex, InferenceEngine.cortex_llamacpp, InferenceEngine.cortex_onnx, InferenceEngine.cortex_t...
/** * Retrieves a engine by provider. * @param provider - The name of the engine to retrieve. * @returns The engine, if found. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/extensions/engines/EngineManager.ts#L23-L41
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
EngineManager.instance
static instance(): EngineManager { return (window.core?.engineManager as EngineManager) ?? new EngineManager() }
/** * The instance of the engine manager. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/extensions/engines/EngineManager.ts#L46-L48
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ModelManager.register
register<T extends Model>(model: T) { if (this.models.has(model.id)) { this.models.set(model.id, { ...model, ...this.models.get(model.id), }) } else { this.models.set(model.id, model) } events.emit(ModelEvent.OnModelsUpdate, {}) }
/** * Registers a model. * @param model - The model to register. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/models/manager.ts#L20-L30
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ModelManager.get
get<T extends Model>(id: string): T | undefined { return this.models.get(id) as T | undefined }
/** * Retrieves a model by it's id. * @param id - The id of the model to retrieve. * @returns The model, if found. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/models/manager.ts#L37-L39
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ModelManager.instance
static instance(): ModelManager { return (window.core?.modelManager as ModelManager) ?? new ModelManager() }
/** * The instance of the tool manager. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/models/manager.ts#L44-L46
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ToolManager.register
register<T extends InferenceTool>(tool: T) { this.tools.set(tool.name, tool) }
/** * Registers a tool. * @param tool - The tool to register. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/tools/manager.ts#L14-L16
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ToolManager.get
get<T extends InferenceTool>(name: string): T | undefined { return this.tools.get(name) as T | undefined }
/** * Retrieves a tool by it's name. * @param name - The name of the tool to retrieve. * @returns The tool, if found. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/tools/manager.ts#L23-L25
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ToolManager.process
process(request: MessageRequest, tools: AssistantTool[]): Promise<MessageRequest> { return tools.reduce((prevPromise, currentTool) => { return prevPromise.then((prevResult) => { return currentTool.enabled ? this.get(currentTool.type)?.process(prevResult, currentTool) ?? Promise...
/* ** Process the message request with the tools. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/tools/manager.ts#L30-L39
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ToolManager.instance
static instance(): ToolManager { return (window.core?.toolManager as ToolManager) ?? new ToolManager() }
/** * The instance of the tool manager. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/tools/manager.ts#L44-L46
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
RequestAdapter.process
process(route: string, ...args: any) { if (route in DownloadRoute) { return this.downloader.process(route, ...args) } else if (route in FileSystemRoute) { return this.fileSystem.process(route, ...args) } else if (route in ExtensionRoute) { return this.extension.process(route, ...args) ...
// TODO: Clearer Factory pattern here
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/common/adapter.ts#L30-L42
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
App.joinPath
joinPath(args: any[]) { return join(...args) }
/** * Joins multiple paths together, respect to the current OS. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/app.ts#L28-L30
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
App.dirName
dirName(path: string) { const arg = path.startsWith(`file:/`) || path.startsWith(`file:\\`) ? join(getJanDataFolderPath(), normalizeFilePath(path)) : path return dirname(arg) }
/** * Get dirname of a file path. * @param path - The file path to retrieve dirname. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/app.ts#L36-L42
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
App.isSubdirectory
isSubdirectory(from: any, to: any) { const rel = relative(from, to) const isSubdir = rel && !rel.startsWith('..') && !isAbsolute(rel) if (isSubdir === '') return false else return isSubdir }
/** * Checks if the given path is a subdirectory of the given directory. * * @param from - The path to check. * @param to - The directory to check against. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/app.ts#L50-L56
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
App.baseName
baseName(args: any) { return basename(args) }
/** * Retrieve basename from given path, respect to the current OS. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/app.ts#L61-L63
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
App.log
log(args: any) { writeLog(args) }
/** * Log message to log file. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/app.ts#L68-L70
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.baseExtensions
async baseExtensions() { const baseExtensionPath = join(appResourcePath(), 'pre-install') return readdirSync(baseExtensionPath) .filter((file) => extname(file) === '.tgz') .map((file) => join(baseExtensionPath, file)) }
/** * Returns the paths of the base extensions. * @returns An array of paths to the base extensions. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/extension.ts#L44-L49
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.installExtension
async installExtension(extensions: any) { // Install and activate all provided extensions const installed = await installExtensions(extensions) return JSON.parse(JSON.stringify(installed)) }
/**MARK: Extension Manager handlers */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/extension.ts#L52-L56
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.uninstallExtension
async uninstallExtension(extensions: any) { // Uninstall all provided extensions for (const ext of extensions) { const extension = getExtension(ext) await extension.uninstall() if (extension.name) removeExtension(extension.name) } // Reload all renderer pages if needed return true...
// Register IPC route to uninstall a extension
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/extension.ts#L59-L69
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.updateExtension
async updateExtension(extensions: any) { // Update all provided extensions const updated: any[] = [] for (const ext of extensions) { const extension = getExtension(ext) const res = await extension.update() if (res) updated.push(extension) } // Reload all renderer pages if needed ...
// Register IPC route to update a extension
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/extension.ts#L72-L83
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
FSExt.getJanDataFolderPath
getJanDataFolderPath() { return Promise.resolve(getPath()) }
// Handles the 'getJanDataFolderPath' IPC event. This event is triggered to get the user space path.
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/fsExt.ts#L22-L24
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
FSExt.getResourcePath
getResourcePath() { return appResourcePath() }
// Handles the 'getResourcePath' IPC event. This event is triggered to get the resource path.
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/fsExt.ts#L27-L29
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
FSExt.getUserHomePath
getUserHomePath() { return defaultAppConfig().data_folder }
// CAUTION: This would not return OS home path but the app data path.
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/fsExt.ts#L33-L35
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
FSExt.fileStat
fileStat(path: string, outsideJanDataFolder?: boolean) { const normalizedPath = normalizeFilePath(path) const fullPath = outsideJanDataFolder ? normalizedPath : join(getJanDataFolderPath(), normalizedPath) const isExist = fs.existsSync(fullPath) if (!isExist) return undefined const isD...
// handle fs is directory here
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/api/processors/fsExt.ts#L38-L56
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.constructor
constructor(origin?: string, options = {}) { const Arborist = require('@npmcli/arborist') const defaultOpts = { version: false, fullMetadata: true, Arborist, } this.origin = origin this.installOptions = { ...defaultOpts, ...options } }
/** * Set installOptions with defaults for options that have not been provided. * @param {string} [origin] Original specification provided to fetch the package. * @param {Object} [options] Options provided to pacote when fetching the manifest. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L43-L53
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.specifier
get specifier() { return ( this.origin + (this.installOptions.version ? '@' + this.installOptions.version : '') ) }
/** * Package name with version number. * @type {string} */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L59-L64
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.active
get active() { return this._active }
/** * Whether the extension should be registered with its activation points. * @type {boolean} */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L70-L72
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.getManifest
async getManifest() { // Get the package's manifest (package.json object) try { const pacote = require('pacote') return pacote .manifest(this.specifier, this.installOptions) .then((mnf: any) => { // set the Package properties based on the it's manifest this.name =...
/** * Set Package details based on it's manifest * @returns {Promise.<Boolean>} Resolves to true when the action completed */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L78-L99
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension._install
async _install() { try { // import the manifest details await this.getManifest() // Install the package in a child folder of the given folder const pacote = require('pacote') await pacote.extract( this.specifier, join( ExtensionManager.instance.getExtensionsP...
/** * Extract extension to extensions folder. * @returns {Promise.<Extension>} This extension * @private */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L106-L133
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.subscribe
subscribe(name: string, cb: () => void) { this.listeners[name] = cb }
/** * Subscribe to updates of this extension * @param {string} name name of the callback to register * @param {callback} cb The function to execute on update */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L140-L142
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.unsubscribe
unsubscribe(name: string) { delete this.listeners[name] }
/** * Remove subscription * @param {string} name name of the callback to remove */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L148-L150
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.emitUpdate
emitUpdate() { for (const cb in this.listeners) { this.listeners[cb].call(null, this) } }
/** * Execute listeners */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L155-L159
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.update
async update(version = false) { if (await this.isUpdateAvailable()) { this.installOptions.version = version await this._install() return true } return false }
/** * Check for updates and install if available. * @param {string} version The version to update to. * @returns {boolean} Whether an update was performed. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L166-L174
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.isUpdateAvailable
async isUpdateAvailable() { const pacote = require('pacote') if (this.origin) { return pacote.manifest(this.origin).then((mnf: any) => { return mnf.version !== this.version ? mnf.version : false }) } }
/** * Check if a new version of the extension is available at the origin. * @returns the latest available version if a new version is available or false if not. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L180-L187
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.uninstall
async uninstall(): Promise<void> { const path = ExtensionManager.instance.getExtensionsPath() const extPath = resolve(path ?? '', this.name ?? '') rmdirSync(extPath, { recursive: true }) this.emitUpdate() }
/** * Remove extension and refresh renderers. * @returns {Promise} */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L193-L199
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Extension.setActive
setActive(active: boolean) { this._active = active this.emitUpdate() return this }
/** * Set a extension's active state. This determines if a extension should be loaded on initialisation. * @param {boolean} active State to set _active to * @returns {Extension} This extension */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/extension.ts#L206-L210
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
registerExtensionProtocol
async function registerExtensionProtocol() { let electron: any = undefined try { const moduleName = 'electron' electron = await import(moduleName) } catch (err) { console.error('Electron is not available') } const extensionPath = ExtensionManager.instance.getExtensionsPath() if (electron && ele...
/** * Create extensions protocol to provide extensions to renderer * @private * @returns {boolean} Whether the protocol registration was successful */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/index.ts#L34-L52
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
loadExtension
function loadExtension(ext: any) { // Create new extension, populate it with ext details and save it to the store const extension = new Extension() for (const key in ext) { if (Object.prototype.hasOwnProperty.call(ext, key)) { // Use Object.defineProperty to set the properties as writable Object....
/** * Check the given extension object. If it is marked for uninstalling, the extension files are removed. * Otherwise a Extension instance for the provided object is created and added to the store. * @private * @param {Object} ext Extension info */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/extension/index.ts#L99-L116
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
DownloadManager.setRequest
setRequest(fileName: string, request: any | undefined) { this.networkRequests[fileName] = request }
/** * Sets a network request for a specific file. * @param {string} fileName - The name of the file. * @param {Request | undefined} request - The network request to set, or undefined to clear the request. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/download.ts#L27-L29
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
LoggerManager.register
register(logger: Logger) { this.loggers.set(logger.name, logger) }
// Register a new logger. If a logger with the same name already exists, it will be replaced.
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/logger.ts#L25-L27
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
LoggerManager.unregister
unregister(name: string) { this.loggers.delete(name) }
// Unregister a logger by its name.
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/logger.ts#L29-L31
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
LoggerManager.flushLogs
flushLogs() { // If flushLogs is already running, do nothing. if (this.isFlushing) { return } this.isFlushing = true while (this.queuedLogs.length > 0 && this.loggers.size > 0) { const log = this.queuedLogs.shift() this.loggers.forEach((logger) => { logger.log(log) ...
// Flush queued logs to all registered loggers.
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/logger.ts#L38-L54
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
LoggerManager.log
log(args: any) { this.queuedLogs.push(args) this.flushLogs() }
// Log message using all registered loggers.
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/logger.ts#L57-L61
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
LoggerManager.instance
static instance(): LoggerManager { let instance: LoggerManager | undefined = global.core?.logger if (!instance) { instance = new LoggerManager() if (!global.core) global.core = {} global.core.logger = instance } return instance }
/** * The instance of the logger. * If an instance doesn't exist, it creates a new one. * This ensures that there is only one LoggerManager instance at any time. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/logger.ts#L68-L76
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ModuleManager.setModule
setModule(moduleName: string, nodule: any | undefined) { this.requiredModules[moduleName] = nodule }
/** * Sets a module. * @param {string} moduleName - The name of the module. * @param {any | undefined} nodule - The module to set, or undefined to clear the module. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/module.ts#L21-L23
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
ModuleManager.clearImportedModules
clearImportedModules() { this.requiredModules = {} }
/** * Clears all imported modules. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/node/helper/module.ts#L28-L30
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
Home
const Home = () => { return ( <Fragment> <Hero /> <BuiltWithLove /> <Feature /> {/* <APIStructure /> */} <Customizable /> <WallOfLove /> <Principles /> <CTANewsletter /> <Statistic /> <CTADownload /> </Fragment> ) }
// import APIStructure from './APIStructure'
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/docs/src/components/Home/index.tsx#L14-L29
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
handleIPCs
function handleIPCs() { // Inject core handlers for IPCs injectHandler() // Handle native IPCs handleAppIPCs() }
/** * Handles various IPC messages from the renderer process. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/electron/main.ts#L140-L146
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
WindowManager.createMainWindow
async createMainWindow(preloadPath: string, startUrl: string) { const bounds = await getBounds() this.mainWindow = new BrowserWindow({ ...mainWindowConfig, width: bounds.width, height: bounds.height, show: false, x: bounds.x, y: bounds.y, webPreferences: { node...
/** * Creates a new window instance. * @returns The created window instance. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/electron/managers/window.ts#L24-L86
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
WindowManager.sendMainAppDeepLink
sendMainAppDeepLink(url: string): void { this.deeplink = url const interval = setInterval(() => { if (!this.deeplink) clearInterval(interval) const mainWindow = this.mainWindow if (mainWindow) { mainWindow.webContents.send(AppEvent.onDeepLink, this.deeplink) if (mainWindow.isMi...
/** * Try to send the deep link to the main app. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/electron/managers/window.ts#L161-L172
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
WindowManager.sendMainViewState
sendMainViewState(route: string) { if (this.mainWindow && !this.mainWindow.isDestroyed()) { this.mainWindow.webContents.send(AppEvent.onMainViewStateChange, route) } }
/** * Send main view state to the main app. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/electron/managers/window.ts#L177-L181
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
WindowManager.ackDeepLink
ackDeepLink() { this.deeplink = undefined }
/** * Acknowledges that the window has received a deep link. We can remove it. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/electron/managers/window.ts#L201-L203
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
BasePage.isElementVisible
async isElementVisible(selector: any) { let isVisible = true await this.page .waitForSelector(selector, { state: 'visible', timeout: TIMEOUT }) .catch(() => { isVisible = false }) return isVisible }
//wait and find a specific element with its selector and return Visible
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/electron/tests/pages/basePage.ts#L50-L58
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
JanAssistantExtension.onUnload
onUnload(): void {}
/** * Called when the extension is unloaded. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/assistant-extension/src/index.ts#L41-L41
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
RetrievalTool.normalize
normalize(request: MessageRequest): MessageRequest { request.messages = request.messages?.map((message) => { if ( message.content && typeof message.content !== 'string' && (message.content.length ?? 0) > 0 ) { return { ...message, content: [message.con...
// TODO: Remove it until engines can handle multiple content types
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/assistant-extension/src/tools/retrieval.ts#L102-L117
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.onLoad
async onLoad() { this.queue.add(() => this.healthz()) }
/** * Called when the extension is loaded. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L28-L30
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.onUnload
onUnload() {}
/** * Called when the extension is unloaded. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L35-L35
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.listThreads
async listThreads(): Promise<Thread[]> { return this.queue.add(() => ky .get(`${API_URL}/v1/threads?limit=-1`) .json<ThreadList>() .then((e) => e.data) ) as Promise<Thread[]> }
/** * Returns a Promise that resolves to an array of Conversation objects. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L40-L47
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.createThread
async createThread(thread: Thread): Promise<Thread> { return this.queue.add(() => ky.post(`${API_URL}/v1/threads`, { json: thread }).json<Thread>() ) as Promise<Thread> }
/** * Saves a Thread object to a json file. * @param thread The Thread object to save. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L53-L57
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.modifyThread
async modifyThread(thread: Thread): Promise<void> { return this.queue .add(() => ky.patch(`${API_URL}/v1/threads/${thread.id}`, { json: thread }) ) .then() }
/** * Saves a Thread object to a json file. * @param thread The Thread object to save. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L63-L69
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.deleteThread
async deleteThread(threadId: string): Promise<void> { return this.queue .add(() => ky.delete(`${API_URL}/v1/threads/${threadId}`)) .then() }
/** * Delete a thread with the specified ID. * @param threadId The ID of the thread to delete. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L75-L79
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.createMessage
async createMessage(message: ThreadMessage): Promise<ThreadMessage> { return this.queue.add(() => ky .post(`${API_URL}/v1/threads/${message.thread_id}/messages`, { json: message, }) .json<ThreadMessage>() ) as Promise<ThreadMessage> }
/** * Adds a new message to a specified thread. * @param message The ThreadMessage object to be added. * @returns A Promise that resolves when the message has been added. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L86-L94
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.modifyMessage
async modifyMessage(message: ThreadMessage): Promise<ThreadMessage> { return this.queue.add(() => ky .patch( `${API_URL}/v1/threads/${message.thread_id}/messages/${message.id}`, { json: message, } ) .json<ThreadMessage>() ) as Promise<Threa...
/** * Modifies a message in a thread. * @param message * @returns */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L101-L112
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.deleteMessage
async deleteMessage(threadId: string, messageId: string): Promise<void> { return this.queue .add(() => ky.delete(`${API_URL}/v1/threads/${threadId}/messages/${messageId}`) ) .then() }
/** * Deletes a specific message from a thread. * @param threadId The ID of the thread containing the message. * @param messageId The ID of the message to be deleted. * @returns A Promise that resolves when the message has been successfully deleted. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L120-L126
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.listMessages
async listMessages(threadId: string): Promise<ThreadMessage[]> { return this.queue.add(() => ky .get(`${API_URL}/v1/threads/${threadId}/messages?order=asc&limit=-1`) .json<MessageList>() .then((e) => e.data) ) as Promise<ThreadMessage[]> }
/** * Retrieves all messages for a specified thread. * @param threadId The ID of the thread to get messages from. * @returns A Promise that resolves to an array of ThreadMessage objects. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L133-L140
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.getThreadAssistant
async getThreadAssistant(threadId: string): Promise<ThreadAssistantInfo> { return this.queue.add(() => ky .get(`${API_URL}/v1/assistants/${threadId}?limit=-1`) .json<ThreadAssistantInfo>() ) as Promise<ThreadAssistantInfo> }
/** * Retrieves the assistant information for a specified thread. * @param threadId The ID of the thread for which to retrieve assistant information. * @returns A Promise that resolves to a ThreadAssistantInfo object containing * the details of the assistant associated with the specified thread. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L148-L154
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.createThreadAssistant
async createThreadAssistant( threadId: string, assistant: ThreadAssistantInfo ): Promise<ThreadAssistantInfo> { return this.queue.add(() => ky .post(`${API_URL}/v1/assistants/${threadId}`, { json: assistant }) .json<ThreadAssistantInfo>() ) as Promise<ThreadAssistantInfo> }
/** * Creates a new assistant for the specified thread. * @param threadId The ID of the thread for which the assistant is being created. * @param assistant The information about the assistant to be created. * @returns A Promise that resolves to the newly created ThreadAssistantInfo object. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L161-L170
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.modifyThreadAssistant
async modifyThreadAssistant( threadId: string, assistant: ThreadAssistantInfo ): Promise<ThreadAssistantInfo> { return this.queue.add(() => ky .patch(`${API_URL}/v1/assistants/${threadId}`, { json: assistant }) .json<ThreadAssistantInfo>() ) as Promise<ThreadAssistantInfo> }
/** * Modifies an existing assistant for the specified thread. * @param threadId The ID of the thread for which the assistant is being modified. * @param assistant The updated information for the assistant. * @returns A Promise that resolves to the updated ThreadAssistantInfo object. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L178-L187
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
CortexConversationalExtension.healthz
async healthz(): Promise<void> { return ky .get(`${API_URL}/healthz`, { retry: { limit: 20, delay: () => 500, methods: ['get'] }, }) .then(() => {}) }
/** * Do health check on cortex.cpp * @returns */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/conversational-extension/src/index.ts#L193-L199
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
JSONEngineManagementExtension.onLoad
async onLoad() { // Symlink Engines Directory await executeOnMain(NODE, 'symlinkEngines') // Run Healthcheck this.queue.add(() => this.healthz()) // Update default local engine this.updateDefaultEngine() // Populate default remote engines this.populateDefaultRemoteEngines() }
/** * Called when the extension is loaded. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/engine-management-extension/src/index.ts#L33-L43
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
JSONEngineManagementExtension.onUnload
onUnload() {}
/** * Called when the extension is unloaded. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/engine-management-extension/src/index.ts#L48-L48
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
JSONEngineManagementExtension.getEngines
async getEngines(): Promise<Engines> { return this.queue.add(() => ky .get(`${API_URL}/v1/engines`) .json<Engines>() .then((e) => e) ) as Promise<Engines> }
/** * @returns A Promise that resolves to an object of list engines. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/engine-management-extension/src/index.ts#L53-L60
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
JSONEngineManagementExtension.getRemoteModels
async getRemoteModels(name: string): Promise<any> { return this.queue.add(() => ky .get(`${API_URL}/v1/models/remote/${name}`) .json<Model[]>() .then((e) => e) .catch(() => []) ) as Promise<Model[]> }
/** * @returns A Promise that resolves to an object of list engines. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/engine-management-extension/src/index.ts#L65-L73
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
JSONEngineManagementExtension.getInstalledEngines
async getInstalledEngines(name: InferenceEngine): Promise<EngineVariant[]> { return this.queue.add(() => ky .get(`${API_URL}/v1/engines/${name}`) .json<EngineVariant[]>() .then((e) => e) ) as Promise<EngineVariant[]> }
/** * @param name - Inference engine name. * @returns A Promise that resolves to an array of installed engine. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/engine-management-extension/src/index.ts#L79-L86
f8f19af8c54989ad9f58e108bf93c08ef6beb03b
jan
github_2023
janhq
typescript
JSONEngineManagementExtension.getReleasedEnginesByVersion
async getReleasedEnginesByVersion( name: InferenceEngine, version: string, platform?: string ) { return this.queue.add(() => ky .get(`${API_URL}/v1/engines/${name}/releases/${version}`) .json<EngineReleased[]>() .then((e) => platform ? e.filter((r) => r.name.inc...
/** * @param name - Inference engine name. * @param version - Version of the engine. * @param platform - Optional to sort by operating system. macOS, linux, windows. * @returns A Promise that resolves to an array of latest released engine by version. */
https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/extensions/engine-management-extension/src/index.ts#L94-L107
f8f19af8c54989ad9f58e108bf93c08ef6beb03b