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

feat: Jan Hub Revamp #4491

Merged
merged 20 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions core/src/browser/extensions/model.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { Model, ModelInterface, OptionType } from '../../types'
import { Model, ModelInterface, ModelSource, OptionType } from '../../types'

/**
* Model extension for managing models.
*/
export abstract class ModelExtension extends BaseExtension implements ModelInterface {
export abstract class ModelExtension
extends BaseExtension
implements ModelInterface
{
/**
* Model extension type.
*/
type(): ExtensionTypeEnum | undefined {
return ExtensionTypeEnum.Model

Check warning on line 15 in core/src/browser/extensions/model.ts

View workflow job for this annotation

GitHub Actions / coverage-check

15 line is not covered with tests
}

abstract configurePullOptions(configs: { [key: string]: any }): Promise<any>
Expand All @@ -25,4 +28,16 @@
abstract updateModel(modelInfo: Partial<Model>): Promise<Model>
abstract deleteModel(model: string): Promise<void>
abstract isModelLoaded(model: string): Promise<boolean>
/**
* Get model sources
*/
abstract getSources(): Promise<ModelSource[]>
/**
* Add a model source
*/
abstract addSource(source: string): Promise<void>
/**
* Delete a model source
*/
abstract deleteSource(source: string): Promise<void>
}
1 change: 1 addition & 0 deletions core/src/types/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './modelEntity'
export * from './modelInterface'
export * from './modelEvent'
export * from './modelImport'
export * from './modelSource'
14 changes: 14 additions & 0 deletions core/src/types/model/modelInterface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Model } from './modelEntity'
import { OptionType } from './modelImport'
import { ModelSource } from './modelSource'

/**
* Model extension for managing models.
Expand Down Expand Up @@ -50,4 +51,17 @@ export interface ModelInterface {
name?: string,
optionType?: OptionType
): Promise<void>

/**
* Get model sources
*/
getSources(): Promise<ModelSource[]>
/**
* Add a model source
*/
addSource(source: string): Promise<void>
/**
* Delete a model source
*/
deleteSource(source: string): Promise<void>
}
67 changes: 67 additions & 0 deletions core/src/types/model/modelSource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* GGUF Metadata of the model source
*/
export interface GGUF {
architecture: string
bos_token: string
chat_template: string
context_length: number
eos_token: string
total: number
}

/**
* Card Metadata of the model source
*/
export interface CardData {
license: string
pipeline_tag: string
}

/**
* Model Metadata of the model source
*/
export interface Metadata {
author: string
cardData: CardData
createdAt: string
description: string
disabled: boolean
downloads: number
gated: boolean
gguf: GGUF
id: string
inference: string
lastModified: string
likes: number
modelId: string
pipeline_tag: string
private: boolean
sha: string
siblings: Array<{
rfilename: string
size: number
}>
spaces: string[]
tags: string[]
usedStorage: number
apiKey?: string
}

/**
* Model source sibling information
*/
export interface ModelSibling {
id: string
size: number
}

/**
* Model source object
*/
export interface ModelSource {
id: string
metadata: Metadata
models: ModelSibling[]
type?: string
}
2 changes: 1 addition & 1 deletion electron/tests/e2e/hub.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('explores hub', async ({ hubPage }) => {
await hubPage.navigateByMenu()
await hubPage.verifyContainerVisible()
await hubPage.scrollToBottom()
const useModelBtn = page.getByTestId(/^use-model-btn-.*/).first()
const useModelBtn = page.getByTestId(/^setup-btn/).first()

await expect(useModelBtn).toBeVisible({
timeout: TIMEOUT,
Expand Down
31 changes: 8 additions & 23 deletions electron/tests/e2e/thread.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
import { expect } from '@playwright/test'
import { page, test, TIMEOUT } from '../config/fixtures'

test('Select GPT model from Hub and Chat with Invalid API Key', async ({
hubPage,
}) => {
await hubPage.navigateByMenu()
await hubPage.verifyContainerVisible()

// Select the first GPT model
await page
.locator('[data-testid^="use-model-btn"][data-testid*="gpt"]')
.first()
.click()

await page.getByTestId('txt-input-chat').fill('dummy value')

test('show onboarding screen without any threads created or models downloaded', async () => {
await page.getByTestId('Thread').first().click({
timeout: TIMEOUT,
})
const denyButton = page.locator('[data-testid="btn-deny-product-analytics"]')

if ((await denyButton.count()) > 0) {
await denyButton.click({ force: true })
} else {
await page.getByTestId('btn-send-chat').click({ force: true })
}

await page.waitForFunction(
() => {
const loaders = document.querySelectorAll('[data-testid$="loader"]')
return !loaders.length
},
{ timeout: TIMEOUT }
)
const onboardScreen = page.getByTestId('onboard-screen')
await expect(onboardScreen).toBeVisible({
timeout: TIMEOUT,
})
})
2 changes: 1 addition & 1 deletion extensions/inference-cortex-extension/bin/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.9-rc4
1.0.9-rc5
Loading
Loading