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

Commit 44aae35

Browse files
authored
adds simple first views on model callbacks (#51)
* adds simple first views on model callbacks * adds view on model callbacks * rename * filter for model callbacks * adds filter and sort on model callbacks * implements suggestions
1 parent c0a4aa8 commit 44aae35

22 files changed

+16232
-193
lines changed

package-lock.json

Lines changed: 15405 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"d3v4": "^4.2.2",
3838
"daisyui": "^1.14.2",
3939
"graphql": "^15.0.0",
40+
"i": "^0.3.7",
4041
"monaco-editor": "^0.24.0",
4142
"ng-intercom": "^8.0.2",
4243
"ngx-filesize": "^2.0.16",

src/app/app-routing.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ProjectAddComponent } from './projects/components/project-add/project-a
1717
import { RecordIDEComponent } from './record-ide/components/record-ide.component';
1818
import { ConfigComponent } from './config/components/config.component';
1919
import { ModelDownloadComponent } from './model-download/pages/model-download/model-download.component';
20+
import { ModelCallbackComponent } from './model-callbacks/components/model-callbacks.component';
2021

2122
const routes: Routes = [
2223
{
@@ -28,7 +29,7 @@ const routes: Routes = [
2829
{ path: 'notification-center', component: NotificationCenterComponent, data: { name: 'NotificationCenterComponent' } },
2930
{ path: 'projects/new', component: ProjectNewComponent, data: { name: 'ProjectNewComponent' } },
3031
{ path: 'config', component: ConfigComponent, data: { name: 'ConfigComponent' } },
31-
32+
3233
{
3334
path: 'projects/:projectId',
3435
component: ProjectComponent,
@@ -56,6 +57,7 @@ const routes: Routes = [
5657
path: 'knowledge-base/:knowledgeBaseId',
5758
component: KnowledgeBaseDetailsComponent, data: { name: 'KnowledgeBaseDetailsComponent' }
5859
},
60+
{ path: 'model-callbacks', component: ModelCallbackComponent, data: { name: 'ModelCallbackComponent' } },
5961
{ path: 'model-download', component: ModelDownloadComponent, data: { name: 'ModelDownloadComponent' } },
6062
{ path: '**', component: ProjectOverviewComponent, data: { name: 'ProjectOverviewComponent' } },
6163
//TODO: redirecting to projects overview page and errors

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IntercomModule } from 'ng-intercom';
2323
import { NotificationCenterModule } from './notification-center/notification-center.module';
2424
import { RecordIDEModule } from './record-ide/record-ide.module';
2525
import { ModelDownloadModule } from './model-download/model-download.module';
26+
import { ModelCallbackModule } from './model-callbacks/model-callbacks.module';
2627

2728
@NgModule({
2829
declarations: [AppComponent],
@@ -41,6 +42,7 @@ import { ModelDownloadModule } from './model-download/model-download.module';
4142
ZeroShotModule,
4243
LabelingModule,
4344
RecordIDEModule,
45+
ModelCallbackModule,
4446
ModelDownloadModule,
4547
NotificationCenterModule,
4648
MonacoEditorModule.forRoot(),

src/app/base/components/sidebar-pm/sidebar-pm.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,30 @@ export class SidebarPmComponent implements OnInit {
101101
})
102102
)
103103
.subscribe());
104-
105-
if(!SidebarPmComponent.initialConfigRequest) {
104+
105+
if (!SidebarPmComponent.initialConfigRequest) {
106106
this.requestVersionOverview();
107107
SidebarPmComponent.initialConfigRequest = true;
108108
}
109109
this.checkIfManagedVersion();
110110
}
111111

112112
requestVersionOverview() {
113-
this.versionOverview = null;
113+
this.versionOverview = null;
114114
this.configService
115-
.getVersionOverview()
116-
.pipe(first())
117-
.subscribe((versionOverview) => {
118-
this.versionOverview = versionOverview;
119-
this.versionOverview.forEach((version)=> {
120-
version.parseDate = this.parseUTC(version.lastChecked);
115+
.getVersionOverview()
116+
.pipe(first())
117+
.subscribe((versionOverview) => {
118+
this.versionOverview = versionOverview;
119+
this.versionOverview.forEach((version) => {
120+
version.parseDate = this.parseUTC(version.lastChecked);
121+
});
122+
this.versionOverview.sort((a, b) => a.service.localeCompare(b.service));
123+
this.configService
124+
.hasUpdates()
125+
.pipe(first())
126+
.subscribe((hasUpdates) => this.hasUpdates = hasUpdates);
121127
});
122-
this.versionOverview.sort((a, b) => a.service.localeCompare(b.service));
123-
this.configService
124-
.hasUpdates()
125-
.pipe(first())
126-
.subscribe((hasUpdates) => this.hasUpdates = hasUpdates);
127-
});
128128
}
129129

130130
onDestroy() {
@@ -187,11 +187,11 @@ export class SidebarPmComponent implements OnInit {
187187
@HostListener('document:mozfullscreenchange', ['$event'])
188188
@HostListener('document:MSFullscreenChange', ['$event'])
189189
onEscapeClick() {
190-
if(this.toggleClass == 'ft-minimize'){
190+
if (this.toggleClass == 'ft-minimize') {
191191
this.toggleClass = 'ft-maximize';
192192
this.isFullscreen = false;
193193
}
194-
else{
194+
else {
195195
this.toggleClass = 'ft-minimize';
196196
this.isFullscreen = true;
197197

src/app/base/enum/graphql-enums.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
export enum LabelSource {
22
MANUAL = "MANUAL",
33
WEAK_SUPERVISION = "WEAK_SUPERVISION",
4-
INFORMATION_SOURCE = "INFORMATION_SOURCE"
4+
INFORMATION_SOURCE = "INFORMATION_SOURCE",
5+
MODEL_CALLBACK = "MODEL_CALLBACK",
56
}
67
export function labelSourceToString(source: LabelSource, forDisplay: boolean = true) {
78
if (forDisplay) {
89
switch (source) {
910
case LabelSource.MANUAL: return "Manual";
1011
case LabelSource.WEAK_SUPERVISION: return "Weak Supervision";
12+
case LabelSource.MODEL_CALLBACK: return "Model Callback";
1113
case LabelSource.INFORMATION_SOURCE: return "Information Source";
1214
default: return source;
1315
}

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,30 @@ export class WeakSourceApolloService {
181181
return [query, vc];
182182
}
183183

184+
getModelCallbacksOverviewData(projectId: string) {
185+
const query = this.apollo
186+
.watchQuery({
187+
query: queries.GET_MODEL_CALLBACKS_OVERVIEW_DATA,
188+
variables: {
189+
projectId: projectId,
190+
},
191+
fetchPolicy: 'cache-and-network'
192+
});
193+
const vc = query.valueChanges.pipe(
194+
map((result) => {
195+
let tmp = result['data']['modelCallbacksOverviewData'];
196+
if (!tmp) return [];
197+
return JSON.parse(tmp).map((source) => {
198+
source.labelSource = LabelSource.INFORMATION_SOURCE;
199+
source.stats = this.mapInformationSourceStatsGlobal(source.stat_data);
200+
return source;
201+
});
202+
})
203+
204+
);
205+
return [query, vc];
206+
}
207+
184208
private mapInformationSourceStatsGlobal(data) {
185209
if (data?.length) {
186210
return data.map((wrapper) => {
@@ -428,6 +452,16 @@ export class WeakSourceApolloService {
428452
});
429453
}
430454

455+
setAllModelCallbacks(projectId: string, value: boolean) {
456+
return this.apollo.mutate({
457+
mutation: mutations.SET_ALL_MODEL_CALLBACKS,
458+
variables: {
459+
projectId: projectId,
460+
value: value
461+
},
462+
});
463+
}
464+
431465
getModelProviderInfo() {
432466
const query = this.apollo
433467
.watchQuery({

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ export const mutations = {
100100
101101
`,
102102

103+
SET_ALL_MODEL_CALLBACKS: gql`
104+
mutation ($projectId: ID!, $value: Boolean!) {
105+
setAllModelCallbacksSelected(projectId: $projectId, value: $value) {
106+
ok
107+
}
108+
}
109+
110+
`,
111+
103112
MODEL_PROVIDER_DELETE_MODEL: gql`
104113
mutation($modelName: String!) {
105114
modelProviderDeleteModel(modelName: $modelName) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export const queries = {
77
}
88
`,
99

10+
GET_MODEL_CALLBACKS_OVERVIEW_DATA: gql`
11+
query($projectId:ID!){
12+
modelCallbacksOverviewData(projectId:$projectId)
13+
}
14+
`,
15+
1016
GET_INFORMATION_SOURCE_BY_SOURCE_ID: gql`
1117
query ($projectId: ID!, $informationSourceId: ID!) {
1218
informationSourceBySourceId(projectId: $projectId, informationSourceId: $informationSourceId) {

src/app/data/components/data-browser/data-browser.component.html

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -347,44 +347,86 @@
347347
</ng-template>
348348
</div>
349349
</div>
350-
<div class="mt-2">Weakly supervised</div>
351-
<div class="flex-grow min-w-0">
352-
<div class="dropdown">
353-
<ng-template
354-
[ngIf]="groupItem.get('weakSupervisionLabels').controls.length == 0"
355-
formArrayName="manualLabels"
356-
[ngIfElse]="dropDownWS">
357-
<ng-container
358-
[ngTemplateOutlet]="buttonLabelsDisabled">
359-
</ng-container>
360-
</ng-template>
361-
<ng-template #dropDownWS>
362-
<kern-dropdown [dropdownOptions]="{
350+
<div>
351+
<div class="mt-2">Weakly supervised</div>
352+
<div class="flex-grow min-w-0">
353+
<div class="dropdown">
354+
<ng-template
355+
[ngIf]="groupItem.get('weakSupervisionLabels').controls.length == 0"
356+
formArrayName="manualLabels"
357+
[ngIfElse]="dropDownWS">
358+
<ng-container
359+
[ngTemplateOutlet]="buttonLabelsDisabled">
360+
</ng-container>
361+
</ng-template>
362+
<ng-template #dropDownWS>
363+
<kern-dropdown [dropdownOptions]="{
363364
optionArray:groupItem.get('weakSupervisionLabels').controls,
364365
hasCheckboxes:true,
365366
keepDropdownOpen:true
366-
}"
367-
(optionClicked)="setActiveNegateGroup($event)">
368-
</kern-dropdown>
369-
</ng-template>
367+
}" (optionClicked)="setActiveNegateGroup($event)">
368+
</kern-dropdown>
369+
</ng-template>
370+
</div>
371+
</div>
372+
<div class="flex-grow min-w-0 mt-1">
373+
<div class="flex flex-row items-center"
374+
[formGroup]="groupItem.get('weakSupervisionConfidence')">
375+
<span
376+
class="label-text mr-1 font-dmMono">CONFIDENCE
377+
BETWEEN</span><input
378+
formControlName="lower" type="number"
379+
class="w-12 px-2 input input-sm input-bordered"
380+
(blur)="ensureValidConfidence(groupItem.get('weakSupervisionConfidence'))">
381+
<span class="label-text mx-1 font-dmMono">%
382+
AND</span>
383+
<input formControlName="upper" type="number"
384+
class="w-12 input input-sm input-bordered px-2"
385+
(blur)="ensureValidConfidence(groupItem.get('weakSupervisionConfidence'))">
386+
<span
387+
class="label-text mx-1 font-dmMono">%</span>
388+
</div>
370389
</div>
371390
</div>
372-
<div class="flex-grow min-w-0 mt-1">
373-
<div class="flex flex-row items-center"
374-
[formGroup]="groupItem.get('confidence')">
375-
<span
376-
class="label-text mr-1 font-dmMono">CONFIDENCE
377-
BETWEEN</span><input formControlName="lower"
378-
type="number"
379-
class="w-12 px-2 input input-sm input-bordered"
380-
(blur)="ensureValidConfidence(groupItem.get('confidence'))">
381-
<span class="label-text mx-1 font-dmMono">%
382-
AND</span>
383-
<input formControlName="upper" type="number"
384-
class="w-12 input input-sm input-bordered px-2"
385-
(blur)="ensureValidConfidence(groupItem.get('confidence'))">
386-
<span
387-
class="label-text mx-1 font-dmMono">%</span>
391+
<div>
392+
<div class="mt-2">Model callback</div>
393+
<div class="flex-grow min-w-0">
394+
<div class="dropdown">
395+
<ng-template
396+
[ngIf]="groupItem.get('modelCallbackLabels').controls.length == 0"
397+
formArrayName="manualLabels"
398+
[ngIfElse]="dropDownMC">
399+
<ng-container
400+
[ngTemplateOutlet]="buttonLabelsDisabled">
401+
</ng-container>
402+
</ng-template>
403+
<ng-template #dropDownMC>
404+
<kern-dropdown [dropdownOptions]="{
405+
optionArray:groupItem.get('modelCallbackLabels').controls,
406+
hasCheckboxes:true,
407+
keepDropdownOpen:true
408+
}" (optionClicked)="setActiveNegateGroup($event)">
409+
</kern-dropdown>
410+
</ng-template>
411+
</div>
412+
</div>
413+
<div class="flex-grow min-w-0 mt-1">
414+
<div class="flex flex-row items-center"
415+
[formGroup]="groupItem.get('modelCallbackConfidence')">
416+
<span
417+
class="label-text mr-1 font-dmMono">CONFIDENCE
418+
BETWEEN</span><input
419+
formControlName="lower" type="number"
420+
class="w-12 px-2 input input-sm input-bordered"
421+
(blur)="ensureValidConfidence(groupItem.get('modelCallbackConfidence'))">
422+
<span class="label-text mx-1 font-dmMono">%
423+
AND</span>
424+
<input formControlName="upper" type="number"
425+
class="w-12 input input-sm input-bordered px-2"
426+
(blur)="ensureValidConfidence(groupItem.get('modelCallbackConfidence'))">
427+
<span
428+
class="label-text mx-1 font-dmMono">%</span>
429+
</div>
388430
</div>
389431
</div>
390432
<div class="mt-2 font-bold">Heuristics

0 commit comments

Comments
 (0)