Skip to content

Commit

Permalink
remove content type filters in agents (#1911)
Browse files Browse the repository at this point in the history
* remove content type filters in agents

* Do not allow blank in field prefix [sc-11387]

* fix
  • Loading branch information
ebrehault authored Jan 11, 2025
1 parent d4943d1 commit b7aaa60
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 161 deletions.
51 changes: 0 additions & 51 deletions libs/common/common.babel
Original file line number Diff line number Diff line change
Expand Up @@ -34461,57 +34461,6 @@
</concept_node>
</children>
</folder_node>
<folder_node>
<name>resource-type</name>
<children>
<concept_node>
<name>all-types</name>
<description/>
<comment/>
<translations>
<translation>
<language>ca-ES</language>
<approved>false</approved>
</translation>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-ES</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-FR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>button-label</name>
<description/>
<comment/>
<translations>
<translation>
<language>ca-ES</language>
<approved>false</approved>
</translation>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-ES</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-FR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
<folder_node>
<name>search-in</name>
<children>
Expand Down
4 changes: 1 addition & 3 deletions libs/common/src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -1420,8 +1420,6 @@
"tasks-automation.form.filter.fields.all-types": "Tots els tipus de camp",
"tasks-automation.form.filter.fields.button-label": "Tipus de camp",
"tasks-automation.form.filter.resource-labels.button-label": "Etiquetes de recursos",
"tasks-automation.form.filter.resource-type.all-types": "Tots els tipus de recursos",
"tasks-automation.form.filter.resource-type.button-label": "Tipus de Recursos",
"tasks-automation.form.filter.search-in.content": "El contingut conté",
"tasks-automation.form.filter.search-in.title": "El títol conté",
"tasks-automation.form.filter.search-in.title-or-content": "El títol o el contingut conté",
Expand Down Expand Up @@ -1455,7 +1453,7 @@
"tasks-automation.generator.description": "Enriquiu els vostres recursos generant text addicional (com un resum) o metadades associades als recursos escollits.",
"tasks-automation.generator.field-name.description": "Prefixeu l'identificador del nou camp on s'emmagatzemaran les dades generades.",
"tasks-automation.generator.field-name.info": "En cada recurs, es crearà un camp nou amb el contingut generat corresponent a la vostra consulta.",
"tasks-automation.generator.field-name.invalid": "El nom del camp no pot contenir guions",
"tasks-automation.generator.field-name.invalid": "El nom del camp només ha de contenir lletres, xifres i _",
"tasks-automation.generator.field-name.title": "On emmagatzemar el contingut generat?",
"tasks-automation.generator.footer.activate-button-label": "Activa el generador",
"tasks-automation.generator.footer.apply-automation": "Apliqueu la vostra consulta a tots els recursos existents i futurs que coincideixin amb la selecció.",
Expand Down
4 changes: 1 addition & 3 deletions libs/common/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1420,8 +1420,6 @@
"tasks-automation.form.filter.fields.all-types": "All field types",
"tasks-automation.form.filter.fields.button-label": "Field types",
"tasks-automation.form.filter.resource-labels.button-label": "Resource labels",
"tasks-automation.form.filter.resource-type.all-types": "All resource types",
"tasks-automation.form.filter.resource-type.button-label": "Resource types",
"tasks-automation.form.filter.search-in.content": "Content contains",
"tasks-automation.form.filter.search-in.title": "Title contains",
"tasks-automation.form.filter.search-in.title-or-content": "Title or content contains",
Expand Down Expand Up @@ -1455,7 +1453,7 @@
"tasks-automation.generator.description": "Enrich your resources by generating extra text (like a summary) or metadata associated to the chosen resources.",
"tasks-automation.generator.field-name.description": "Prefix the id of the new field where the generated data will be stored.",
"tasks-automation.generator.field-name.info": "In each resource, a new field will be created containing the generated content corresponding to your query.",
"tasks-automation.generator.field-name.invalid": "The field name cannot contain hyphens",
"tasks-automation.generator.field-name.invalid": "The field name must only contain letters, figures and _",
"tasks-automation.generator.field-name.title": "Where to store the generated content?",
"tasks-automation.generator.footer.activate-button-label": "Activate generator",
"tasks-automation.generator.footer.apply-automation": "Apply your query to all existing and future resources matching the selection.",
Expand Down
4 changes: 1 addition & 3 deletions libs/common/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1420,8 +1420,6 @@
"tasks-automation.form.filter.fields.all-types": "Todos los tipos de campos",
"tasks-automation.form.filter.fields.button-label": "Tipos de campos",
"tasks-automation.form.filter.resource-labels.button-label": "Etiquetas de recursos",
"tasks-automation.form.filter.resource-type.all-types": "Todos los tipos de recursos",
"tasks-automation.form.filter.resource-type.button-label": "Tipos de recursos",
"tasks-automation.form.filter.search-in.content": "Contenido",
"tasks-automation.form.filter.search-in.title": "El título contiene",
"tasks-automation.form.filter.search-in.title-or-content": "El título o contenido contiene",
Expand Down Expand Up @@ -1455,7 +1453,7 @@
"tasks-automation.generator.description": "Enriquezca sus recursos generando texto adicional (como un resumen) o metadatos asociados a los recursos elegidos.",
"tasks-automation.generator.field-name.description": "Anteponga el id del nuevo campo donde se almacenarán los datos generados.",
"tasks-automation.generator.field-name.info": "En cada recurso se creará un nuevo campo que contendrá el contenido generado correspondiente a su consulta.",
"tasks-automation.generator.field-name.invalid": "El nombre del campo no puede contener guiones",
"tasks-automation.generator.field-name.invalid": "El nombre del campo solo debe contener letras, cifras y _",
"tasks-automation.generator.field-name.title": "¿Dónde almacenar el contenido generado?",
"tasks-automation.generator.footer.activate-button-label": "Activar generador",
"tasks-automation.generator.footer.apply-automation": "Aplique su consulta a todos los recursos existentes y futuros que coincidan con la selección.",
Expand Down
4 changes: 1 addition & 3 deletions libs/common/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1420,8 +1420,6 @@
"tasks-automation.form.filter.fields.all-types": "Tous types de champs",
"tasks-automation.form.filter.fields.button-label": "Types de champs",
"tasks-automation.form.filter.resource-labels.button-label": "Étiquettes de ressources",
"tasks-automation.form.filter.resource-type.all-types": "Tous les types de ressources",
"tasks-automation.form.filter.resource-type.button-label": "Types de ressources",
"tasks-automation.form.filter.search-in.content": "Le contenu contient",
"tasks-automation.form.filter.search-in.title": "Le titre contient",
"tasks-automation.form.filter.search-in.title-or-content": "Le titre ou le contenu contient",
Expand Down Expand Up @@ -1455,7 +1453,7 @@
"tasks-automation.generator.description": "Enrichissez vos ressources en générant du texte supplémentaire (comme un résumé) ou des métadonnées associées aux ressources choisies.",
"tasks-automation.generator.field-name.description": "Préfixe l'identifiant du nouveau champ où les données générées seront stockées.",
"tasks-automation.generator.field-name.info": "Dans chaque ressource, un nouveau champ sera créé contenant le contenu généré correspondant à votre requête.",
"tasks-automation.generator.field-name.invalid": "Le nom du champ ne peut pas contenir de tirets",
"tasks-automation.generator.field-name.invalid": "Le nom du champ ne doit contenir que des lettres, des chiffres et des _",
"tasks-automation.generator.field-name.title": "Où stocker le contenu généré ?",
"tasks-automation.generator.footer.activate-button-label": "Activer le générateur",
"tasks-automation.generator.footer.apply-automation": "Appliquez votre requête à toutes les ressources existantes et futures correspondant à la sélection.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class AskComponent extends TaskRouteDirective {
question: new FormControl<string>('', { nonNullable: true, validators: [Validators.required] }),
fieldName: new FormControl<string>('', {
nonNullable: true,
validators: [Validators.required, Validators.pattern('[^-]*')],
validators: [Validators.required, Validators.pattern('[0-9a-zA-Z_]+')],
}),
});
override errorMessages = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,47 +45,6 @@
</pa-input>
</div>
}
@if (filters?.['resource_type']) {
<div>
<nsi-dropdown-button
fullWidth
aspect="basic"
[popupRef]="resourceTypesDropdown">
{{ 'tasks-automation.form.filter.resource-type.button-label' | translate }}

@if (resourceTypeSelectionCount > 0) {
({{
resourceTypeSelectionCount === resourceTypeTotalCount
? ('tasks-automation.form.filter.all' | translate)
: resourceTypeSelectionCount
}})
}
</nsi-dropdown-button>

<pa-dropdown #resourceTypesDropdown>
<pa-option
dontCloseOnSelect
(selectOption)="toggleAll('types', $event)">
<pa-checkbox [value]="allResourceTypesSelected">
{{ 'tasks-automation.form.filter.resource-type.all-types' | translate }}
</pa-checkbox>
</pa-option>
<pa-separator></pa-separator>
@for (option of resourceTypeFilters; track option.id) {
<pa-option
[paTooltip]="option.help"
(selectOption)="onSelectFilter(option, $event)"
dontCloseOnSelect>
<pa-checkbox
[(value)]="option.selected"
(valueChange)="onToggleFilter()">
{{ option.label }}
</pa-checkbox>
</pa-option>
}
</pa-dropdown>
</div>
}
<div>
<nsi-dropdown-button
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
TaskTrigger,
} from '@nuclia/core';
import { BehaviorSubject, combineLatest, filter, map, Subject, switchMap, tap } from 'rxjs';
import { Filters, formatFiltersFromFacets, MIME_FACETS } from '../../resources';
import { debounceTime, take, takeUntil } from 'rxjs/operators';
import { TasksAutomationService } from '../tasks-automation.service';
import { removeDeprecatedModels } from '../../ai-models/ai-models.utils';
Expand All @@ -55,7 +54,6 @@ export interface TaskFormCommonConfig {
filter: {
//searchIn: 'titleOrContent' | 'title' | 'content';
contains: string[];
resource_type: string[];
field_types: string[];
};
llm: LLMConfig;
Expand Down Expand Up @@ -141,18 +139,6 @@ export class TaskFormComponent implements OnInit, OnDestroy {

resourceCount?: number;

resourceTypeFilters: OptionModel[] = [];
allResourceTypesSelected = false;
get resourceTypeSelectionCount(): number {
return this.resourceTypeFilters.filter((option) => option.selected).length;
}
get resourceTypeTotalCount(): number {
return this.resourceTypeFilters.length;
}
get selectedResourceTypes() {
return this.resourceTypeFilters.filter((option) => option.selected).map((option) => option.value);
}

fieldTypeFilters: OptionModel[] = [FIELD_TYPE.file, FIELD_TYPE.link, FIELD_TYPE.text, FIELD_TYPE.conversation].map(
(t) => new OptionModel({ id: longToShortFieldType(t), value: longToShortFieldType(t), label: t }),
);
Expand Down Expand Up @@ -227,27 +213,6 @@ export class TaskFormComponent implements OnInit, OnDestroy {
this.form.controls.llm.patchValue({ model: 'chatgpt-azure-4o-mini' });
});

this.sdk.currentKb
.pipe(
switchMap((kb) => kb.catalog('', { faceted: MIME_FACETS })),
map((results) => {
if (results.type === 'error') {
return;
}
const facets: Search.FacetsResult = results.fulltext?.facets || {};
return formatFiltersFromFacets(facets);
}),
filter((filters) => !!filters),
map((filters) => filters as Filters),
)
.subscribe((filters) => {
this.resourceTypeFilters = filters.mainTypes.map((filter) => ({
...filter,
value: filter.value.split('/').slice(2).join('/'),
}));
this.cdr.detectChanges();
});

combineLatest([this.form.valueChanges, this.selectedFilters])
.pipe(
filter(([data]) => data.applyTaskTo === 'EXISTING'),
Expand Down Expand Up @@ -277,11 +242,6 @@ export class TaskFormComponent implements OnInit, OnDestroy {
const tagName = (event.target as HTMLElement).tagName;
if (tagName === 'LI' || tagName === 'INPUT') {
switch (filter) {
case 'types':
this.resourceTypeFilters = this.resourceTypeFilters.map(
(option) => new OptionModel({ ...option, selected: !this.allResourceTypesSelected }),
);
break;
case 'fieldTypes':
this.fieldTypeFilters = this.fieldTypeFilters.map(
(option) => new OptionModel({ ...option, selected: !this.allFieldTypesSelected }),
Expand All @@ -305,9 +265,8 @@ export class TaskFormComponent implements OnInit, OnDestroy {
}

onToggleFilter() {
this.allResourceTypesSelected = this.resourceTypeFilters.every((option) => option.selected);
this.allFieldTypesSelected = this.fieldTypeFilters.every((option) => option.selected);
this.selectedFilters.next(this.selectedResourceTypes.concat(this.selectedFieldTypes).concat(this.labelFilters));
this.selectedFilters.next(this.selectedFieldTypes.concat(this.labelFilters));
}

activateTask() {
Expand All @@ -327,7 +286,6 @@ export class TaskFormComponent implements OnInit, OnDestroy {
: undefined,
filter: {
contains: rawValue.filter.contains ? [rawValue.filter.contains] : [],
resource_type: this.selectedResourceTypes,
field_types: this.selectedFieldTypes,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@
<div>{{ filter.contains?.[0] || '-' }}</div>
</div>
<div class="separator-line"></div>
<div class="setting">
<label>{{ 'tasks-automation.form.filter.resource-type.button-label' | translate }}</label>
<div class="filters">
@if (filter.resource_type?.length) {
@for (type of filter.resource_type; track type) {
<nsi-badge>{{ type }}</nsi-badge>
}
} @else {
<nsi-badge>{{ 'generic.all' | translate }}</nsi-badge>
}
</div>
</div>
@if (fieldTypes.length > 0) {
<div class="separator-line"></div>
<div class="setting">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function mapParameters(parameters: TaskParameters): TaskConfiguration {
title: parameters.name,
filters: [
{ label: 'contains', count: parameters.filter.contains?.length || 0 },
{ label: 'resource_type', count: parameters.filter.resource_type?.length || 0 },
{ label: 'field_types', count: parameters.filter.field_types?.length || 0 },
],
hasPrompt: false, // TODO: extract prompt from parameters
Expand Down

0 comments on commit b7aaa60

Please sign in to comment.