Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit d60a629

Browse files
lumburovskalinaFelixKirschKernJWittmeyer
authored
Model download page (#44)
* Downloaded models page start * Queries and mutations * Model download mutations and queries * Model providers page improvements * Seconds to milliseconds * Model name parameter changed * Model name changes * Changes modelname * Model download page improvements * Sizes changed * changes method and api names * adds status to model provider info query * Typo downaloded fixed * Changed select option bar * Spinner, refetch added * Invalid date fix * Icons for downaloded models added * Console error fix * Green color when the models are downloaded * Align icons and disable add when duplicate is added * Added green color to the downloaded models as part of the kern dropdown component * Comments from PR * Delete model modal and moved the right page to pages * Parce date and combine requests added * Optimized code * applies api changes in the gateway, global notifications * Added button disabled for OS version * Aligned icons * Separator for models, and types with icon instead of column * Added info on hover * Adds config manager error on request before init * PR comments * Update config check * Align elements on project settings * Global changes for the modal center alignment Co-authored-by: felix0496 <felix.kirsch@kern.ai> Co-authored-by: JWittmeyer <jens.wittmeyer@onetask.ai>
1 parent db2d947 commit d60a629

29 files changed

+698
-19
lines changed

src/app/app-routing.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ProjectNewComponent } from './projects/components/project-new/project-n
1616
import { ProjectAddComponent } from './projects/components/project-add/project-add.component';
1717
import { RecordIDEComponent } from './record-ide/components/record-ide.component';
1818
import { ConfigComponent } from './config/components/config.component';
19+
import { ModelDownloadComponent } from './model-download/pages/model-download/model-download.component';
1920

2021
const routes: Routes = [
2122
{
@@ -27,6 +28,7 @@ const routes: Routes = [
2728
{ path: 'notification-center', component: NotificationCenterComponent, data: { name: 'NotificationCenterComponent' } },
2829
{ path: 'projects/new', component: ProjectNewComponent, data: { name: 'ProjectNewComponent' } },
2930
{ path: 'config', component: ConfigComponent, data: { name: 'ConfigComponent' } },
31+
3032
{
3133
path: 'projects/:projectId',
3234
component: ProjectComponent,
@@ -54,6 +56,7 @@ const routes: Routes = [
5456
path: 'knowledge-base/:knowledgeBaseId',
5557
component: KnowledgeBaseDetailsComponent, data: { name: 'KnowledgeBaseDetailsComponent' }
5658
},
59+
{ path: 'model-download', component: ModelDownloadComponent, data: { name: 'ModelDownloadComponent' } },
5760
{ path: '**', component: ProjectOverviewComponent, data: { name: 'ProjectOverviewComponent' } },
5861
//TODO: redirecting to projects overview page and errors
5962
],

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { ConfigModule } from './config/config.module'
2222
import { IntercomModule } from 'ng-intercom';
2323
import { NotificationCenterModule } from './notification-center/notification-center.module';
2424
import { RecordIDEModule } from './record-ide/record-ide.module';
25+
import { ModelDownloadModule } from './model-download/model-download.module';
2526

2627
@NgModule({
2728
declarations: [AppComponent],
@@ -40,6 +41,7 @@ import { RecordIDEModule } from './record-ide/record-ide.module';
4041
ZeroShotModule,
4142
LabelingModule,
4243
RecordIDEModule,
44+
ModelDownloadModule,
4345
NotificationCenterModule,
4446
MonacoEditorModule.forRoot(),
4547
KnowledgeBasesModule,

src/app/base/components/dropdown/dropdown-helper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { FormArray } from "@angular/forms";
2323
* @textHoverColor {string, optional} - text color on hover for the dropdown options
2424
* @textSize {string, optional} - text size for the dropdown options
2525
* @isButtonSampleProjects {boolean, optional} - checks if the button is the specific one for sample project
26+
* @isModelDownloaded {boolean[], optional} - checks if the model is downloaded and if so the color of the text is green
2627
*/
2728
export type DropdownOptions = {
2829
optionArray: string[] | FormArray[] | any[];
@@ -46,5 +47,6 @@ export type DropdownOptions = {
4647
textHoverColor?: string;
4748
textSize?: string;
4849
isButtonSampleProjects?: boolean;
50+
isModelDownloaded: boolean[];
4951
};
5052

src/app/base/components/dropdown/dropdown.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1">
3838
<div class="py-1 cursor-pointer" role="none">
3939
<div *ngFor="let caption of dropdownOptionCaptions;let i = index" (click)="performActionOnOption($event,i)"
40-
[ngClass]="[dropdownOptions.textSize,dropdownOptions.textColor,dropdownOptions.optionDescriptions ? '' : 'flex' ,dropdownOptions.isOptionDisabled?.length && dropdownOptions.isOptionDisabled[i]?'opacity-50 cursor-not-allowed':'',!dropdownOptions.hasCheckboxes ? dropdownOptions.hoverColor + ' ' +dropdownOptions.textHoverColor:'']"
40+
[ngClass]="[dropdownOptions.textSize,dropdownOptions.textColor,dropdownOptions.optionDescriptions ? '' : 'flex' ,dropdownOptions.isOptionDisabled?.length && dropdownOptions.isOptionDisabled[i]?'opacity-50 cursor-not-allowed':'',!dropdownOptions.hasCheckboxes ? dropdownOptions.hoverColor + ' ' +dropdownOptions.textHoverColor:'', dropdownOptions.isModelDownloaded?.length && dropdownOptions.isModelDownloaded[i] ? 'text-green-700 hover:text-lime-300': '']"
4141
[ngStyle]="{'border-bottom': dropdownOptions.isButtonSampleProjects && i%2 == 0 && i!=dropdownOptionCaptions.length-1 ? '1px dashed #e2e8f0' : (dropdownOptions.isButtonSampleProjects && i%2 != 0 && i!=dropdownOptionCaptions.length-1 ? '1px solid #e2e8f0' : null) }"
4242
class="block px-2 py-1.5 flex-row flex-nowrap items-center gap-x-2 w-max min-w-full"
4343
role="menuitem" tabindex="-1" id="menu-item-0">

src/app/base/components/dropdown/dropdown.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export class DropdownComponent implements OnChanges {
7979
if (this.dropdownOptions.optionDescriptions && this.dropdownOptions.optionArray.length != this.dropdownOptions.optionDescriptions.length) this.hasInputErrors = "array options != optionDescriptions length\n";
8080
if (this.dropdownOptions.optionIcons && this.dropdownOptions.optionIcons.length != this.dropdownOptions.optionIcons.length) this.hasInputErrors = "array options != optionIcons length\n";
8181
if (!this.dropdownOptions.buttonVersion) this.dropdownOptions.buttonVersion = "default";
82+
if (this.dropdownOptions.isModelDownloaded && this.dropdownOptions.isModelDownloaded.length != this.dropdownOptions.optionArray.length) this.hasInputErrors = "array options != isModelDownloaded length\n";
8283

8384
this.buttonClassList = "";
8485
if (!this.dropdownOptions.buttonBgColor) this.dropdownOptions.buttonBgColor = "bg-white ";

src/app/base/services/base/apollo-checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export class ApolloChecker {
2929
}
3030

3131
private static checkBlackWhiteList(type: string, queryText: string) {
32-
if (!ConfigManager.getIsDemo()) return;
33-
if (ConfigManager.getIsAdmin()) return;
32+
if (!ConfigManager.getIsDemo(true)) return;
33+
if (ConfigManager.getIsAdmin(true)) return;
3434
if (!queryText) throw new Error("Can't find query text");
3535
if (!ConfigManager.checkBlackWhiteList(type, queryText)) throw new DemoError(type, queryText);
3636
}

src/app/base/services/config-service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export class ConfigManager {
6868
return ConfigManager.config[key][subkey]
6969
}
7070

71-
public static getIsManaged(): boolean {
71+
public static getIsManaged(ignoreCheck: boolean = false): boolean {
72+
if (!ignoreCheck && !ConfigManager.isInit()) console.log("ConfigManager not initialized");
7273
return ConfigManager.isManaged;
7374
}
7475

@@ -86,14 +87,16 @@ export class ConfigManager {
8687
public static setIsAdmin(value: boolean) {
8788
ConfigManager.isAdmin = value;
8889
}
89-
public static getIsAdmin() {
90+
public static getIsAdmin(ignoreCheck: boolean = false): boolean {
91+
if (!ignoreCheck && !ConfigManager.isInit()) console.log("ConfigManager not initialized");
9092
return ConfigManager.isAdmin;
9193
}
9294

9395
public static setIsDemo(value: boolean) {
9496
ConfigManager.isDemo = value;
9597
}
96-
public static getIsDemo() {
98+
public static getIsDemo(ignoreCheck: boolean = false): boolean {
99+
if (!ignoreCheck && !ConfigManager.isInit()) console.log("ConfigManager not initialized");
97100
return ConfigManager.isDemo;
98101
}
99102

src/app/base/services/weak-source/weak-source-apollo.service.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,40 @@ export class WeakSourceApolloService {
428428
});
429429
}
430430

431+
getModelProviderInfo() {
432+
const query = this.apollo
433+
.watchQuery({
434+
query: queries.GET_MODEL_PROVIDER_INFO,
435+
fetchPolicy: 'network-only', // Used for first execution
436+
nextFetchPolicy: 'cache-first', // Used for subsequent executions (refetch query updates the cache != triggers the function)
437+
});
438+
const vc = query.valueChanges.pipe(
439+
map((result) => result['data']['modelProviderInfo'])
440+
);
441+
return [query, vc]
442+
}
443+
444+
downloadModel(name: string) {
445+
return this.apollo.mutate({
446+
mutation: mutations.MODEL_PROVIDER_DOWNLOAD_MODEL,
447+
variables: {
448+
modelName: name
449+
}
450+
});
451+
}
452+
453+
deleteModel(name: string) {
454+
return this.apollo.mutate({
455+
mutation: mutations.MODEL_PROVIDER_DELETE_MODEL,
456+
variables: {
457+
modelName: name
458+
},
459+
refetchQueries: [
460+
{
461+
query: queries.GET_MODEL_PROVIDER_INFO
462+
},
463+
],
464+
});
465+
}
466+
431467
}

src/app/base/services/weak-source/weak-source-mutations.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,21 @@ export const mutations = {
9898
}
9999
}
100100
101-
`
101+
`,
102+
103+
MODEL_PROVIDER_DELETE_MODEL: gql`
104+
mutation($modelName: String!) {
105+
modelProviderDeleteModel(modelName: $modelName) {
106+
ok
107+
}
108+
}
109+
`,
110+
111+
MODEL_PROVIDER_DOWNLOAD_MODEL: gql`
112+
mutation($modelName: String!) {
113+
modelProviderDownloadModel(modelName: $modelName) {
114+
ok
115+
}
116+
}
117+
`,
102118
};

src/app/base/services/weak-source/weak-source-queries.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,17 @@ export const queries = {
9898
}
9999
`,
100100

101+
GET_MODEL_PROVIDER_INFO: gql`
102+
query{
103+
modelProviderInfo {
104+
name
105+
revision
106+
link
107+
date
108+
size
109+
status
110+
zeroShotPipeline
111+
}
112+
}
113+
`,
101114
};

0 commit comments

Comments
 (0)