@fluxhub/fluxhub-lib 19.0.182 → 19.0.184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/fluxhub-fluxhub-lib.mjs +826 -1
- package/fesm2022/fluxhub-fluxhub-lib.mjs.map +1 -1
- package/lib/ai-components/fh-ai-assistant/fh-ai-assistant.component.d.ts +48 -0
- package/lib/ai-components/fh-ai-chat/fh-ai-chat.component.d.ts +77 -0
- package/lib/ai-components/fh-ai.service.d.ts +47 -0
- package/lib/ai-components/models/fh-ai.models.d.ts +67 -0
- package/package.json +30 -5
- package/public-api.d.ts +4 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { OnInit } from "@angular/core";
|
|
2
|
+
import { FHAiContext } from "../models/fh-ai.models";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Launcher AI flottante ("drop-anywhere") di FluxHub: un FAB in basso a destra che
|
|
6
|
+
* apre/chiude un pannello con dentro <FHAiChat>. Si inserisce in qualunque pagina
|
|
7
|
+
* del portale per dare accesso all'assistente senza occupare layout.
|
|
8
|
+
*
|
|
9
|
+
* Inoltra al chat gli @Input principali (endpoint, contesto, tema, testi).
|
|
10
|
+
*
|
|
11
|
+
* Esempio:
|
|
12
|
+
* <FHAiAssistant [context]="{azienda:'COEM', ruolo:'manager'}"
|
|
13
|
+
* [accent]="'#16afc7'"
|
|
14
|
+
* welcomeTitle="Assistente COEM"></FHAiAssistant>
|
|
15
|
+
*/
|
|
16
|
+
export declare class FHAiAssistantComponent implements OnInit {
|
|
17
|
+
accent: string;
|
|
18
|
+
accentDark: string;
|
|
19
|
+
get _a(): string;
|
|
20
|
+
get _ad(): string;
|
|
21
|
+
icon: string;
|
|
22
|
+
openLabel: string;
|
|
23
|
+
showLabel: boolean;
|
|
24
|
+
/** 'floating' = popover ancorato al FAB; 'right' = drawer a tutta altezza. */
|
|
25
|
+
dock: "floating" | "right";
|
|
26
|
+
/** Apre il pannello all'avvio. */
|
|
27
|
+
startOpen: boolean;
|
|
28
|
+
title: string;
|
|
29
|
+
subtitle: string;
|
|
30
|
+
tagLabel: string;
|
|
31
|
+
welcomeTitle: string;
|
|
32
|
+
welcomeSubtitle: string;
|
|
33
|
+
suggestions: string[];
|
|
34
|
+
placeholder: string;
|
|
35
|
+
endpoint: string;
|
|
36
|
+
path: string;
|
|
37
|
+
model: string;
|
|
38
|
+
stream: boolean;
|
|
39
|
+
apiKey: string;
|
|
40
|
+
forwardAuth: boolean;
|
|
41
|
+
context: FHAiContext | null;
|
|
42
|
+
systemPrompt: string;
|
|
43
|
+
open: boolean;
|
|
44
|
+
ngOnInit(): void;
|
|
45
|
+
toggle(): void;
|
|
46
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FHAiAssistantComponent, never>;
|
|
47
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FHAiAssistantComponent, "FHAiAssistant", never, { "accent": { "alias": "accent"; "required": false; }; "accentDark": { "alias": "accentDark"; "required": false; }; "icon": { "alias": "icon"; "required": false; }; "openLabel": { "alias": "openLabel"; "required": false; }; "showLabel": { "alias": "showLabel"; "required": false; }; "dock": { "alias": "dock"; "required": false; }; "startOpen": { "alias": "startOpen"; "required": false; }; "title": { "alias": "title"; "required": false; }; "subtitle": { "alias": "subtitle"; "required": false; }; "tagLabel": { "alias": "tagLabel"; "required": false; }; "welcomeTitle": { "alias": "welcomeTitle"; "required": false; }; "welcomeSubtitle": { "alias": "welcomeSubtitle"; "required": false; }; "suggestions": { "alias": "suggestions"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "endpoint": { "alias": "endpoint"; "required": false; }; "path": { "alias": "path"; "required": false; }; "model": { "alias": "model"; "required": false; }; "stream": { "alias": "stream"; "required": false; }; "apiKey": { "alias": "apiKey"; "required": false; }; "forwardAuth": { "alias": "forwardAuth"; "required": false; }; "context": { "alias": "context"; "required": false; }; "systemPrompt": { "alias": "systemPrompt"; "required": false; }; }, {}, never, never, true, never>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ElementRef, EventEmitter, OnDestroy } from "@angular/core";
|
|
2
|
+
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
|
|
3
|
+
import { FHAiService } from "../fh-ai.service";
|
|
4
|
+
import { FHAiContext, FHAiMessage } from "../models/fh-ai.models";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Pannello chat AI riusabile di FluxHub.
|
|
8
|
+
*
|
|
9
|
+
* Conversazione con un backend OpenAI-compatible (proxy Prologika -> Cheshire Cat ->
|
|
10
|
+
* Gemma) via FHAiService. Renderizza testo markdown, citazioni RAG, ha schermata di
|
|
11
|
+
* benvenuto con suggerimenti e supporta streaming token-by-token.
|
|
12
|
+
*
|
|
13
|
+
* Tutto configurabile via @Input (endpoint, contesto azienda/ruolo, testi, tema) per
|
|
14
|
+
* riuso cross-cliente, in linea con gli altri componenti standard della libreria.
|
|
15
|
+
*
|
|
16
|
+
* Esempio:
|
|
17
|
+
* <FHAiChat [context]="{azienda:'Bormioli', ruolo:'sales'}"
|
|
18
|
+
* [accent]="'#16afc7'"
|
|
19
|
+
* welcomeTitle="Assistente Bormioli"></FHAiChat>
|
|
20
|
+
*/
|
|
21
|
+
export declare class FHAiChatComponent implements OnDestroy {
|
|
22
|
+
private ai;
|
|
23
|
+
private sanitizer;
|
|
24
|
+
accent: string;
|
|
25
|
+
accentDark: string;
|
|
26
|
+
get _a(): string;
|
|
27
|
+
get _ad(): string;
|
|
28
|
+
showHeader: boolean;
|
|
29
|
+
title: string;
|
|
30
|
+
subtitle: string;
|
|
31
|
+
tagLabel: string;
|
|
32
|
+
welcomeTitle: string;
|
|
33
|
+
welcomeSubtitle: string;
|
|
34
|
+
suggestions: string[];
|
|
35
|
+
placeholder: string;
|
|
36
|
+
showHint: boolean;
|
|
37
|
+
/** URL completo dell'endpoint AI. Se vuoto: AppService.API_ENDPOINT + path. */
|
|
38
|
+
endpoint: string;
|
|
39
|
+
/** Path relativo all'API_ENDPOINT (default route AI sul backend FluxHub). */
|
|
40
|
+
path: string;
|
|
41
|
+
/** Modello da richiedere (di norma deciso lato server). */
|
|
42
|
+
model: string;
|
|
43
|
+
/** Abilita lo streaming token-by-token (SSE). */
|
|
44
|
+
stream: boolean;
|
|
45
|
+
/** API key del servizio AI (di norma NON serve lato browser). */
|
|
46
|
+
apiKey: string;
|
|
47
|
+
/** Inoltra il JWT FluxHub come Authorization Bearer. */
|
|
48
|
+
forwardAuth: boolean;
|
|
49
|
+
/** Contesto di scoping {azienda, ruolo, persona} (informativo + metadata). */
|
|
50
|
+
context: FHAiContext | null;
|
|
51
|
+
/** Messaggio di sistema iniziale opzionale (di norma lo costruisce il backend). */
|
|
52
|
+
systemPrompt: string;
|
|
53
|
+
messageSent: EventEmitter<string>;
|
|
54
|
+
responseReceived: EventEmitter<FHAiMessage>;
|
|
55
|
+
errored: EventEmitter<string>;
|
|
56
|
+
scroller?: ElementRef<HTMLDivElement>;
|
|
57
|
+
messages: FHAiMessage[];
|
|
58
|
+
userInput: string;
|
|
59
|
+
busy: boolean;
|
|
60
|
+
errorMsg: string;
|
|
61
|
+
private sub?;
|
|
62
|
+
constructor(ai: FHAiService, sanitizer: DomSanitizer);
|
|
63
|
+
ngOnDestroy(): void;
|
|
64
|
+
onKeyDown(ev: KeyboardEvent): void;
|
|
65
|
+
autoGrow(ta: HTMLTextAreaElement): void;
|
|
66
|
+
sendSuggestion(text: string): void;
|
|
67
|
+
send(): void;
|
|
68
|
+
stop(): void;
|
|
69
|
+
clear(): void;
|
|
70
|
+
private finish;
|
|
71
|
+
private fail;
|
|
72
|
+
private scrollSoon;
|
|
73
|
+
/** Rende il markdown (sottoinsieme) in HTML sicuro: escape -> formattazione. */
|
|
74
|
+
render(content: string): SafeHtml;
|
|
75
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FHAiChatComponent, never>;
|
|
76
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FHAiChatComponent, "FHAiChat", never, { "accent": { "alias": "accent"; "required": false; }; "accentDark": { "alias": "accentDark"; "required": false; }; "showHeader": { "alias": "showHeader"; "required": false; }; "title": { "alias": "title"; "required": false; }; "subtitle": { "alias": "subtitle"; "required": false; }; "tagLabel": { "alias": "tagLabel"; "required": false; }; "welcomeTitle": { "alias": "welcomeTitle"; "required": false; }; "welcomeSubtitle": { "alias": "welcomeSubtitle"; "required": false; }; "suggestions": { "alias": "suggestions"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "showHint": { "alias": "showHint"; "required": false; }; "endpoint": { "alias": "endpoint"; "required": false; }; "path": { "alias": "path"; "required": false; }; "model": { "alias": "model"; "required": false; }; "stream": { "alias": "stream"; "required": false; }; "apiKey": { "alias": "apiKey"; "required": false; }; "forwardAuth": { "alias": "forwardAuth"; "required": false; }; "context": { "alias": "context"; "required": false; }; "systemPrompt": { "alias": "systemPrompt"; "required": false; }; }, { "messageSent": "messageSent"; "responseReceived": "responseReceived"; "errored": "errored"; }, never, never, true, never>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { AppService } from "../services/app.service";
|
|
3
|
+
import { FHAiChunk, FHAiMessage, FHAiRequestOptions, FHAiSource } from "./models/fh-ai.models";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Client del layer AI di FluxHub.
|
|
7
|
+
*
|
|
8
|
+
* Parla con un backend OpenAI-compatible (/v1/chat/completions o una route FluxHub
|
|
9
|
+
* che fa da proxy verso il Cheshire Cat / Gemma). Supporta streaming SSE e risposta
|
|
10
|
+
* singola. L'identita' utente viene inoltrata col JWT FluxHub: scoping e retrieval
|
|
11
|
+
* sono enforced server-side (vedi architettura, sez. 10-11).
|
|
12
|
+
*
|
|
13
|
+
* Usa fetch() invece di HttpClient per gestire nativamente lo streaming SSE e per
|
|
14
|
+
* avere pieno controllo sugli header (la chiamata AI puo' usare una chiave dedicata).
|
|
15
|
+
*/
|
|
16
|
+
export declare class FHAiService {
|
|
17
|
+
private appService;
|
|
18
|
+
/** Path di default (relativo ad API_ENDPOINT) della route AI sul backend FluxHub. */
|
|
19
|
+
defaultPath: string;
|
|
20
|
+
constructor(appService: AppService);
|
|
21
|
+
/** Costruisce l'URL effettivo dell'endpoint. */
|
|
22
|
+
private resolveUrl;
|
|
23
|
+
/** Costruisce gli header (Content-Type, JWT FluxHub, API key AI, custom). */
|
|
24
|
+
private buildHeaders;
|
|
25
|
+
/** Corpo della richiesta (OpenAI-compatible). */
|
|
26
|
+
private buildBody;
|
|
27
|
+
/**
|
|
28
|
+
* Conversazione in streaming. Emette un FHAiChunk per ogni delta di testo;
|
|
29
|
+
* l'ultimo ha done=true ed eventuali sources.
|
|
30
|
+
*/
|
|
31
|
+
chatStream(messages: FHAiMessage[], opts?: FHAiRequestOptions): Observable<FHAiChunk>;
|
|
32
|
+
/**
|
|
33
|
+
* Conversazione non-streaming: risolve con il testo completo e le sorgenti.
|
|
34
|
+
*/
|
|
35
|
+
chatOnce(messages: FHAiMessage[], opts?: FHAiRequestOptions): Observable<{
|
|
36
|
+
content: string;
|
|
37
|
+
sources?: FHAiSource[];
|
|
38
|
+
}>;
|
|
39
|
+
/** Estrae il delta di testo da un evento SSE (OpenAI: choices[].delta.content). */
|
|
40
|
+
private extractDelta;
|
|
41
|
+
/** Estrae il testo completo dalla risposta non-streaming. */
|
|
42
|
+
private extractContent;
|
|
43
|
+
/** Estrae le sorgenti RAG (Cheshire Cat: why.memory.declarative; o sources/citations). */
|
|
44
|
+
private extractSources;
|
|
45
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FHAiService, never>;
|
|
46
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<FHAiService>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** Ruolo di un messaggio nella conversazione (formato OpenAI-compatible). */
|
|
2
|
+
export type FHAiRole = "user" | "assistant" | "system";
|
|
3
|
+
/** Sorgente RAG citata dal modello (chunk recuperato da Qdrant via Cheshire Cat). */
|
|
4
|
+
export interface FHAiSource {
|
|
5
|
+
/** Titolo/nome documento o riferimento mostrabile. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Estratto del chunk (snippet). */
|
|
8
|
+
snippet?: string;
|
|
9
|
+
/** Punteggio di similarita' (0..1) se fornito dal backend. */
|
|
10
|
+
score?: number;
|
|
11
|
+
/** Eventuale URL/percorso del documento sorgente. */
|
|
12
|
+
url?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Singolo messaggio della conversazione. */
|
|
15
|
+
export interface FHAiMessage {
|
|
16
|
+
role: FHAiRole;
|
|
17
|
+
content: string;
|
|
18
|
+
/** True mentre il messaggio assistant e' in streaming/caricamento. */
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
/** Sorgenti RAG associate alla risposta (citazioni). */
|
|
21
|
+
sources?: FHAiSource[];
|
|
22
|
+
/** Timestamp di creazione (ms). */
|
|
23
|
+
ts?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Contesto di scoping {azienda, ruolo, persona}.
|
|
27
|
+
* NB: e' informativo/di visualizzazione lato client (es. per il titolo).
|
|
28
|
+
* L'enforcement di sicurezza avviene server-side dall'identita' autenticata.
|
|
29
|
+
*/
|
|
30
|
+
export interface FHAiContext {
|
|
31
|
+
azienda?: string;
|
|
32
|
+
ruolo?: string;
|
|
33
|
+
persona?: string;
|
|
34
|
+
/** Id conversazione per continuita' lato backend. */
|
|
35
|
+
conversationId?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Opzioni della singola chiamata al backend AI. */
|
|
38
|
+
export interface FHAiRequestOptions {
|
|
39
|
+
/** URL completo dell'endpoint chat. Se assente: AppService.API_ENDPOINT + path. */
|
|
40
|
+
endpoint?: string;
|
|
41
|
+
/** Path relativo all'API_ENDPOINT quando non si passa un endpoint completo. */
|
|
42
|
+
path?: string;
|
|
43
|
+
/** Modello da richiedere (override; di norma deciso dal backend). */
|
|
44
|
+
model?: string;
|
|
45
|
+
/** Abilita lo streaming SSE (default true). */
|
|
46
|
+
stream?: boolean;
|
|
47
|
+
/** API key del servizio AI (header x-api-key). Di norma NON serve lato browser:
|
|
48
|
+
* la chiave sta sul backend FluxHub che fa da proxy. */
|
|
49
|
+
apiKey?: string;
|
|
50
|
+
/** Header aggiuntivi. */
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
/** Inoltra il JWT FluxHub come Authorization: Bearer (default true). */
|
|
53
|
+
forwardAuth?: boolean;
|
|
54
|
+
/** Contesto di scoping (inviato come metadata, non autoritativo). */
|
|
55
|
+
context?: FHAiContext;
|
|
56
|
+
}
|
|
57
|
+
/** Frammento emesso durante lo streaming. */
|
|
58
|
+
export interface FHAiChunk {
|
|
59
|
+
/** Delta di testo (token). */
|
|
60
|
+
delta: string;
|
|
61
|
+
/** Testo accumulato finora. */
|
|
62
|
+
text: string;
|
|
63
|
+
/** True sull'ultimo frammento. */
|
|
64
|
+
done: boolean;
|
|
65
|
+
/** Sorgenti, se arrivate (di norma a fine risposta). */
|
|
66
|
+
sources?: FHAiSource[];
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluxhub/fluxhub-lib",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.184",
|
|
4
4
|
"description": "FluxHub components and workflow library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
8
|
+
"@angular/animations": "^19.2.0",
|
|
9
|
+
"@angular/cdk": "^19.2.0",
|
|
10
|
+
"@angular/common": "^19.2.0",
|
|
11
|
+
"@angular/core": "^19.2.0",
|
|
12
|
+
"@angular/forms": "^19.2.0",
|
|
13
|
+
"@angular/material": "^19.2.0",
|
|
14
|
+
"@angular/platform-browser": "^19.2.0",
|
|
15
|
+
"@angular/platform-browser-dynamic": "^19.2.0",
|
|
16
|
+
"@angular/router": "^19.2.0",
|
|
17
|
+
"rxjs": "^7.8.0",
|
|
18
|
+
"ag-grid-community": "^33.1.0",
|
|
19
|
+
"ag-grid-angular": "^33.1.0",
|
|
20
|
+
"ag-grid-enterprise": "^33.1.0",
|
|
21
|
+
"@ngx-translate/core": "^16.0.0",
|
|
22
|
+
"ngx-toastr": "^19.0.0",
|
|
23
|
+
"ngx-flexible-layout": "^19.0.0"
|
|
11
24
|
},
|
|
12
25
|
"dependencies": {
|
|
13
|
-
"tslib": "^2.8.1"
|
|
26
|
+
"tslib": "^2.8.1",
|
|
27
|
+
"crypto-ts": "^1.0.2",
|
|
28
|
+
"recursive-diff": "^1.0.7",
|
|
29
|
+
"moment": "^2.30.1",
|
|
30
|
+
"bpmn-js": "^18.6.2",
|
|
31
|
+
"quill": "^2.0.3",
|
|
32
|
+
"chart.js": "^4.4.8",
|
|
33
|
+
"ng2-charts": "^8.0.0",
|
|
34
|
+
"ng2-file-upload": "^8.0.0",
|
|
35
|
+
"ngx-quill": "^27.0.1",
|
|
36
|
+
"ngx-color-picker": "^20.1.1",
|
|
37
|
+
"@angular/google-maps": "^19.2.0",
|
|
38
|
+
"@angular/material-moment-adapter": "^19.2.0"
|
|
14
39
|
},
|
|
15
40
|
"module": "fesm2022/fluxhub-fluxhub-lib.mjs",
|
|
16
41
|
"exports": {
|
package/public-api.d.ts
CHANGED
|
@@ -109,3 +109,7 @@ export { FHHomeLauncherComponent, FHLauncherApp, FHLauncherCategory } from './li
|
|
|
109
109
|
export { FHHomeTodoComponent } from './lib/home-components/fh-home-todo/fh-home-todo.component';
|
|
110
110
|
export { FHHomeStatsComponent } from './lib/home-components/fh-home-stats/fh-home-stats.component';
|
|
111
111
|
export { FHHomeDocsComponent } from './lib/home-components/fh-home-docs/fh-home-docs.component';
|
|
112
|
+
export { FHAiService } from './lib/ai-components/fh-ai.service';
|
|
113
|
+
export { FHAiChatComponent } from './lib/ai-components/fh-ai-chat/fh-ai-chat.component';
|
|
114
|
+
export { FHAiAssistantComponent } from './lib/ai-components/fh-ai-assistant/fh-ai-assistant.component';
|
|
115
|
+
export { FHAiRole, FHAiSource, FHAiMessage, FHAiContext, FHAiRequestOptions, FHAiChunk, } from './lib/ai-components/models/fh-ai.models';
|