@zodic/shared 0.0.374 → 0.0.376
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.
|
@@ -29,7 +29,6 @@ export class ArchetypeService {
|
|
|
29
29
|
context: Record<string, any> = {}
|
|
30
30
|
) {
|
|
31
31
|
const logMessage = `[${new Date().toISOString()}] [${level.toUpperCase()}] ${message}`;
|
|
32
|
-
|
|
33
32
|
console[level](logMessage, context);
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -775,9 +774,7 @@ export class ArchetypeService {
|
|
|
775
774
|
await this.log(
|
|
776
775
|
'debug',
|
|
777
776
|
`Generating content for archetype ${index} (${g})`,
|
|
778
|
-
{
|
|
779
|
-
name: archetype.name,
|
|
780
|
-
}
|
|
777
|
+
{ name: archetype.name }
|
|
781
778
|
);
|
|
782
779
|
const contentMessages = this.context
|
|
783
780
|
.buildLLMMessages()
|
|
@@ -790,9 +787,7 @@ export class ArchetypeService {
|
|
|
790
787
|
await this.log(
|
|
791
788
|
'debug',
|
|
792
789
|
`Calling API for content of archetype ${index} (${g})`,
|
|
793
|
-
{
|
|
794
|
-
messages: contentMessages,
|
|
795
|
-
}
|
|
790
|
+
{ messages: contentMessages }
|
|
796
791
|
);
|
|
797
792
|
const contentResponse = await this.context
|
|
798
793
|
.api()
|
|
@@ -815,6 +810,7 @@ export class ArchetypeService {
|
|
|
815
810
|
`Received content response for archetype ${index} (${g})`,
|
|
816
811
|
{
|
|
817
812
|
responseLength: contentResponse.length,
|
|
813
|
+
rawResponse: contentResponse, // Log raw response for debugging
|
|
818
814
|
}
|
|
819
815
|
);
|
|
820
816
|
|
|
@@ -924,13 +920,14 @@ export class ArchetypeService {
|
|
|
924
920
|
|
|
925
921
|
const expectedHeader =
|
|
926
922
|
sectionIndex === 0 ? 'EN:' : sectionIndex === 1 ? 'PT-M:' : 'PT-F:';
|
|
927
|
-
|
|
923
|
+
const actualHeader = lines[0].trim(); // Trim the header to remove trailing spaces
|
|
924
|
+
if (actualHeader !== expectedHeader) {
|
|
928
925
|
this.log(
|
|
929
926
|
'error',
|
|
930
927
|
`Invalid language header in section ${sectionIndex + 1}`,
|
|
931
928
|
{
|
|
932
929
|
expected: expectedHeader,
|
|
933
|
-
found:
|
|
930
|
+
found: actualHeader,
|
|
934
931
|
}
|
|
935
932
|
);
|
|
936
933
|
throw new Error(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { and, eq } from 'drizzle-orm';
|
|
1
2
|
import { inject, injectable } from 'inversify';
|
|
2
|
-
import { AppContext } from '../base';
|
|
3
|
-
import { Gender, Languages } from '../../types';
|
|
4
3
|
import { ArchetypeService, LeonardoService, schema } from '../..';
|
|
5
|
-
import {
|
|
4
|
+
import { Gender, Languages } from '../../types';
|
|
5
|
+
import { AppContext } from '../base';
|
|
6
6
|
|
|
7
7
|
@injectable()
|
|
8
8
|
export class ArchetypeWorkflow {
|
|
@@ -38,8 +38,17 @@ export class ArchetypeWorkflow {
|
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
40
|
// Step 1: Generate archetype names for both genders
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if (override) {
|
|
42
|
+
await this.log('debug', 'Generating archetype names', {
|
|
43
|
+
combinationString,
|
|
44
|
+
override,
|
|
45
|
+
userId,
|
|
46
|
+
});
|
|
47
|
+
await this.archetypeService.generateArchetypeNames(
|
|
48
|
+
combinationString,
|
|
49
|
+
override
|
|
50
|
+
);
|
|
51
|
+
}
|
|
43
52
|
|
|
44
53
|
// Step 2: Generate descriptions and virtues for both genders
|
|
45
54
|
await this.log('debug', 'Generating descriptions and virtues', {
|
|
@@ -49,12 +58,13 @@ export class ArchetypeWorkflow {
|
|
|
49
58
|
override,
|
|
50
59
|
userId,
|
|
51
60
|
});
|
|
52
|
-
const descriptions =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
const descriptions =
|
|
62
|
+
await this.archetypeService.generateDescriptionsAndVirtues(
|
|
63
|
+
combinationString,
|
|
64
|
+
gender, // Service processes both genders internally
|
|
65
|
+
language,
|
|
66
|
+
override
|
|
67
|
+
);
|
|
58
68
|
|
|
59
69
|
// Step 3: Generate content for both genders
|
|
60
70
|
await this.log('debug', 'Generating content', {
|
|
@@ -102,50 +112,70 @@ export class ArchetypeWorkflow {
|
|
|
102
112
|
);
|
|
103
113
|
|
|
104
114
|
if (archetypes.length !== 3) {
|
|
105
|
-
await this.log(
|
|
106
|
-
|
|
107
|
-
gender,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
await this.log(
|
|
116
|
+
'error',
|
|
117
|
+
`Expected 3 archetypes for ${gender}, found ${archetypes.length}`,
|
|
118
|
+
{
|
|
119
|
+
combinationString,
|
|
120
|
+
gender,
|
|
121
|
+
language,
|
|
122
|
+
userId,
|
|
123
|
+
}
|
|
124
|
+
);
|
|
111
125
|
throw new Error(
|
|
112
126
|
`Expected 3 archetypes for combination ${combinationString}, gender ${gender}, language ${language}, but found ${archetypes.length}`
|
|
113
127
|
);
|
|
114
128
|
}
|
|
115
129
|
|
|
116
130
|
// Step 6: Process image generation only for the requested gender
|
|
117
|
-
await this.log(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
await this.log(
|
|
132
|
+
'info',
|
|
133
|
+
`Processing image generation for gender ${gender}`,
|
|
134
|
+
{
|
|
135
|
+
archetypeIds: archetypes.map((a) => a.id),
|
|
136
|
+
archetypeIndexes: archetypes.map((a) => a.archetypeIndex),
|
|
137
|
+
userId,
|
|
138
|
+
}
|
|
139
|
+
);
|
|
122
140
|
for (const archetype of archetypes) {
|
|
123
141
|
if (!archetype.leonardoPrompt) {
|
|
124
|
-
await this.log(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
await this.log(
|
|
143
|
+
'warn',
|
|
144
|
+
`No Leonardo prompt for archetype ${archetype.id}`,
|
|
145
|
+
{
|
|
146
|
+
archetypeIndex: archetype.archetypeIndex,
|
|
147
|
+
gender,
|
|
148
|
+
language,
|
|
149
|
+
userId,
|
|
150
|
+
}
|
|
151
|
+
);
|
|
130
152
|
continue;
|
|
131
153
|
}
|
|
132
154
|
|
|
133
155
|
if (override || !archetype.images || archetype.images === '[]') {
|
|
134
|
-
await this.log(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
156
|
+
await this.log(
|
|
157
|
+
'debug',
|
|
158
|
+
`Queueing image generation for archetype ${archetype.id}`,
|
|
159
|
+
{
|
|
160
|
+
archetypeIndex: archetype.archetypeIndex,
|
|
161
|
+
gender,
|
|
162
|
+
language,
|
|
163
|
+
userId,
|
|
164
|
+
}
|
|
165
|
+
);
|
|
140
166
|
await this.leonardoService.processArchetypePopulation(archetype.id);
|
|
141
167
|
} else {
|
|
142
|
-
await this.log(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
168
|
+
await this.log(
|
|
169
|
+
'debug',
|
|
170
|
+
`Skipping image generation for archetype ${archetype.id}`,
|
|
171
|
+
{
|
|
172
|
+
reason: 'Images already exist and override is false',
|
|
173
|
+
archetypeIndex: archetype.archetypeIndex,
|
|
174
|
+
gender,
|
|
175
|
+
language,
|
|
176
|
+
userId,
|
|
177
|
+
}
|
|
178
|
+
);
|
|
149
179
|
}
|
|
150
180
|
}
|
|
151
181
|
|
|
@@ -163,13 +193,17 @@ export class ArchetypeWorkflow {
|
|
|
163
193
|
const images = archetype.images ? JSON.parse(archetype.images) : [];
|
|
164
194
|
imageCount = Array.isArray(images) ? images.length : 0;
|
|
165
195
|
} catch (error) {
|
|
166
|
-
await this.log(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
196
|
+
await this.log(
|
|
197
|
+
'warn',
|
|
198
|
+
`Failed to parse images for archetype ${archetype.id}`,
|
|
199
|
+
{
|
|
200
|
+
archetypeIndex: archetype.archetypeIndex,
|
|
201
|
+
gender,
|
|
202
|
+
language,
|
|
203
|
+
userId,
|
|
204
|
+
error: error instanceof Error ? error.message : String(error),
|
|
205
|
+
}
|
|
206
|
+
);
|
|
173
207
|
continue;
|
|
174
208
|
}
|
|
175
209
|
|
|
@@ -185,24 +219,35 @@ export class ArchetypeWorkflow {
|
|
|
185
219
|
eq(schema.archetypesData.id, archetype.id),
|
|
186
220
|
eq(schema.archetypesData.gender, gender),
|
|
187
221
|
eq(schema.archetypesData.language, language),
|
|
188
|
-
eq(
|
|
222
|
+
eq(
|
|
223
|
+
schema.archetypesData.archetypeIndex,
|
|
224
|
+
archetype.archetypeIndex
|
|
225
|
+
)
|
|
189
226
|
)
|
|
190
227
|
);
|
|
191
|
-
await this.log(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
228
|
+
await this.log(
|
|
229
|
+
'info',
|
|
230
|
+
`Updated status to 'completed' for archetype ${archetype.id}`,
|
|
231
|
+
{
|
|
232
|
+
archetypeIndex: archetype.archetypeIndex,
|
|
233
|
+
gender,
|
|
234
|
+
language,
|
|
235
|
+
imageCount,
|
|
236
|
+
userId,
|
|
237
|
+
}
|
|
238
|
+
);
|
|
198
239
|
} else {
|
|
199
|
-
await this.log(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
240
|
+
await this.log(
|
|
241
|
+
'debug',
|
|
242
|
+
`Skipping status update for archetype ${archetype.id}`,
|
|
243
|
+
{
|
|
244
|
+
reason: `Fewer than 3 images (found ${imageCount})`,
|
|
245
|
+
archetypeIndex: archetype.archetypeIndex,
|
|
246
|
+
gender,
|
|
247
|
+
language,
|
|
248
|
+
userId,
|
|
249
|
+
}
|
|
250
|
+
);
|
|
206
251
|
}
|
|
207
252
|
}
|
|
208
253
|
|
|
@@ -223,4 +268,4 @@ export class ArchetypeWorkflow {
|
|
|
223
268
|
throw error;
|
|
224
269
|
}
|
|
225
270
|
}
|
|
226
|
-
}
|
|
271
|
+
}
|
package/package.json
CHANGED
package/utils/buildMessages.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const buildLLMMessages = (env: BackendBindings) => ({
|
|
|
25
25
|
content: `
|
|
26
26
|
You are a gifted fantasy writer and astrologer. Your task is to write mystical **narrative descriptions** and **core virtues** for three archetypes, based on their names, essence lines, and astrological combination.
|
|
27
27
|
|
|
28
|
-
Each archetype is influenced by the zodiac combination (Sun, Ascendant, Moon), and each one emphasizes one of those signs respectively.
|
|
28
|
+
Each archetype is influenced by the zodiac combination (Sun, Ascendant, Moon), and each one emphasizes one of those signs respectively. The signs and the archetype name should not be mentioned in the description. Use only their abstract representation and symbolism.
|
|
29
29
|
|
|
30
30
|
Please provide:
|
|
31
31
|
|