@zodic/shared 0.0.294 → 0.0.295
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,8 @@ export class ArchetypeService {
|
|
|
286
287
|
|
|
287
288
|
async generateArchetypeNames(
|
|
288
289
|
combination: string,
|
|
289
|
-
gender: 'male' | 'female' | 'non-binary'
|
|
290
|
+
gender: 'male' | 'female' | 'non-binary',
|
|
291
|
+
overrideExisting: boolean = false
|
|
290
292
|
) {
|
|
291
293
|
const [sun, ascendant, moon] = combination.split('-') as ZodiacSignSlug[];
|
|
292
294
|
|
|
@@ -338,49 +340,184 @@ export class ArchetypeService {
|
|
|
338
340
|
await Promise.all(
|
|
339
341
|
englishNames.map(async (entry, i) => {
|
|
340
342
|
const index = (i + 1).toString();
|
|
341
|
-
await db
|
|
342
|
-
.
|
|
343
|
-
.
|
|
344
|
-
|
|
345
|
-
combination
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
343
|
+
const existingEntry = await db
|
|
344
|
+
.select({ id: schema.archetypesData.id })
|
|
345
|
+
.from(schema.archetypesData)
|
|
346
|
+
.where(
|
|
347
|
+
eq(schema.archetypesData.id, `${combination}:${gender}:${index}`)
|
|
348
|
+
)
|
|
349
|
+
.execute();
|
|
350
|
+
|
|
351
|
+
if (overrideExisting || existingEntry.length === 0) {
|
|
352
|
+
await db
|
|
353
|
+
.insert(schema.archetypesData)
|
|
354
|
+
.values({
|
|
355
|
+
id: `${combination}:${gender}:${index}`,
|
|
356
|
+
combination,
|
|
357
|
+
gender,
|
|
358
|
+
archetypeIndex: index,
|
|
359
|
+
language: 'en-us',
|
|
357
360
|
name: entry.name,
|
|
358
361
|
essenceLine: entry.essenceLine,
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
362
|
+
status: 'idle',
|
|
363
|
+
})
|
|
364
|
+
.onConflictDoUpdate({
|
|
365
|
+
target: [schema.archetypesData.id],
|
|
366
|
+
set: {
|
|
367
|
+
name: entry.name,
|
|
368
|
+
essenceLine: entry.essenceLine,
|
|
369
|
+
updatedAt: new Date().getTime(),
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const existingEntryPt = await db
|
|
375
|
+
.select({ id: schema.archetypesData.id })
|
|
376
|
+
.from(schema.archetypesData)
|
|
377
|
+
.where(
|
|
378
|
+
eq(schema.archetypesData.id, `${combination}:${gender}:${index}:pt`)
|
|
379
|
+
)
|
|
380
|
+
.execute();
|
|
381
|
+
|
|
382
|
+
if (overrideExisting || existingEntryPt.length === 0) {
|
|
383
|
+
await db
|
|
384
|
+
.insert(schema.archetypesData)
|
|
385
|
+
.values({
|
|
386
|
+
id: `${combination}:${gender}:${index}:pt`,
|
|
387
|
+
combination,
|
|
388
|
+
gender,
|
|
389
|
+
archetypeIndex: index,
|
|
390
|
+
language: 'pt-br',
|
|
378
391
|
name: portugueseVariants[i].masc,
|
|
379
392
|
essenceLine: portugueseVariants[i].essenceLine,
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
393
|
+
status: 'idle',
|
|
394
|
+
})
|
|
395
|
+
.onConflictDoUpdate({
|
|
396
|
+
target: [schema.archetypesData.id],
|
|
397
|
+
set: {
|
|
398
|
+
name: portugueseVariants[i].masc,
|
|
399
|
+
essenceLine: portugueseVariants[i].essenceLine,
|
|
400
|
+
updatedAt: new Date().getTime(),
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
}
|
|
383
404
|
})
|
|
384
405
|
);
|
|
385
406
|
}
|
|
407
|
+
|
|
408
|
+
async generateArchetypeNamesBatch(
|
|
409
|
+
entries: Array<{
|
|
410
|
+
combination: string;
|
|
411
|
+
gender: 'male' | 'female' | 'non-binary';
|
|
412
|
+
}>,
|
|
413
|
+
overrideExisting: boolean = false
|
|
414
|
+
) {
|
|
415
|
+
const prompts = entries.map(({ combination }) => {
|
|
416
|
+
const [sun, ascendant, moon] = combination.split('-') as ZodiacSignSlug[];
|
|
417
|
+
return { sun, ascendant, moon };
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
const prompt = generateArchetypePrompt(prompts);
|
|
421
|
+
const messages: ChatMessages = [{ role: 'user', content: prompt }];
|
|
422
|
+
const response = await this.context.api().callTogether.single(messages, {});
|
|
423
|
+
|
|
424
|
+
if (!response)
|
|
425
|
+
throw new Error('No response when generating batch archetype names');
|
|
426
|
+
|
|
427
|
+
const db = this.context.drizzle();
|
|
428
|
+
|
|
429
|
+
const blocks = response
|
|
430
|
+
.split(/Composition \d+/)
|
|
431
|
+
.slice(1)
|
|
432
|
+
.map((b) => b.trim());
|
|
433
|
+
|
|
434
|
+
for (let i = 0; i < entries.length; i++) {
|
|
435
|
+
const { combination, gender } = entries[i];
|
|
436
|
+
const block = blocks[i];
|
|
437
|
+
const en = block.split('-EN')[1].split('-PT')[0].trim();
|
|
438
|
+
const pt = block.split('-PT')[1].trim();
|
|
439
|
+
|
|
440
|
+
const english = en
|
|
441
|
+
.split(/\n\d\.\s*\n?/)
|
|
442
|
+
.filter(Boolean)
|
|
443
|
+
.map((line) => ({
|
|
444
|
+
name: line.match(/• Name:\s*(.+)/)?.[1]?.trim() || '',
|
|
445
|
+
essenceLine: line.match(/• Essence:\s*(.+)/)?.[1]?.trim() || '',
|
|
446
|
+
}));
|
|
447
|
+
|
|
448
|
+
const portuguese = pt
|
|
449
|
+
.split(/\n\d\.\s*\n?/)
|
|
450
|
+
.filter(Boolean)
|
|
451
|
+
.map((line) => ({
|
|
452
|
+
masc: line.match(/• Masculino:\s*(.+)/)?.[1]?.trim() || '',
|
|
453
|
+
essenceLine: line.match(/• Essência:\s*(.+)/)?.[1]?.trim() || '',
|
|
454
|
+
}));
|
|
455
|
+
|
|
456
|
+
for (let j = 0; j < 3; j++) {
|
|
457
|
+
const index = (j + 1).toString();
|
|
458
|
+
|
|
459
|
+
const existingEntry = await db
|
|
460
|
+
.select({ id: schema.archetypesData.id })
|
|
461
|
+
.from(schema.archetypesData)
|
|
462
|
+
.where(
|
|
463
|
+
eq(schema.archetypesData.id, `${combination}:${gender}:${index}`)
|
|
464
|
+
)
|
|
465
|
+
.execute();
|
|
466
|
+
|
|
467
|
+
if (overrideExisting || existingEntry.length === 0) {
|
|
468
|
+
await db
|
|
469
|
+
.insert(schema.archetypesData)
|
|
470
|
+
.values({
|
|
471
|
+
id: `${combination}:${gender}:${index}`,
|
|
472
|
+
combination,
|
|
473
|
+
gender,
|
|
474
|
+
archetypeIndex: index,
|
|
475
|
+
language: 'en-us',
|
|
476
|
+
name: english[j].name,
|
|
477
|
+
essenceLine: english[j].essenceLine,
|
|
478
|
+
status: 'idle',
|
|
479
|
+
})
|
|
480
|
+
.onConflictDoUpdate({
|
|
481
|
+
target: [schema.archetypesData.id],
|
|
482
|
+
set: {
|
|
483
|
+
name: english[j].name,
|
|
484
|
+
essenceLine: english[j].essenceLine,
|
|
485
|
+
updatedAt: new Date().getTime(),
|
|
486
|
+
},
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const existingEntryPt = await db
|
|
491
|
+
.select({ id: schema.archetypesData.id })
|
|
492
|
+
.from(schema.archetypesData)
|
|
493
|
+
.where(
|
|
494
|
+
eq(schema.archetypesData.id, `${combination}:${gender}:${index}:pt`)
|
|
495
|
+
)
|
|
496
|
+
.execute();
|
|
497
|
+
|
|
498
|
+
if (overrideExisting || existingEntryPt.length === 0) {
|
|
499
|
+
await db
|
|
500
|
+
.insert(schema.archetypesData)
|
|
501
|
+
.values({
|
|
502
|
+
id: `${combination}:${gender}:${index}:pt`,
|
|
503
|
+
combination,
|
|
504
|
+
gender,
|
|
505
|
+
archetypeIndex: index,
|
|
506
|
+
language: 'pt-br',
|
|
507
|
+
name: portuguese[j].masc,
|
|
508
|
+
essenceLine: portuguese[j].essenceLine,
|
|
509
|
+
status: 'idle',
|
|
510
|
+
})
|
|
511
|
+
.onConflictDoUpdate({
|
|
512
|
+
target: [schema.archetypesData.id],
|
|
513
|
+
set: {
|
|
514
|
+
name: portuguese[j].masc,
|
|
515
|
+
essenceLine: portuguese[j].essenceLine,
|
|
516
|
+
updatedAt: new Date().getTime(),
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
386
523
|
}
|
|
@@ -87,6 +87,33 @@ export class ArchetypeWorkflow {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
async generateNames({
|
|
91
|
+
combinations,
|
|
92
|
+
gender,
|
|
93
|
+
overrideExisting,
|
|
94
|
+
}: {
|
|
95
|
+
combinations: string[];
|
|
96
|
+
gender: Gender;
|
|
97
|
+
overrideExisting?: boolean;
|
|
98
|
+
}): Promise<void> {
|
|
99
|
+
if (combinations.length === 0) return;
|
|
100
|
+
|
|
101
|
+
if (combinations.length === 1) {
|
|
102
|
+
await this.archetypeService.generateArchetypeNames(
|
|
103
|
+
combinations[0],
|
|
104
|
+
gender,
|
|
105
|
+
overrideExisting
|
|
106
|
+
);
|
|
107
|
+
} else {
|
|
108
|
+
const entries = combinations.map((combination) => ({
|
|
109
|
+
combination,
|
|
110
|
+
gender,
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
await this.archetypeService.generateArchetypeNamesBatch(entries, overrideExisting);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
90
117
|
/**
|
|
91
118
|
* Fetch all three archetypes from KV for a given combination and gender.
|
|
92
119
|
*/
|
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
|
+
};
|