Automático button in Conectar and model suggestions in Revisión
This commit is contained in:
+113
@@ -979,6 +979,48 @@
|
||||
"title": "Join",
|
||||
"type": "object"
|
||||
},
|
||||
"LanguageModel": {
|
||||
"properties": {
|
||||
"available": {
|
||||
"title": "Available",
|
||||
"type": "boolean"
|
||||
},
|
||||
"model": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Model"
|
||||
},
|
||||
"reason": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Reason"
|
||||
},
|
||||
"vision": {
|
||||
"title": "Vision",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"available",
|
||||
"model",
|
||||
"vision",
|
||||
"reason"
|
||||
],
|
||||
"title": "LanguageModel",
|
||||
"type": "object"
|
||||
},
|
||||
"Link": {
|
||||
"additionalProperties": false,
|
||||
"description": "Identity rows from every input, grouped into persons (Splink).\n\nTwo records are the same person when any rule holds (Splink's SQL rule syntax, `l.`\nand `r.` for the two records); persons are the connected groups. A person whose\nrecords disagree on birth date or sex is held for review as a whole. Pairs Splink\nscores above `review` that ended up apart are queued as possible matches.",
|
||||
@@ -2967,6 +3009,28 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/ingest/llm": {
|
||||
"get": {
|
||||
"description": "The site's language model (LLM_URL): whether it answers, which, and whether it\nreads images. Autom\u00e1tico needs it; extract nodes use their patterns without it.",
|
||||
"operationId": "language_model",
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/LanguageModel"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Successful Response"
|
||||
}
|
||||
},
|
||||
"summary": "Language Model",
|
||||
"tags": [
|
||||
"ingest"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/ingest/pipelines": {
|
||||
"get": {
|
||||
"operationId": "pipelines",
|
||||
@@ -3111,6 +3175,55 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/ingest/pipelines/{pipeline_id}/draft": {
|
||||
"post": {
|
||||
"description": "Autom\u00e1tico: starts the `draft` job, which draws the whole pipeline from its saved\nsources (the only nodes it may hold), saves it as a new version and runs it; follow it\nat /runs/{run_id}.",
|
||||
"operationId": "start_draft",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "pipeline_id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"maxLength": 40,
|
||||
"pattern": "^[a-z][a-z0-9_]*$",
|
||||
"title": "Pipeline Id",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "Response Start Draft",
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Successful Response"
|
||||
},
|
||||
"422": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Validation Error"
|
||||
}
|
||||
},
|
||||
"summary": "Start Draft",
|
||||
"tags": [
|
||||
"ingest"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/ingest/pipelines/{pipeline_id}/nodes/{node_id}/rows": {
|
||||
"get": {
|
||||
"description": "What a node produced in the last run (empty if it produced nothing yet).",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/* eslint-disable */
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { StrictHttpResponse } from '../../strict-http-response';
|
||||
import { RequestBuilder } from '../../request-builder';
|
||||
|
||||
import { LanguageModel } from '../../models/language-model';
|
||||
|
||||
export interface LanguageModel$Params {
|
||||
}
|
||||
|
||||
export function languageModel(http: HttpClient, rootUrl: string, params?: LanguageModel$Params, context?: HttpContext): Observable<StrictHttpResponse<LanguageModel>> {
|
||||
const rb = new RequestBuilder(rootUrl, languageModel.PATH, 'get');
|
||||
if (params) {
|
||||
}
|
||||
|
||||
return http.request(
|
||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<LanguageModel>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
languageModel.PATH = '/ingest/llm';
|
||||
@@ -0,0 +1,35 @@
|
||||
/* eslint-disable */
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { StrictHttpResponse } from '../../strict-http-response';
|
||||
import { RequestBuilder } from '../../request-builder';
|
||||
|
||||
|
||||
export interface StartDraft$Params {
|
||||
pipeline_id: string;
|
||||
}
|
||||
|
||||
export function startDraft(http: HttpClient, rootUrl: string, params: StartDraft$Params, context?: HttpContext): Observable<StrictHttpResponse<{
|
||||
[key: string]: string;
|
||||
}>> {
|
||||
const rb = new RequestBuilder(rootUrl, startDraft.PATH, 'post');
|
||||
if (params) {
|
||||
rb.path('pipeline_id', params.pipeline_id, {});
|
||||
}
|
||||
|
||||
return http.request(
|
||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<{
|
||||
[key: string]: string;
|
||||
}>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
startDraft.PATH = '/ingest/pipelines/{pipeline_id}/draft';
|
||||
@@ -15,12 +15,16 @@ export type { GetConceptMap$Params as GetConceptMap$Params } from './fn/ingest/g
|
||||
export { getConceptMap as getConceptMap } from './fn/ingest/get-concept-map';
|
||||
export type { SaveConceptMap$Params as SaveConceptMap$Params } from './fn/ingest/save-concept-map';
|
||||
export { saveConceptMap as saveConceptMap } from './fn/ingest/save-concept-map';
|
||||
export type { LanguageModel$Params as LanguageModel$Params } from './fn/ingest/language-model';
|
||||
export { languageModel as languageModel } from './fn/ingest/language-model';
|
||||
export type { Pipelines$Params as Pipelines$Params } from './fn/ingest/pipelines';
|
||||
export { pipelines as pipelines } from './fn/ingest/pipelines';
|
||||
export type { Pipeline$Params as Pipeline$Params } from './fn/ingest/pipeline';
|
||||
export { pipeline as pipeline } from './fn/ingest/pipeline';
|
||||
export type { SavePipeline$Params as SavePipeline$Params } from './fn/ingest/save-pipeline';
|
||||
export { savePipeline as savePipeline } from './fn/ingest/save-pipeline';
|
||||
export type { StartDraft$Params as StartDraft$Params } from './fn/ingest/start-draft';
|
||||
export { startDraft as startDraft } from './fn/ingest/start-draft';
|
||||
export type { NodeRows$Params as NodeRows$Params } from './fn/ingest/node-rows';
|
||||
export { nodeRows as nodeRows } from './fn/ingest/node-rows';
|
||||
export type { StartRun$Params as StartRun$Params } from './fn/ingest/start-run';
|
||||
|
||||
@@ -19,6 +19,7 @@ export type { Group } from './models/group';
|
||||
export type { Guided } from './models/guided';
|
||||
export type { HttpValidationError } from './models/http-validation-error';
|
||||
export type { Join } from './models/join';
|
||||
export type { LanguageModel } from './models/language-model';
|
||||
export type { Link } from './models/link';
|
||||
export type { Listing } from './models/listing';
|
||||
export type { Login } from './models/login';
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable */
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
export interface LanguageModel {
|
||||
available: boolean;
|
||||
model: (string | null);
|
||||
reason: (string | null);
|
||||
vision: boolean;
|
||||
}
|
||||
@@ -36,6 +36,24 @@
|
||||
<span class="spacer"></span>
|
||||
<button mat-stroked-button (click)="save()">Guardar</button>
|
||||
<button mat-flat-button (click)="start()" [disabled]="running()">Ejecutar</button>
|
||||
@if (onlySources()) {
|
||||
<span
|
||||
[matTooltip]="
|
||||
llm.value()?.available
|
||||
? 'El modelo de lenguaje del sitio arma toda la canalización a partir de estas fuentes y la ejecuta.'
|
||||
: 'No disponible: ' +
|
||||
(llm.value()?.reason ?? 'no hay modelo de lenguaje configurado')
|
||||
"
|
||||
>
|
||||
<button
|
||||
mat-flat-button
|
||||
(click)="automatic()"
|
||||
[disabled]="running() || !llm.value()?.available"
|
||||
>
|
||||
<mat-icon>auto_awesome</mat-icon>Armar automáticamente
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@if (message()) {
|
||||
|
||||
@@ -23,12 +23,14 @@ import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
|
||||
import { withFormlyMaterial } from '@ngx-formly/material';
|
||||
import { Connection, NodeChange, Vflow } from 'ngx-vflow';
|
||||
import { Api } from '../api/api';
|
||||
import { languageModel } from '../api/fn/ingest/language-model';
|
||||
import { nodeRows } from '../api/fn/ingest/node-rows';
|
||||
import { pipeline as getPipeline } from '../api/fn/ingest/pipeline';
|
||||
import { pipelines } from '../api/fn/ingest/pipelines';
|
||||
import { savePipeline } from '../api/fn/ingest/save-pipeline';
|
||||
import { schema } from '../api/fn/ingest/schema';
|
||||
import { sourcePreview } from '../api/fn/ingest/source-preview';
|
||||
import { startDraft } from '../api/fn/ingest/start-draft';
|
||||
import { startRun } from '../api/fn/ingest/start-run';
|
||||
import { runStatus } from '../api/fn/runs/run-status';
|
||||
import type { Pipeline } from '../api/models/pipeline';
|
||||
@@ -120,6 +122,8 @@ export class Conectar {
|
||||
protected readonly rawError = signal('');
|
||||
|
||||
protected readonly list = resource({ loader: () => this.api.invoke(pipelines) });
|
||||
/** The site's language model: Automático needs it. */
|
||||
protected readonly llm = resource({ loader: () => this.api.invoke(languageModel) });
|
||||
private readonly schema = resource({ loader: () => this.api.invoke(schema) });
|
||||
|
||||
protected readonly pipelineId = signal<string | undefined>(undefined);
|
||||
@@ -136,6 +140,10 @@ export class Conectar {
|
||||
protected readonly doc = computed(() => this.docs().find((d) => d.id === this.selected()));
|
||||
protected readonly message = signal('');
|
||||
protected readonly run = signal<{ id: string; status: string } | undefined>(undefined);
|
||||
/** Automático drafts a pipeline that holds its sources only. */
|
||||
protected readonly onlySources = computed(
|
||||
() => this.docs().length > 0 && this.docs().every((d) => d.kind === 'source'),
|
||||
);
|
||||
protected readonly running = computed(() => {
|
||||
const run = this.run();
|
||||
return !!run && !['SUCCESS', 'FAILURE', 'CANCELED'].includes(run.status);
|
||||
@@ -395,20 +403,44 @@ export class Conectar {
|
||||
const id = this.pipelineId();
|
||||
if (!id || !(await this.save())) return;
|
||||
try {
|
||||
const { run_id } = await this.api.invoke(startRun, { pipeline_id: id, body: {} });
|
||||
this.run.set({ id: run_id, status: 'STARTING' });
|
||||
while (this.running()) {
|
||||
await new Promise((r) => setTimeout(r, 2000));
|
||||
this.run.set({
|
||||
id: run_id,
|
||||
status: (await this.api.invoke(runStatus, { run_id }))['status'],
|
||||
});
|
||||
await this.follow((await this.api.invoke(startRun, { pipeline_id: id, body: {} }))['run_id']);
|
||||
} catch (e) {
|
||||
this.message.set(problem(e));
|
||||
}
|
||||
}
|
||||
|
||||
/** "Armar automáticamente": saves the sources, starts the `draft` job (the site's model
|
||||
* draws the whole pipeline, saves it as a new version and runs it) and, once it ends,
|
||||
* shows the version drawn. */
|
||||
protected async automatic(): Promise<void> {
|
||||
const id = this.pipelineId();
|
||||
if (!id || !(await this.save())) return;
|
||||
try {
|
||||
this.message.set('Armando la canalización: se leen los documentos y el modelo los revisa.');
|
||||
await this.follow((await this.api.invoke(startDraft, { pipeline_id: id }))['run_id']);
|
||||
if (this.run()?.status === 'SUCCESS') {
|
||||
await this.open(id);
|
||||
this.message.set(
|
||||
`Versión ${this.version()} armada y ejecutada. Revise lo que queda en Revisión.`,
|
||||
);
|
||||
this.list.reload();
|
||||
}
|
||||
} catch (e) {
|
||||
this.message.set(problem(e));
|
||||
}
|
||||
}
|
||||
|
||||
private async follow(run_id: string): Promise<void> {
|
||||
this.run.set({ id: run_id, status: 'STARTING' });
|
||||
while (this.running()) {
|
||||
await new Promise((r) => setTimeout(r, 2000));
|
||||
this.run.set({
|
||||
id: run_id,
|
||||
status: (await this.api.invoke(runStatus, { run_id }))['status'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** What the node gives: a source's first rows, or what any other node gave in the last run. */
|
||||
protected async show(): Promise<void> {
|
||||
const doc = this.doc();
|
||||
|
||||
@@ -219,8 +219,20 @@
|
||||
@if (c['probability'] !== null) {
|
||||
· p = {{ $any(c['probability']) | number: '1.2-2' }}
|
||||
}
|
||||
</span></span
|
||||
>
|
||||
</span>
|
||||
@if ($any(c['suggestion']); as s) {
|
||||
<span class="suggestion"
|
||||
>Sugerencia del modelo:
|
||||
{{
|
||||
s.same === true
|
||||
? 'misma paciente'
|
||||
: s.same === false
|
||||
? 'distintas'
|
||||
: 'no se puede saber'
|
||||
}}. {{ s.reason }}</span
|
||||
>
|
||||
}
|
||||
</span>
|
||||
<button
|
||||
mat-stroked-button
|
||||
[disabled]="decided().has(entry['person'] + '|' + c['candidate'])"
|
||||
@@ -245,6 +257,17 @@
|
||||
<h2>Registros que no coinciden en fecha de nacimiento o sexo ({{ p['torn'].length }})</h2>
|
||||
@for (entry of p['torn']; track entry['person']) {
|
||||
<div class="card person">
|
||||
@if ($any(entry['suggestion']); as s) {
|
||||
<p class="suggestion">
|
||||
Sugerencia del modelo:
|
||||
@if (s.record) {
|
||||
el registro <code>{{ text(s.record).slice(0, 10) }}</code> parece de otra persona.
|
||||
} @else {
|
||||
no se puede saber cuál registro es de otra persona.
|
||||
}
|
||||
{{ s.reason }}
|
||||
</p>
|
||||
}
|
||||
@for (r of records(entry); track $index) {
|
||||
<div class="candidate">
|
||||
<span class="values">
|
||||
|
||||
@@ -54,3 +54,10 @@ h2 {
|
||||
white-space: pre-wrap;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.suggestion {
|
||||
display: block;
|
||||
color: var(--mat-sys-tertiary, #4a5d6b);
|
||||
font-size: 0.85rem;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user