@zodic/shared 0.0.294 → 0.0.296
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
1
2
|
import { inject, injectable } from 'inversify';
|
|
2
3
|
import { ChatMessages, schema } from '../..';
|
|
3
4
|
import { KVArchetype, ZodiacSignSlug } from '../../types/scopes/legacy';
|
|
@@ -286,7 +287,7 @@ export class ArchetypeService {
|
|
|
286
287
|
|
|
287
288
|
async generateArchetypeNames(
|
|
288
289
|
combination: string,
|
|
289
|
-
|
|
290
|
+
overrideExisting: boolean = false
|
|
290
291
|
) {
|
|
291
292
|
const [sun, ascendant, moon] = combination.split('-') as ZodiacSignSlug[];
|
|
292
293
|
|
|
@@ -338,49 +339,192 @@ export class ArchetypeService {
|
|
|
338
339
|
await Promise.all(
|
|
339
340
|
englishNames.map(async (entry, i) => {
|
|
340
341
|
const index = (i + 1).toString();
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
342
|
+
const ptVariant = portugueseVariants[i];
|
|
343
|
+
|
|
344
|
+
for (const gender of ['male', 'female']) {
|
|
345
|
+
const enId = `${combination}:${gender}:${index}`;
|
|
346
|
+
const ptId = `${combination}:${gender}:${index}:pt`;
|
|
347
|
+
|
|
348
|
+
const existingEn = await db
|
|
349
|
+
.select({ id: schema.archetypesData.id })
|
|
350
|
+
.from(schema.archetypesData)
|
|
351
|
+
.where(eq(schema.archetypesData.id, enId))
|
|
352
|
+
.execute();
|
|
353
|
+
|
|
354
|
+
if (overrideExisting || existingEn.length === 0) {
|
|
355
|
+
await db
|
|
356
|
+
.insert(schema.archetypesData)
|
|
357
|
+
.values({
|
|
358
|
+
id: enId,
|
|
359
|
+
combination,
|
|
360
|
+
gender,
|
|
361
|
+
archetypeIndex: index,
|
|
362
|
+
language: 'en-us',
|
|
363
|
+
name: entry.name,
|
|
364
|
+
essenceLine: entry.essenceLine,
|
|
365
|
+
status: 'idle',
|
|
366
|
+
})
|
|
367
|
+
.onConflictDoUpdate({
|
|
368
|
+
target: [schema.archetypesData.id],
|
|
369
|
+
set: {
|
|
370
|
+
name: entry.name,
|
|
371
|
+
essenceLine: entry.essenceLine,
|
|
372
|
+
updatedAt: new Date().getTime(),
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const ptName = gender === 'female' ? ptVariant.fem : ptVariant.masc;
|
|
378
|
+
|
|
379
|
+
const existingPt = await db
|
|
380
|
+
.select({ id: schema.archetypesData.id })
|
|
381
|
+
.from(schema.archetypesData)
|
|
382
|
+
.where(eq(schema.archetypesData.id, ptId))
|
|
383
|
+
.execute();
|
|
384
|
+
|
|
385
|
+
if (overrideExisting || existingPt.length === 0) {
|
|
386
|
+
await db
|
|
387
|
+
.insert(schema.archetypesData)
|
|
388
|
+
.values({
|
|
389
|
+
id: ptId,
|
|
390
|
+
combination,
|
|
391
|
+
gender,
|
|
392
|
+
archetypeIndex: index,
|
|
393
|
+
language: 'pt-br',
|
|
394
|
+
name: ptName,
|
|
395
|
+
essenceLine: ptVariant.essenceLine,
|
|
396
|
+
status: 'idle',
|
|
397
|
+
})
|
|
398
|
+
.onConflictDoUpdate({
|
|
399
|
+
target: [schema.archetypesData.id],
|
|
400
|
+
set: {
|
|
401
|
+
name: ptName,
|
|
402
|
+
essenceLine: ptVariant.essenceLine,
|
|
403
|
+
updatedAt: new Date().getTime(),
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
383
408
|
})
|
|
384
409
|
);
|
|
385
410
|
}
|
|
411
|
+
|
|
412
|
+
async generateArchetypeNamesBatch(
|
|
413
|
+
entries: Array<{ combination: string }>,
|
|
414
|
+
overrideExisting: boolean = false
|
|
415
|
+
) {
|
|
416
|
+
const prompts = entries.map(({ combination }) => {
|
|
417
|
+
const [sun, ascendant, moon] = combination.split('-') as ZodiacSignSlug[];
|
|
418
|
+
return { sun, ascendant, moon };
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
const prompt = generateArchetypePrompt(prompts);
|
|
422
|
+
const messages: ChatMessages = [{ role: 'user', content: prompt }];
|
|
423
|
+
const response = await this.context.api().callTogether.single(messages, {});
|
|
424
|
+
|
|
425
|
+
if (!response) {
|
|
426
|
+
throw new Error('No response when generating batch archetype names');
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const db = this.context.drizzle();
|
|
430
|
+
|
|
431
|
+
const blocks = response
|
|
432
|
+
.split(/Composition \d+/)
|
|
433
|
+
.slice(1)
|
|
434
|
+
.map((b) => b.trim());
|
|
435
|
+
|
|
436
|
+
for (let i = 0; i < entries.length; i++) {
|
|
437
|
+
const { combination } = entries[i];
|
|
438
|
+
const block = blocks[i];
|
|
439
|
+
const en = block.split('-EN')[1].split('-PT')[0].trim();
|
|
440
|
+
const pt = block.split('-PT')[1].trim();
|
|
441
|
+
|
|
442
|
+
const english = en
|
|
443
|
+
.split(/\n\d\.\s*\n?/)
|
|
444
|
+
.filter(Boolean)
|
|
445
|
+
.map((line) => ({
|
|
446
|
+
name: line.match(/• Name:\s*(.+)/)?.[1]?.trim() || '',
|
|
447
|
+
essenceLine: line.match(/• Essence:\s*(.+)/)?.[1]?.trim() || '',
|
|
448
|
+
}));
|
|
449
|
+
|
|
450
|
+
const portuguese = pt
|
|
451
|
+
.split(/\n\d\.\s*\n?/)
|
|
452
|
+
.filter(Boolean)
|
|
453
|
+
.map((line) => ({
|
|
454
|
+
masc: line.match(/• Masculino:\s*(.+)/)?.[1]?.trim() || '',
|
|
455
|
+
fem: line.match(/• Feminino:\s*(.+)/)?.[1]?.trim() || '',
|
|
456
|
+
essenceLine: line.match(/• Essência:\s*(.+)/)?.[1]?.trim() || '',
|
|
457
|
+
}));
|
|
458
|
+
|
|
459
|
+
for (let j = 0; j < 3; j++) {
|
|
460
|
+
const index = (j + 1).toString();
|
|
461
|
+
const englishEntry = english[j];
|
|
462
|
+
const ptEntry = portuguese[j];
|
|
463
|
+
|
|
464
|
+
for (const gender of ['male', 'female']) {
|
|
465
|
+
const enId = `${combination}:${gender}:${index}`;
|
|
466
|
+
const ptId = `${combination}:${gender}:${index}:pt`;
|
|
467
|
+
const ptName = gender === 'female' ? ptEntry.fem : ptEntry.masc;
|
|
468
|
+
|
|
469
|
+
const existingEn = await db
|
|
470
|
+
.select({ id: schema.archetypesData.id })
|
|
471
|
+
.from(schema.archetypesData)
|
|
472
|
+
.where(eq(schema.archetypesData.id, enId))
|
|
473
|
+
.execute();
|
|
474
|
+
|
|
475
|
+
if (overrideExisting || existingEn.length === 0) {
|
|
476
|
+
await db
|
|
477
|
+
.insert(schema.archetypesData)
|
|
478
|
+
.values({
|
|
479
|
+
id: enId,
|
|
480
|
+
combination,
|
|
481
|
+
gender,
|
|
482
|
+
archetypeIndex: index,
|
|
483
|
+
language: 'en-us',
|
|
484
|
+
name: englishEntry.name,
|
|
485
|
+
essenceLine: englishEntry.essenceLine,
|
|
486
|
+
status: 'idle',
|
|
487
|
+
})
|
|
488
|
+
.onConflictDoUpdate({
|
|
489
|
+
target: [schema.archetypesData.id],
|
|
490
|
+
set: {
|
|
491
|
+
name: englishEntry.name,
|
|
492
|
+
essenceLine: englishEntry.essenceLine,
|
|
493
|
+
updatedAt: new Date().getTime(),
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const existingPt = await db
|
|
499
|
+
.select({ id: schema.archetypesData.id })
|
|
500
|
+
.from(schema.archetypesData)
|
|
501
|
+
.where(eq(schema.archetypesData.id, ptId))
|
|
502
|
+
.execute();
|
|
503
|
+
|
|
504
|
+
if (overrideExisting || existingPt.length === 0) {
|
|
505
|
+
await db
|
|
506
|
+
.insert(schema.archetypesData)
|
|
507
|
+
.values({
|
|
508
|
+
id: ptId,
|
|
509
|
+
combination,
|
|
510
|
+
gender,
|
|
511
|
+
archetypeIndex: index,
|
|
512
|
+
language: 'pt-br',
|
|
513
|
+
name: ptName,
|
|
514
|
+
essenceLine: ptEntry.essenceLine,
|
|
515
|
+
status: 'idle',
|
|
516
|
+
})
|
|
517
|
+
.onConflictDoUpdate({
|
|
518
|
+
target: [schema.archetypesData.id],
|
|
519
|
+
set: {
|
|
520
|
+
name: ptName,
|
|
521
|
+
essenceLine: ptEntry.essenceLine,
|
|
522
|
+
updatedAt: new Date().getTime(),
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
386
530
|
}
|
|
@@ -87,6 +87,32 @@ export class ArchetypeWorkflow {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
async generateNames({
|
|
91
|
+
combinations,
|
|
92
|
+
overrideExisting,
|
|
93
|
+
}: {
|
|
94
|
+
combinations: string[];
|
|
95
|
+
overrideExisting?: boolean;
|
|
96
|
+
}): Promise<void> {
|
|
97
|
+
if (combinations.length === 0) return;
|
|
98
|
+
|
|
99
|
+
if (combinations.length === 1) {
|
|
100
|
+
await this.archetypeService.generateArchetypeNames(
|
|
101
|
+
combinations[0],
|
|
102
|
+
overrideExisting
|
|
103
|
+
);
|
|
104
|
+
} else {
|
|
105
|
+
const entries = combinations.map((combination) => ({
|
|
106
|
+
combination,
|
|
107
|
+
}));
|
|
108
|
+
|
|
109
|
+
await this.archetypeService.generateArchetypeNamesBatch(
|
|
110
|
+
entries,
|
|
111
|
+
overrideExisting
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
90
116
|
/**
|
|
91
117
|
* Fetch all three archetypes from KV for a given combination and gender.
|
|
92
118
|
*/
|
package/package.json
CHANGED
package/types/scopes/generic.ts
CHANGED
|
@@ -402,7 +402,7 @@ export interface JWKS {
|
|
|
402
402
|
|
|
403
403
|
export type ControlNetStrenghtType = 'Low' | 'Mid' | 'High';
|
|
404
404
|
|
|
405
|
-
export type ControlNetPreprocessorId = 100 | 19;
|
|
405
|
+
export type ControlNetPreprocessorId = 100 | 19 | 133;
|
|
406
406
|
|
|
407
407
|
export type ControlNetConfig =
|
|
408
408
|
| {
|
|
@@ -416,6 +416,12 @@ export type ControlNetConfig =
|
|
|
416
416
|
initImageType: 'UPLOADED' | 'GENERATED';
|
|
417
417
|
preprocessorId: 19;
|
|
418
418
|
weight: number;
|
|
419
|
+
}
|
|
420
|
+
| {
|
|
421
|
+
initImageId: string;
|
|
422
|
+
initImageType: 'UPLOADED' | 'GENERATED';
|
|
423
|
+
preprocessorId: 133;
|
|
424
|
+
strengthType: ControlNetStrenghtType;
|
|
419
425
|
};
|
|
420
426
|
|
|
421
427
|
export type PlacementObject = {
|
|
@@ -545,13 +551,13 @@ export type ConceptProgress = {
|
|
|
545
551
|
};
|
|
546
552
|
|
|
547
553
|
export type UserConceptData = {
|
|
548
|
-
name: string;
|
|
549
|
-
description: string;
|
|
550
|
-
poem: any[];
|
|
551
|
-
content: any[];
|
|
554
|
+
name: string; // From conceptsData.name (text, notNull)
|
|
555
|
+
description: string; // From conceptsData.description (text, notNull)
|
|
556
|
+
poem: any[]; // From conceptsData.poem (text, defaults to '[]', but assuming parsed as string)
|
|
557
|
+
content: any[]; // From conceptsData.content (text, JSON-stringified array, parsed)
|
|
552
558
|
images: {
|
|
553
|
-
post: any[];
|
|
554
|
-
reel: any[];
|
|
559
|
+
post: any[]; // From conceptsData.postImages (text, JSON-stringified array, parsed)
|
|
560
|
+
reel: any[]; // From conceptsData.reelImages (text, JSON-stringified array, parsed)
|
|
555
561
|
};
|
|
556
562
|
combinationString: string; // e.g., "sagittarius-aquarius-libra"
|
|
557
563
|
conceptSlug: Concept;
|
|
@@ -578,4 +584,4 @@ export type UserProfile = {
|
|
|
578
584
|
oauthProvider: string | null;
|
|
579
585
|
creditsBalance: number;
|
|
580
586
|
language: string;
|
|
581
|
-
};
|
|
587
|
+
};
|