@naniteninja/profile-comparison-lib 0.0.1 → 1.0.0
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/README.md +193 -314
- package/fesm2022/naniteninja-profile-comparison-lib.mjs +1061 -1256
- package/fesm2022/naniteninja-profile-comparison-lib.mjs.map +1 -1
- package/index.d.ts +168 -210
- package/package.json +3 -19
package/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { OnInit, AfterViewInit, OnChanges, EventEmitter, ElementRef, Renderer2, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { InjectionToken, OnInit, AfterViewInit, OnChanges, EventEmitter, ElementRef, Renderer2, ChangeDetectorRef, SimpleChanges } from '@angular/core';
|
|
3
|
+
import { Observable, BehaviorSubject } from 'rxjs';
|
|
3
4
|
import * as i3 from '@angular/common/http';
|
|
4
|
-
import { HttpClient
|
|
5
|
-
import { Observable } from 'rxjs';
|
|
6
|
-
import * as i4 from '@angular/forms';
|
|
7
|
-
import { FormGroup, FormControl } from '@angular/forms';
|
|
5
|
+
import { HttpClient } from '@angular/common/http';
|
|
8
6
|
import * as i2 from '@angular/common';
|
|
9
|
-
import * as
|
|
10
|
-
import { Router } from '@angular/router';
|
|
7
|
+
import * as i4 from '@angular/forms';
|
|
11
8
|
|
|
12
9
|
interface IProfileConfig {
|
|
13
10
|
person1Interests: string[];
|
|
@@ -76,7 +73,7 @@ interface FaceDetectionResponse {
|
|
|
76
73
|
interface FaceDetectionData {
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
interface IImageCompressionConfig
|
|
76
|
+
interface IImageCompressionConfig {
|
|
80
77
|
maxWidth: number;
|
|
81
78
|
maxHeight: number;
|
|
82
79
|
format: 'image/jpeg' | 'image/png' | 'image/webp';
|
|
@@ -147,6 +144,10 @@ interface IEnvironment {
|
|
|
147
144
|
openaiApiKey: string;
|
|
148
145
|
apiFaceplusKey?: string;
|
|
149
146
|
apiFaceplusSecret?: string;
|
|
147
|
+
/** Base URL for local mock server (e.g. http://localhost:3000/api). Used when backend mode is "mock". */
|
|
148
|
+
backendApiUrlMock?: string;
|
|
149
|
+
/** Base URL for real deployed backend (e.g. AWS). Used when backend mode is "real". */
|
|
150
|
+
backendApiUrlReal?: string;
|
|
150
151
|
[key: string]: unknown;
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -164,6 +165,45 @@ interface IMatrixData {
|
|
|
164
165
|
rows: IMatrixRow[];
|
|
165
166
|
}
|
|
166
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Response from the profile comparison backend (POST /api/profile/compare-full).
|
|
170
|
+
* The lib is a thin client: it sends config and receives this display payload.
|
|
171
|
+
*/
|
|
172
|
+
interface IComparisonPayload {
|
|
173
|
+
face1?: IFaceDetectionResult | null;
|
|
174
|
+
face2?: IFaceDetectionResult | null;
|
|
175
|
+
alignedPerson1Interests: string[];
|
|
176
|
+
alignedPerson2Interests: string[];
|
|
177
|
+
centerItem: string[];
|
|
178
|
+
matrixData: IMatrixData | null;
|
|
179
|
+
rawLLMOutput?: string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
declare const STORE_NAMES: readonly ["openai-spacer", "openai-alignment", "openai-similarity", "openai-embeddings", "profile-face", "profile-compare"];
|
|
183
|
+
type CacheStoreName = typeof STORE_NAMES[number];
|
|
184
|
+
/**
|
|
185
|
+
* Persists cache entries to IndexedDB per device (mobile-friendly).
|
|
186
|
+
* No-op when IndexedDB is unavailable (e.g. SSR, private mode on some browsers).
|
|
187
|
+
*/
|
|
188
|
+
declare class CachePersistenceService {
|
|
189
|
+
private db;
|
|
190
|
+
private openPromise;
|
|
191
|
+
private openDb;
|
|
192
|
+
private getStore;
|
|
193
|
+
get<T>(storeName: CacheStoreName, key: string): Promise<T | undefined>;
|
|
194
|
+
set(storeName: CacheStoreName, key: string, value: unknown): Promise<void>;
|
|
195
|
+
getAll(storeName: CacheStoreName): Promise<[string, unknown][]>;
|
|
196
|
+
clear(storeName?: CacheStoreName): Promise<void>;
|
|
197
|
+
static readonly STORE_OPENAI_SPACER = "openai-spacer";
|
|
198
|
+
static readonly STORE_OPENAI_ALIGNMENT = "openai-alignment";
|
|
199
|
+
static readonly STORE_OPENAI_SIMILARITY = "openai-similarity";
|
|
200
|
+
static readonly STORE_OPENAI_EMBEDDINGS = "openai-embeddings";
|
|
201
|
+
static readonly STORE_PROFILE_FACE = "profile-face";
|
|
202
|
+
static readonly STORE_PROFILE_COMPARE = "profile-compare";
|
|
203
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CachePersistenceService, never>;
|
|
204
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<CachePersistenceService>;
|
|
205
|
+
}
|
|
206
|
+
|
|
167
207
|
declare class EmbeddingService {
|
|
168
208
|
private model$;
|
|
169
209
|
getEmbedding(text: string): Observable<Float32Array>;
|
|
@@ -229,7 +269,7 @@ declare class FileConversionService {
|
|
|
229
269
|
}
|
|
230
270
|
|
|
231
271
|
declare class ImageCompressionService {
|
|
232
|
-
compressImageFile(file: File, config: IImageCompressionConfig
|
|
272
|
+
compressImageFile(file: File, config: IImageCompressionConfig, overrides?: Partial<IImageCompressionConfig>): Observable<{
|
|
233
273
|
file: File;
|
|
234
274
|
dataUrl: string;
|
|
235
275
|
}>;
|
|
@@ -241,6 +281,18 @@ declare class ImageCompressionService {
|
|
|
241
281
|
static ɵprov: i0.ɵɵInjectableDeclaration<ImageCompressionService>;
|
|
242
282
|
}
|
|
243
283
|
|
|
284
|
+
/** Either a static base URL or a getter that returns the current base URL (for runtime toggle). */
|
|
285
|
+
type ProfileComparisonApiBaseUrl = string | (() => string | null);
|
|
286
|
+
/**
|
|
287
|
+
* When provided, ProfileService and OpenAIEmbeddingService call this backend base URL
|
|
288
|
+
* (e.g. 'http://localhost:3000/api') for all profile/embedding endpoints instead of
|
|
289
|
+
* calling external APIs directly with keys. Can be a string or a getter function for runtime toggle.
|
|
290
|
+
* When not provided or getter returns null, the lib uses the direct path with keys.
|
|
291
|
+
*/
|
|
292
|
+
declare const PROFILE_COMPARISON_API_BASE_URL: InjectionToken<ProfileComparisonApiBaseUrl | null>;
|
|
293
|
+
/** Optional getter: when true, lib and backend service log steps to console for diagnosis. */
|
|
294
|
+
declare const PROFILE_COMPARISON_VERBOSE_LOGGING: InjectionToken<() => boolean>;
|
|
295
|
+
|
|
244
296
|
/**
|
|
245
297
|
* OpenAI Alignment Service
|
|
246
298
|
* Uses OpenAI Chat Completions API to align two lists of text in a single request.
|
|
@@ -248,6 +300,8 @@ declare class ImageCompressionService {
|
|
|
248
300
|
*/
|
|
249
301
|
declare class OpenAIEmbeddingService {
|
|
250
302
|
private http;
|
|
303
|
+
private apiBaseUrl;
|
|
304
|
+
private persistence;
|
|
251
305
|
private static readonly API_URL;
|
|
252
306
|
private static readonly MODEL;
|
|
253
307
|
private static readonly HEADER_CONTENT_TYPE;
|
|
@@ -260,7 +314,23 @@ declare class OpenAIEmbeddingService {
|
|
|
260
314
|
private readonly MODEL;
|
|
261
315
|
private alignmentCache;
|
|
262
316
|
private spacerAlignmentCache;
|
|
263
|
-
|
|
317
|
+
private similarityCache;
|
|
318
|
+
private embeddingsCache;
|
|
319
|
+
private spacerLoaded;
|
|
320
|
+
private alignmentLoaded;
|
|
321
|
+
private similarityLoaded;
|
|
322
|
+
private embeddingsLoaded;
|
|
323
|
+
private spacerLoadPromise;
|
|
324
|
+
private alignmentLoadPromise;
|
|
325
|
+
private similarityLoadPromise;
|
|
326
|
+
private embeddingsLoadPromise;
|
|
327
|
+
rawResponse$: BehaviorSubject<string>;
|
|
328
|
+
constructor(http: HttpClient, apiBaseUrl: ProfileComparisonApiBaseUrl | null, persistence: CachePersistenceService);
|
|
329
|
+
private loadSpacerCache;
|
|
330
|
+
private loadAlignmentCache;
|
|
331
|
+
private loadSimilarityCache;
|
|
332
|
+
private loadEmbeddingsCache;
|
|
333
|
+
private getBaseUrl;
|
|
264
334
|
/**
|
|
265
335
|
* Get aligned lists with spacers.
|
|
266
336
|
* Now uses a direct LLM call with a specific prompt to generate the aligned lists.
|
|
@@ -269,12 +339,14 @@ declare class OpenAIEmbeddingService {
|
|
|
269
339
|
listA: string[];
|
|
270
340
|
listB: string[];
|
|
271
341
|
}>;
|
|
342
|
+
private requestAlignedListsDirect;
|
|
272
343
|
private sanitizeResponse;
|
|
273
344
|
/**
|
|
274
345
|
* Get alignment between two lists using a single OpenAI Chat Completion request.
|
|
275
346
|
* Uses canonical caching to ensure A->B and B->A use the same API response.
|
|
276
347
|
*/
|
|
277
348
|
groupAlignLists(listA: string[], listB: string[], threshold: number | undefined, preserveLeftOrder: boolean | undefined, exclusivityMargin: number | undefined, leftCohesion: number | undefined, apiKey: string): Observable<IAlignmentRow[]>;
|
|
349
|
+
private requestGroupAlignLists;
|
|
278
350
|
/**
|
|
279
351
|
* Calculate semantic similarity between two texts using OpenAI Embeddings API.
|
|
280
352
|
* Returns a cosine similarity score in [0, 1] (0 for empty/invalid inputs).
|
|
@@ -286,7 +358,7 @@ declare class OpenAIEmbeddingService {
|
|
|
286
358
|
getEmbeddings(texts: string[], apiKey: string): Observable<number[][]>;
|
|
287
359
|
private cosineSimilarityVectors;
|
|
288
360
|
clearCache(): void;
|
|
289
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<OpenAIEmbeddingService,
|
|
361
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OpenAIEmbeddingService, [null, { optional: true; }, null]>;
|
|
290
362
|
static ɵprov: i0.ɵɵInjectableDeclaration<OpenAIEmbeddingService>;
|
|
291
363
|
}
|
|
292
364
|
|
|
@@ -306,26 +378,61 @@ declare class ProfileComparisonLibService {
|
|
|
306
378
|
|
|
307
379
|
declare class ProfileService {
|
|
308
380
|
private http;
|
|
381
|
+
private apiBaseUrl;
|
|
382
|
+
private persistence;
|
|
309
383
|
private static readonly BASE_URL;
|
|
310
384
|
private static readonly FACE_PLUS_PLUS_URL;
|
|
311
385
|
private baseUrl;
|
|
312
386
|
private baseUrlf;
|
|
313
|
-
|
|
387
|
+
private faceCache;
|
|
388
|
+
private compareInterestsCache;
|
|
389
|
+
private faceLoaded;
|
|
390
|
+
private compareLoaded;
|
|
391
|
+
private faceLoadPromise;
|
|
392
|
+
private compareLoadPromise;
|
|
393
|
+
/** Content-based cache key: hash long strings/data URLs so same content yields same key and we avoid huge keys. */
|
|
394
|
+
private static faceCacheKey;
|
|
395
|
+
constructor(http: HttpClient, apiBaseUrl: ProfileComparisonApiBaseUrl | null, persistence: CachePersistenceService);
|
|
396
|
+
private loadFaceCache;
|
|
397
|
+
private loadCompareCache;
|
|
398
|
+
private getBaseUrl;
|
|
314
399
|
compareInterests(text_1: string, text_2: string, apiKey: string): Observable<ISimilarityResponse>;
|
|
315
400
|
detectFace(image: File | string, creds?: {
|
|
316
401
|
apiKey?: string;
|
|
317
402
|
apiSecret?: string;
|
|
403
|
+
}, options?: {
|
|
404
|
+
cacheKey?: string;
|
|
318
405
|
}): Observable<IFaceDetectionResult>;
|
|
319
|
-
|
|
406
|
+
private detectFaceDirect;
|
|
407
|
+
clearFaceCache(): void;
|
|
408
|
+
clearCompareInterestsCache(): void;
|
|
409
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileService, [null, { optional: true; }, null]>;
|
|
320
410
|
static ɵprov: i0.ɵɵInjectableDeclaration<ProfileService>;
|
|
321
411
|
}
|
|
322
412
|
|
|
413
|
+
/**
|
|
414
|
+
* Thin-client service: sends config to the backend and returns the display payload.
|
|
415
|
+
* The lib does not call third-party APIs; the backend does.
|
|
416
|
+
*/
|
|
417
|
+
declare class ProfileComparisonBackendService {
|
|
418
|
+
private http;
|
|
419
|
+
private apiBaseUrl;
|
|
420
|
+
private getVerboseLogging?;
|
|
421
|
+
constructor(http: HttpClient, apiBaseUrl: ProfileComparisonApiBaseUrl | null, getVerboseLogging?: (() => boolean) | undefined);
|
|
422
|
+
private log;
|
|
423
|
+
getBaseUrl(): string | null;
|
|
424
|
+
getComparison(config: IProfileConfig): Observable<IComparisonPayload>;
|
|
425
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonBackendService, [null, { optional: true; }, { optional: true; }]>;
|
|
426
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ProfileComparisonBackendService>;
|
|
427
|
+
}
|
|
428
|
+
|
|
323
429
|
declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, OnChanges {
|
|
324
|
-
private
|
|
325
|
-
private openaiEmbeddingService;
|
|
430
|
+
private backendService;
|
|
326
431
|
private renderer;
|
|
327
432
|
private fileConversionService;
|
|
328
433
|
private imageCompressionService;
|
|
434
|
+
private cdr;
|
|
435
|
+
private getVerboseLogging?;
|
|
329
436
|
private static readonly DEFAULT_OBJECT_POSITION;
|
|
330
437
|
private static readonly DEFAULT_EYE_ALIGNMENT_BIAS_PX;
|
|
331
438
|
private static readonly DEFAULT_IMAGE_FORMAT;
|
|
@@ -344,21 +451,35 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
344
451
|
private static readonly CONSOLIDATION_SEPARATOR_SLASH;
|
|
345
452
|
private static readonly FACEPP_RATE_LIMIT_DELAY_MS;
|
|
346
453
|
private static readonly DEFAULT_PROFILE_IMAGE_NAME;
|
|
454
|
+
private static readonly SHAPE_BG_HEIGHT;
|
|
455
|
+
private static readonly SHAPE_BG_OBJECT_FIT;
|
|
456
|
+
private static readonly SHAPE_BG1_OBJECT_POSITION;
|
|
457
|
+
private static readonly SHAPE_BG2_OBJECT_POSITION;
|
|
458
|
+
private static readonly DRAG_MIN_WIDTH;
|
|
459
|
+
private static readonly DRAG_MAX_WIDTH;
|
|
460
|
+
private static readonly MAX_DRAG_DISTANCE;
|
|
461
|
+
private static readonly CENTER_MOVE_MULTIPLIER;
|
|
462
|
+
private static readonly TEXT_MOVE_MULTIPLIER;
|
|
463
|
+
private static readonly TRANSITION_WIDTH;
|
|
464
|
+
private static readonly TRANSITION_TRANSFORM;
|
|
465
|
+
private static readonly TRANSFORM_RESET;
|
|
466
|
+
private static readonly TRANSITION_RESET_DELAY_MS;
|
|
347
467
|
config: IProfileConfig;
|
|
348
|
-
apiNinjasKey: string;
|
|
349
|
-
faceplusKey: string;
|
|
350
|
-
faceplusSecret: string;
|
|
351
|
-
openaiApiKey: string;
|
|
352
468
|
fadeAllEdges: boolean;
|
|
353
469
|
matrixDataChange: EventEmitter<IMatrixData>;
|
|
470
|
+
rawLLMOutputChange: EventEmitter<string>;
|
|
471
|
+
viewProfileClick: EventEmitter<{
|
|
472
|
+
side: "left" | "right";
|
|
473
|
+
}>;
|
|
354
474
|
selectedFile: File | null;
|
|
355
|
-
result: unknown;
|
|
356
475
|
firstImageData: FaceDetectionData | null;
|
|
357
476
|
secondImageData: FaceDetectionData | null;
|
|
358
477
|
user1Transform: string;
|
|
359
478
|
user2Transform: string;
|
|
360
479
|
alignmentCalculated: boolean;
|
|
361
480
|
isAligning: boolean;
|
|
481
|
+
/** Set when backend returns an error (e.g. 503 API keys not configured). */
|
|
482
|
+
backendError: string | null;
|
|
362
483
|
user1ObjectPosition: string;
|
|
363
484
|
user2ObjectPosition: string;
|
|
364
485
|
private user1NaturalWidth;
|
|
@@ -399,36 +520,34 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
399
520
|
similarity: number;
|
|
400
521
|
similarityMatrixCsv: string;
|
|
401
522
|
matrixData: IMatrixData | null;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
quotaExhausted: boolean;
|
|
406
|
-
customFaceppKey: string;
|
|
407
|
-
customFaceppSecret: string;
|
|
408
|
-
showFaceppKeyModal: boolean;
|
|
409
|
-
faceppKeyInputValue: string;
|
|
410
|
-
faceppSecretInputValue: string;
|
|
411
|
-
faceppQuotaExhausted: boolean;
|
|
412
|
-
customOpenAIKey: string;
|
|
413
|
-
showOpenAIKeyModal: boolean;
|
|
414
|
-
openaiKeyInputValue: string;
|
|
415
|
-
openaiQuotaExhausted: boolean;
|
|
416
|
-
compressionConfig: IImageCompressionConfig$1;
|
|
523
|
+
/** When false, backend URL is not provided — show "Configure backend". */
|
|
524
|
+
backendConfigured: boolean;
|
|
525
|
+
compressionConfig: IImageCompressionConfig;
|
|
417
526
|
private computeSub?;
|
|
418
|
-
|
|
419
|
-
private
|
|
420
|
-
private activeRequestEpoch;
|
|
421
|
-
form: FormGroup<{
|
|
422
|
-
interest1: FormControl<string | null>;
|
|
423
|
-
interest2: FormControl<string | null>;
|
|
424
|
-
}>;
|
|
527
|
+
/** Incremented on each fetchComparison(); used to ignore stale success/error from an older request. */
|
|
528
|
+
private fetchRequestId;
|
|
425
529
|
leftContainer: ElementRef;
|
|
426
530
|
rightContainer: ElementRef;
|
|
427
|
-
|
|
531
|
+
profileFlex: ElementRef<HTMLElement>;
|
|
532
|
+
profileImgLeft: ElementRef<HTMLElement>;
|
|
533
|
+
profileImgRight: ElementRef<HTMLElement>;
|
|
534
|
+
shapeContainer: ElementRef<HTMLElement>;
|
|
535
|
+
shapeBg: ElementRef<HTMLElement>;
|
|
536
|
+
shapeBg1: ElementRef<SVGElement>;
|
|
537
|
+
shapeBg2: ElementRef<SVGElement>;
|
|
538
|
+
shapeTextLeft: ElementRef<HTMLElement>;
|
|
539
|
+
shapeTextRight: ElementRef<HTMLElement>;
|
|
540
|
+
shapeTextCenter: ElementRef<HTMLElement>;
|
|
541
|
+
constructor(backendService: ProfileComparisonBackendService, renderer: Renderer2, fileConversionService: FileConversionService, imageCompressionService: ImageCompressionService, cdr: ChangeDetectorRef, getVerboseLogging?: (() => boolean) | undefined);
|
|
542
|
+
private log;
|
|
428
543
|
anchorSide: 'left' | 'right';
|
|
544
|
+
rawLLMOutput: string;
|
|
429
545
|
ngOnInit(): void;
|
|
430
546
|
ngAfterViewInit(): void;
|
|
431
547
|
ngOnChanges(changes: SimpleChanges): void;
|
|
548
|
+
/** Use for template: hide left/right item when it's a shared (center) item. Compares case-insensitively. */
|
|
549
|
+
isInCenter(interest: string): boolean;
|
|
550
|
+
private fetchComparison;
|
|
432
551
|
private updateConfigProperties;
|
|
433
552
|
private buildConfigWithDefaults;
|
|
434
553
|
onUserImageLoad(which: 1 | 2, event: Event): void;
|
|
@@ -438,41 +557,9 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
438
557
|
private setOverlapSizeCssPx;
|
|
439
558
|
waitForImagesAndInitDrag(): void;
|
|
440
559
|
initDrag(): void;
|
|
441
|
-
|
|
442
|
-
createSemanticAlignment(person1Results: {
|
|
443
|
-
item: string;
|
|
444
|
-
score: number;
|
|
445
|
-
}[], person2Results: {
|
|
446
|
-
item: string;
|
|
447
|
-
score: number;
|
|
448
|
-
}[]): Promise<void>;
|
|
449
|
-
createEmbeddingBasedAlignment(person1Results: {
|
|
450
|
-
item: string;
|
|
451
|
-
score: number;
|
|
452
|
-
}[], person2Results: {
|
|
453
|
-
item: string;
|
|
454
|
-
score: number;
|
|
455
|
-
}[]): Promise<void>;
|
|
456
|
-
sortByMaxSimilarity(personList: string[], otherLists: string[][]): Observable<{
|
|
457
|
-
item: string;
|
|
458
|
-
score: number;
|
|
459
|
-
}[]>;
|
|
460
|
-
onViewProfile(): void;
|
|
461
|
-
getActiveApiKey(): string;
|
|
462
|
-
updateApiKey(): void;
|
|
463
|
-
closeApiKeyModal(): void;
|
|
464
|
-
handleApiQuotaError(error: HttpErrorResponse | {
|
|
465
|
-
status?: number;
|
|
466
|
-
error?: {
|
|
467
|
-
message?: string;
|
|
468
|
-
};
|
|
469
|
-
}): void;
|
|
470
|
-
private saveApiKeyToStorage;
|
|
471
|
-
private loadApiKeyFromStorage;
|
|
472
|
-
onFileInputChange(event: FileInputEvent): void;
|
|
560
|
+
onViewProfile(side: 'left' | 'right'): void;
|
|
473
561
|
private compressConfigImagesIfNeeded;
|
|
474
562
|
private compressImageStringToDataUrl;
|
|
475
|
-
private loadCustomConfig;
|
|
476
563
|
getEyeCoordinatesFromBBox(bbox: IBoundingBox): {
|
|
477
564
|
leftEye: IPoint;
|
|
478
565
|
rightEye: IPoint;
|
|
@@ -491,147 +578,18 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
491
578
|
faceLeft: IPoint;
|
|
492
579
|
faceRight: IPoint;
|
|
493
580
|
};
|
|
494
|
-
initializeFaceDetection(): void;
|
|
495
581
|
calculateFaceAlignment(user1Data: FaceDetectionData, user2Data: FaceDetectionData): void;
|
|
496
582
|
applyDefaultAlignment(): void;
|
|
497
583
|
isValidFaceData(face: IBoundingBox): boolean;
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
updateFaceppCredentials(): void;
|
|
501
|
-
closeFaceppKeyModal(): void;
|
|
502
|
-
handleFaceppError(error: HttpErrorResponse | {
|
|
503
|
-
status?: number;
|
|
504
|
-
error?: {
|
|
505
|
-
message?: string;
|
|
506
|
-
};
|
|
507
|
-
}): void;
|
|
508
|
-
private saveFaceppCredsToStorage;
|
|
509
|
-
private loadFaceppCredsFromStorage;
|
|
510
|
-
private getActiveOpenAIKey;
|
|
511
|
-
updateOpenAIKey(): void;
|
|
512
|
-
closeOpenAIKeyModal(): void;
|
|
513
|
-
private saveOpenAIKeyToStorage;
|
|
514
|
-
private loadOpenAIKeyFromStorage;
|
|
515
|
-
private generateSimilarityMatrix;
|
|
516
|
-
private cosineSimilarity;
|
|
517
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonLibComponent, never>;
|
|
518
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ProfileComparisonLibComponent, "lib-profile-comparison", never, { "config": { "alias": "config"; "required": false; }; "apiNinjasKey": { "alias": "apiNinjasKey"; "required": false; }; "faceplusKey": { "alias": "faceplusKey"; "required": false; }; "faceplusSecret": { "alias": "faceplusSecret"; "required": false; }; "openaiApiKey": { "alias": "openaiApiKey"; "required": false; }; "fadeAllEdges": { "alias": "fadeAllEdges"; "required": false; }; }, { "matrixDataChange": "matrixDataChange"; }, never, never, false, never>;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
interface IImageCompressionConfig {
|
|
522
|
-
maxWidth: number;
|
|
523
|
-
maxHeight: number;
|
|
524
|
-
format: 'image/jpeg' | 'image/png' | 'image/webp';
|
|
525
|
-
qualityStart: number;
|
|
526
|
-
qualityMin: number;
|
|
527
|
-
qualityStep: number;
|
|
528
|
-
maxBytes: number;
|
|
529
|
-
downscaleStep: number;
|
|
530
|
-
minWidth: number;
|
|
531
|
-
minHeight: number;
|
|
532
|
-
}
|
|
533
|
-
declare class CustomInputComponent {
|
|
534
|
-
private router;
|
|
535
|
-
person1Text: string;
|
|
536
|
-
person2Text: string;
|
|
537
|
-
person3Text: string;
|
|
538
|
-
user1File: File | null;
|
|
539
|
-
user2File: File | null;
|
|
540
|
-
user1Preview: string | null;
|
|
541
|
-
user2Preview: string | null;
|
|
542
|
-
saving: boolean;
|
|
543
|
-
error: string | null;
|
|
544
|
-
private static readonly MAX_WIDTH;
|
|
545
|
-
private static readonly MAX_HEIGHT;
|
|
546
|
-
private static readonly COMPRESSION_FORMAT;
|
|
547
|
-
private static readonly QUALITY_START;
|
|
548
|
-
private static readonly QUALITY_MIN;
|
|
549
|
-
private static readonly QUALITY_STEP;
|
|
550
|
-
private static readonly MAX_BYTES;
|
|
551
|
-
private static readonly DOWNSCALE_STEP;
|
|
552
|
-
private static readonly MIN_WIDTH;
|
|
553
|
-
private static readonly MIN_HEIGHT;
|
|
554
|
-
compressionConfig: IImageCompressionConfig;
|
|
555
|
-
constructor(router: Router);
|
|
556
|
-
onUser1FileChange(event: Event): Promise<void>;
|
|
557
|
-
onUser2FileChange(event: Event): Promise<void>;
|
|
558
|
-
saveAndView(): Promise<void>;
|
|
559
|
-
clearAll(): void;
|
|
560
|
-
close(): void;
|
|
561
|
-
private toList;
|
|
562
|
-
private fileToDataURL;
|
|
563
|
-
private previewFile;
|
|
564
|
-
private compressImageFile;
|
|
565
|
-
private loadImageFromFile;
|
|
566
|
-
private canvasToBlob;
|
|
567
|
-
private blobToDataURL;
|
|
568
|
-
private renameFileForFormat;
|
|
569
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<CustomInputComponent, never>;
|
|
570
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<CustomInputComponent, "lib-custom-input", never, {}, {}, never, never, true, never>;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
declare class DocumentationComponent implements OnInit {
|
|
574
|
-
private openaiEmbeddingService;
|
|
575
|
-
private profileService;
|
|
576
|
-
private router;
|
|
577
|
-
apiKeyInput: string;
|
|
578
|
-
textA: string;
|
|
579
|
-
textB: string;
|
|
580
|
-
embeddingScore: number | null;
|
|
581
|
-
embeddingLoading: boolean;
|
|
582
|
-
embeddingError: string | null;
|
|
583
|
-
listAInput: string;
|
|
584
|
-
listBInput: string;
|
|
585
|
-
matchingPairs: Array<{
|
|
586
|
-
wordA: string;
|
|
587
|
-
wordB: string;
|
|
588
|
-
score: number;
|
|
589
|
-
}>;
|
|
590
|
-
pairsLoading: boolean;
|
|
591
|
-
pairsError: string | null;
|
|
592
|
-
faceFile: File | null;
|
|
593
|
-
faceResult: unknown;
|
|
594
|
-
faceLoading: boolean;
|
|
595
|
-
faceError: string | null;
|
|
596
|
-
compareA: string;
|
|
597
|
-
compareB: string;
|
|
598
|
-
apiSimilarity: number | null;
|
|
599
|
-
apiLoading: boolean;
|
|
600
|
-
apiError: string | null;
|
|
601
|
-
openaiKeyInput: string;
|
|
602
|
-
defaultApiNinjasKey: string;
|
|
603
|
-
defaultOpenaiApiKey: string;
|
|
604
|
-
constructor(openaiEmbeddingService: OpenAIEmbeddingService, profileService: ProfileService, router: Router);
|
|
605
|
-
ngOnInit(): void;
|
|
606
|
-
getActiveApiKey(): string;
|
|
607
|
-
saveKey(): void;
|
|
608
|
-
getStoredKey(): string | null;
|
|
609
|
-
getActiveOpenAIKey(): string;
|
|
610
|
-
saveOpenAIKey(): void;
|
|
611
|
-
runEmbeddingSimilarity(): void;
|
|
612
|
-
runBestPairs(): void;
|
|
613
|
-
onFaceFileChange(event: Event): void;
|
|
614
|
-
runFaceDetect(): void;
|
|
615
|
-
runApiSimilarity(): void;
|
|
616
|
-
similarityLabel(): string;
|
|
617
|
-
apiSimilarityLabel(): string;
|
|
618
|
-
pairLabel(p: {
|
|
619
|
-
wordA: string;
|
|
620
|
-
wordB: string;
|
|
621
|
-
score: number;
|
|
622
|
-
}): string;
|
|
623
|
-
faceResultJson(): string;
|
|
624
|
-
private formatNumber;
|
|
625
|
-
goHome(event: Event): void;
|
|
626
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DocumentationComponent, never>;
|
|
627
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<DocumentationComponent, "lib-documentation", never, { "defaultApiNinjasKey": { "alias": "defaultApiNinjasKey"; "required": false; }; "defaultOpenaiApiKey": { "alias": "defaultOpenaiApiKey"; "required": false; }; }, {}, never, never, true, never>;
|
|
584
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonLibComponent, [null, null, null, null, null, { optional: true; }]>;
|
|
585
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ProfileComparisonLibComponent, "lib-profile-comparison", never, { "config": { "alias": "config"; "required": false; }; "fadeAllEdges": { "alias": "fadeAllEdges"; "required": false; }; }, { "matrixDataChange": "matrixDataChange"; "rawLLMOutputChange": "rawLLMOutputChange"; "viewProfileClick": "viewProfileClick"; }, never, never, false, never>;
|
|
628
586
|
}
|
|
629
587
|
|
|
630
588
|
declare class ProfileComparisonLibModule {
|
|
631
589
|
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonLibModule, never>;
|
|
632
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<ProfileComparisonLibModule, [typeof ProfileComparisonLibComponent], [typeof i2.CommonModule, typeof i3.HttpClientModule, typeof i4.FormsModule, typeof i4.ReactiveFormsModule
|
|
590
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ProfileComparisonLibModule, [typeof ProfileComparisonLibComponent], [typeof i2.CommonModule, typeof i3.HttpClientModule, typeof i4.FormsModule, typeof i4.ReactiveFormsModule], [typeof ProfileComparisonLibComponent]>;
|
|
633
591
|
static ɵinj: i0.ɵɵInjectorDeclaration<ProfileComparisonLibModule>;
|
|
634
592
|
}
|
|
635
593
|
|
|
636
|
-
export {
|
|
637
|
-
export type { FaceDetectionData, FaceDetectionResponse, FileInputEvent, IAlignmentRow, IBoundingBox, IComparisonResult, IEnvironment, IFaceBoxWithLandmarks, IFaceDetectionResult, IFaceLandmarks, IFacePlusPlusFace, IFacePlusPlusResponse, IFaceRectangle, IImageCompressionConfig
|
|
594
|
+
export { CachePersistenceService, EmbeddingService, FileConversionService, ImageCompressionService, OpenAIEmbeddingService, PROFILE_COMPARISON_API_BASE_URL, PROFILE_COMPARISON_VERBOSE_LOGGING, ProfileComparisonBackendService, ProfileComparisonLibComponent, ProfileComparisonLibModule, ProfileComparisonLibService, ProfileService };
|
|
595
|
+
export type { CacheStoreName, FaceDetectionData, FaceDetectionResponse, FileInputEvent, IAlignmentRow, IBoundingBox, IComparisonPayload, IComparisonResult, IEnvironment, IFaceBoxWithLandmarks, IFaceDetectionResult, IFaceLandmarks, IFacePlusPlusFace, IFacePlusPlusResponse, IFaceRectangle, IImageCompressionConfig, IMatrixData, IMatrixLegendItem, IMatrixRow, IOpenAIEmbeddingItem, IOpenAIResponse, IPoint, IProfileConfig, ISimilarityResponse, ISimilarityThreshold, IWordAlignment, IWordPair };
|
package/package.json
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naniteninja/profile-comparison-lib",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "Angular library for profile comparison functionality",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"angular",
|
|
7
|
-
"profile",
|
|
8
|
-
"comparison",
|
|
9
|
-
"library"
|
|
10
|
-
],
|
|
11
|
-
"author": "",
|
|
12
|
-
"license": "MIT",
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": ""
|
|
16
|
-
},
|
|
3
|
+
"version": "1.0.0",
|
|
17
4
|
"peerDependencies": {
|
|
18
|
-
"@angular/common": "^
|
|
19
|
-
"@angular/core": "^
|
|
20
|
-
"axios": "1.13.2",
|
|
21
|
-
"socket.io": "4.8.1",
|
|
22
|
-
"socket.io-client": "4.8.1"
|
|
5
|
+
"@angular/common": "^20.0.0",
|
|
6
|
+
"@angular/core": "^20.0.0"
|
|
23
7
|
},
|
|
24
8
|
"dependencies": {
|
|
25
9
|
"tslib": "^2.3.0"
|