Skip to content

Commit

Permalink
Merge pull request #2787 from janhq/dev
Browse files Browse the repository at this point in the history
Release cut 0.4.12
  • Loading branch information
Van-QA authored Apr 23, 2024
2 parents 9369ac3 + f288a86 commit e54e7c0
Show file tree
Hide file tree
Showing 124 changed files with 7,241 additions and 1,701 deletions.
112 changes: 56 additions & 56 deletions .github/workflows/jan-electron-linter-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ jobs:
rm -rf ~/jan
make clean
- name: Get Commit Message for PR
if : github.event_name == 'pull_request'
run: |
echo "REPORT_PORTAL_DESCRIPTION=${{github.event.after}})" >> $GITHUB_ENV
# - name: Get Commit Message for PR
# if : github.event_name == 'pull_request'
# run: |
# echo "REPORT_PORTAL_DESCRIPTION=${{github.event.after}})" >> $GITHUB_ENV

- name: Get Commit Message for push event
if : github.event_name == 'push'
run: |
echo "REPORT_PORTAL_DESCRIPTION=${{github.sha}})" >> $GITHUB_ENV
# - name: Get Commit Message for push event
# if : github.event_name == 'push'
# run: |
# echo "REPORT_PORTAL_DESCRIPTION=${{github.sha}})" >> $GITHUB_ENV

- name: "Config report portal"
run: |
make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App macos" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"
# - name: "Config report portal"
# run: |
# make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App macos" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"

- name: Linter and test
run: |
Expand All @@ -78,9 +78,9 @@ jobs:
make test
env:
CSC_IDENTITY_AUTO_DISCOVERY: "false"
TURBO_API: "${{ secrets.TURBO_API }}"
TURBO_TEAM: "macos"
TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"
# TURBO_API: "${{ secrets.TURBO_API }}"
# TURBO_TEAM: "macos"
# TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"

test-on-macos-pr-target:
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
Expand Down Expand Up @@ -141,27 +141,27 @@ jobs:
}
make clean
- name: Get Commit Message for push event
if : github.event_name == 'push'
shell: bash
run: |
echo "REPORT_PORTAL_DESCRIPTION=${{github.sha}}" >> $GITHUB_ENV
# - name: Get Commit Message for push event
# if : github.event_name == 'push'
# shell: bash
# run: |
# echo "REPORT_PORTAL_DESCRIPTION=${{github.sha}}" >> $GITHUB_ENV

- name: "Config report portal"
shell: bash
run: |
make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App Windows ${{ matrix.antivirus-tools }}" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"
# - name: "Config report portal"
# shell: bash
# run: |
# make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App Windows ${{ matrix.antivirus-tools }}" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"

- name: Linter and test
shell: powershell
run: |
npm config set registry ${{ secrets.NPM_PROXY }} --global
yarn config set registry ${{ secrets.NPM_PROXY }} --global
make test
env:
TURBO_API: "${{ secrets.TURBO_API }}"
TURBO_TEAM: "windows"
TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"
# env:
# TURBO_API: "${{ secrets.TURBO_API }}"
# TURBO_TEAM: "windows"
# TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"
test-on-windows-pr:
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
runs-on: windows-desktop-default-windows-security
Expand Down Expand Up @@ -189,27 +189,27 @@ jobs:
}
make clean
- name: Get Commit Message for PR
if : github.event_name == 'pull_request'
shell: bash
run: |
echo "REPORT_PORTAL_DESCRIPTION=${{github.event.after}}" >> $GITHUB_ENV
# - name: Get Commit Message for PR
# if : github.event_name == 'pull_request'
# shell: bash
# run: |
# echo "REPORT_PORTAL_DESCRIPTION=${{github.event.after}}" >> $GITHUB_ENV

- name: "Config report portal"
shell: bash
run: |
make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App Windows" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"
# - name: "Config report portal"
# shell: bash
# run: |
# make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App Windows" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"

- name: Linter and test
shell: powershell
run: |
npm config set registry ${{ secrets.NPM_PROXY }} --global
yarn config set registry ${{ secrets.NPM_PROXY }} --global
make test
env:
TURBO_API: "${{ secrets.TURBO_API }}"
TURBO_TEAM: "windows"
TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"
# env:
# TURBO_API: "${{ secrets.TURBO_API }}"
# TURBO_TEAM: "windows"
# TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"

test-on-windows-pr-target:
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
Expand Down Expand Up @@ -266,20 +266,20 @@ jobs:
rm -rf ~/jan
make clean
- name: Get Commit Message for PR
if : github.event_name == 'pull_request'
run: |
echo "REPORT_PORTAL_DESCRIPTION=${{github.event.after}}" >> $GITHUB_ENV
# - name: Get Commit Message for PR
# if : github.event_name == 'pull_request'
# run: |
# echo "REPORT_PORTAL_DESCRIPTION=${{github.event.after}}" >> $GITHUB_ENV

- name: Get Commit Message for push event
if : github.event_name == 'push'
run: |
echo "REPORT_PORTAL_DESCRIPTION=${{github.sha}}" >> $GITHUB_ENV
# - name: Get Commit Message for push event
# if : github.event_name == 'push'
# run: |
# echo "REPORT_PORTAL_DESCRIPTION=${{github.sha}}" >> $GITHUB_ENV

- name: "Config report portal"
shell: bash
run: |
make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App Linux" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"
# - name: "Config report portal"
# shell: bash
# run: |
# make update-playwright-config REPORT_PORTAL_URL=${{ secrets.REPORT_PORTAL_URL }} REPORT_PORTAL_API_KEY=${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_PROJECT_NAME=${{ secrets.REPORT_PORTAL_PROJECT_NAME }} REPORT_PORTAL_LAUNCH_NAME="Jan App Linux" REPORT_PORTAL_DESCRIPTION="${{env.REPORT_PORTAL_DESCRIPTION}}"

- name: Linter and test
run: |
Expand All @@ -288,10 +288,10 @@ jobs:
npm config set registry ${{ secrets.NPM_PROXY }} --global
yarn config set registry ${{ secrets.NPM_PROXY }} --global
make test
env:
TURBO_API: "${{ secrets.TURBO_API }}"
TURBO_TEAM: "linux"
TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"
# env:
# TURBO_API: "${{ secrets.TURBO_API }}"
# TURBO_TEAM: "linux"
# TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"

test-on-ubuntu-pr-target:
runs-on: [self-hosted, Linux, ubuntu-desktop]
Expand Down
11 changes: 11 additions & 0 deletions core/src/browser/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ const downloadFile: (downloadRequest: DownloadRequest, network?: NetworkConfig)
network
) => globalThis.core?.api?.downloadFile(downloadRequest, network)

/**
* Get unit in bytes for a remote file.
*
* @param url - The url of the file.
* @returns {Promise<number>} - A promise that resolves with the file size.
*/
const getFileSize: (url: string) => Promise<number> = (url: string) =>
globalThis.core.api?.getFileSize(url)

/**
* Aborts the download of a specific file.
* @param {string} fileName - The name of the file whose download is to be aborted.
Expand Down Expand Up @@ -122,6 +131,7 @@ const systemInformation: () => Promise<SystemInformation> = () =>
*/
const showToast: (title: string, message: string) => void = (title, message) =>
globalThis.core.api?.showToast(title, message)

/**
* Register extension point function type definition
*/
Expand Down Expand Up @@ -150,5 +160,6 @@ export {
getUserHomePath,
systemInformation,
showToast,
getFileSize,
FileStat,
}
30 changes: 0 additions & 30 deletions core/src/browser/extensions/huggingface.ts

This file was deleted.

5 changes: 0 additions & 5 deletions core/src/browser/extensions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export { AssistantExtension } from './assistant'
*/
export { ModelExtension } from './model'

/**
* Hugging Face extension for converting HF models to GGUF.
*/
export { HuggingFaceExtension } from './huggingface'

/**
* Base AI Engines.
*/
Expand Down
11 changes: 10 additions & 1 deletion core/src/browser/extensions/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { GpuSetting, ImportingModel, Model, ModelInterface, OptionType } from '../../types'
import {
GpuSetting,
HuggingFaceRepoData,
ImportingModel,
Model,
ModelInterface,
OptionType,
} from '../../types'

/**
* Model extension for managing models.
Expand All @@ -24,4 +31,6 @@ export abstract class ModelExtension extends BaseExtension implements ModelInter
abstract getConfiguredModels(): Promise<Model[]>
abstract importModels(models: ImportingModel[], optionType: OptionType): Promise<void>
abstract updateModelInfo(modelInfo: Partial<Model>): Promise<Model>
abstract fetchHuggingFaceRepoData(repoId: string): Promise<HuggingFaceRepoData>
abstract getDefaultModel(): Promise<Model>
}
38 changes: 31 additions & 7 deletions core/src/node/api/processors/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Downloader implements Processor {
localPath: normalizedPath,
}
DownloadManager.instance.downloadProgressMap[modelId] = initialDownloadState
DownloadManager.instance.downloadInfo[normalizedPath] = initialDownloadState

if (downloadRequest.downloadType === 'extension') {
observer?.(DownloadEvent.onFileDownloadUpdate, initialDownloadState)
Expand Down Expand Up @@ -118,19 +119,42 @@ export class Downloader implements Processor {
if (rq) {
DownloadManager.instance.networkRequests[fileName] = undefined
rq?.abort()
} else {
observer?.(DownloadEvent.onFileDownloadError, {
fileName,
error: 'aborted',
})
}

const downloadInfo = DownloadManager.instance.downloadInfo[fileName]
observer?.(DownloadEvent.onFileDownloadError, {
...downloadInfo,
fileName,
error: 'aborted',
})
}

resumeDownload(observer: any, fileName: any) {
resumeDownload(_observer: any, fileName: any) {
DownloadManager.instance.networkRequests[fileName]?.resume()
}

pauseDownload(observer: any, fileName: any) {
pauseDownload(_observer: any, fileName: any) {
DownloadManager.instance.networkRequests[fileName]?.pause()
}

async getFileSize(_observer: any, url: string): Promise<number> {
return new Promise((resolve, reject) => {
const request = require('request')
request(
{
url,
method: 'HEAD',
},
function (err: any, response: any) {
if (err) {
console.error('Getting file size failed:', err)
reject(err)
} else {
const size: number = response.headers['content-length'] ?? -1
resolve(size)
}
}
)
})
}
}
4 changes: 4 additions & 0 deletions core/src/node/helper/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ export class DownloadManager {

public static instance: DownloadManager = new DownloadManager()

// store the download information with key is model id
public downloadProgressMap: Record<string, DownloadState> = {}

// store the download infomation with key is normalized file path
public downloadInfo: Record<string, DownloadState> = {}

constructor() {
if (DownloadManager.instance) {
return DownloadManager.instance
Expand Down
2 changes: 1 addition & 1 deletion core/src/types/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export enum AppRoute {
startServer = 'startServer',
stopServer = 'stopServer',
log = 'log',
logServer = 'logServer',
systemInformation = 'systemInformation',
showToast = 'showToast',
}
Expand All @@ -52,6 +51,7 @@ export enum DownloadRoute {
pauseDownload = 'pauseDownload',
resumeDownload = 'resumeDownload',
getDownloadProgress = 'getDownloadProgress',
getFileSize = 'getFileSize',
}

export enum DownloadEvent {
Expand Down
Loading

0 comments on commit e54e7c0

Please sign in to comment.