@zodic/shared 0.0.142 → 0.0.143
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.
|
@@ -4,7 +4,7 @@ import 'reflect-metadata';
|
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
import { schema } from '../..';
|
|
6
6
|
import { Concept, ControlNetConfig, Languages } from '../../types';
|
|
7
|
-
import { KVConcept, sizes } from '../../types/scopes/legacy';
|
|
7
|
+
import { KVConcept, sizes, StructuredConceptContent } from '../../types/scopes/legacy';
|
|
8
8
|
import { leonardoInitImages } from '../../utils/initImages';
|
|
9
9
|
import { buildConceptKVKey } from '../../utils/KVKeysBuilders';
|
|
10
10
|
import { AppContext } from '../base/AppContext';
|
|
@@ -267,15 +267,20 @@ export class ConceptService {
|
|
|
267
267
|
|
|
268
268
|
phase = "parsing"; // ✅ Switch to parsing phase
|
|
269
269
|
|
|
270
|
-
// ✅
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
// ✅ Parse structured content for both languages
|
|
271
|
+
const { structuredContentEN, structuredContentPT } =
|
|
272
|
+
this.parseStructuredContent(response);
|
|
273
273
|
|
|
274
|
+
// 🌍 Store English content
|
|
275
|
+
Object.assign(conceptEN, { content: structuredContentEN });
|
|
274
276
|
await kvStore.put(kvKeyEN, JSON.stringify(conceptEN));
|
|
277
|
+
|
|
278
|
+
// 🇧🇷 Store Portuguese content
|
|
279
|
+
Object.assign(conceptPT, { content: structuredContentPT });
|
|
275
280
|
await kvStore.put(kvKeyPT, JSON.stringify(conceptPT));
|
|
276
281
|
|
|
277
282
|
console.log(
|
|
278
|
-
`✅
|
|
283
|
+
`✅ Structured content stored for ${conceptSlug}, combination: ${combinationString}, in both languages.`
|
|
279
284
|
);
|
|
280
285
|
return; // ✅ Exit loop if successful
|
|
281
286
|
|
|
@@ -303,6 +308,61 @@ export class ConceptService {
|
|
|
303
308
|
}
|
|
304
309
|
}
|
|
305
310
|
|
|
311
|
+
private parseStructuredContent(response: string): {
|
|
312
|
+
structuredContentEN: StructuredConceptContent;
|
|
313
|
+
structuredContentPT: StructuredConceptContent;
|
|
314
|
+
} {
|
|
315
|
+
console.log('📌 Parsing structured content from ChatGPT response:', response);
|
|
316
|
+
|
|
317
|
+
const sections = [
|
|
318
|
+
"Core Identity",
|
|
319
|
+
"Strengths and Challenges",
|
|
320
|
+
"Path to Fulfillment",
|
|
321
|
+
"Emotional Depth",
|
|
322
|
+
"Vision and Aspirations"
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
const sectionsPT = [
|
|
326
|
+
"Identidade Essencial",
|
|
327
|
+
"Forças e Desafios",
|
|
328
|
+
"Caminho para a Plenitude",
|
|
329
|
+
"Profundidade Emocional",
|
|
330
|
+
"Visão e Aspirações"
|
|
331
|
+
];
|
|
332
|
+
|
|
333
|
+
// ✅ Match English and Portuguese content separately
|
|
334
|
+
const enMatches = response.match(/EN:\s*([\s\S]+?)\s*PT:/);
|
|
335
|
+
const ptMatches = response.match(/PT:\s*([\s\S]+)/);
|
|
336
|
+
|
|
337
|
+
if (!enMatches || !ptMatches) {
|
|
338
|
+
throw new Error("❌ Missing English or Portuguese content in response.");
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const enContent = enMatches[1].trim();
|
|
342
|
+
const ptContent = ptMatches[1].trim();
|
|
343
|
+
|
|
344
|
+
function extractSections(text: string, sectionTitles: string[]) {
|
|
345
|
+
return sectionTitles.map((title) => {
|
|
346
|
+
const regex = new RegExp(`${title}:\\s*([\\s\\S]+?)(?=\\n\\d|$)`);
|
|
347
|
+
const match = text.match(regex);
|
|
348
|
+
|
|
349
|
+
if (!match) {
|
|
350
|
+
return { type: "section", title, content: ["❌ Section Missing"] };
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// ✅ Split content into paragraphs
|
|
354
|
+
const paragraphs = match[1].trim().split(/\n\n+/).map((p) => p.trim());
|
|
355
|
+
|
|
356
|
+
return { type: "section", title, content: paragraphs };
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return {
|
|
361
|
+
structuredContentEN: extractSections(enContent, sections),
|
|
362
|
+
structuredContentPT: extractSections(ptContent, sectionsPT),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
306
366
|
/**
|
|
307
367
|
* Queue image generation for a concept.
|
|
308
368
|
*/
|
|
@@ -470,7 +530,7 @@ export class ConceptService {
|
|
|
470
530
|
return {
|
|
471
531
|
name: '',
|
|
472
532
|
description: '',
|
|
473
|
-
content:
|
|
533
|
+
content: [],
|
|
474
534
|
poem: '',
|
|
475
535
|
leonardoPrompt: '',
|
|
476
536
|
postImages: [],
|
|
@@ -9,7 +9,8 @@ export class ConceptWorkflow {
|
|
|
9
9
|
async processSingle(
|
|
10
10
|
conceptSlug: Concept,
|
|
11
11
|
combinationString: string,
|
|
12
|
-
phase: ConceptPhase
|
|
12
|
+
phase: ConceptPhase,
|
|
13
|
+
override?: boolean
|
|
13
14
|
) {
|
|
14
15
|
console.log(
|
|
15
16
|
`Processing single concept for slug: ${conceptSlug}, combination: ${combinationString}, phase: ${phase}`
|
|
@@ -20,13 +21,15 @@ export class ConceptWorkflow {
|
|
|
20
21
|
case 'basic-info':
|
|
21
22
|
await this.conceptService.generateBasicInfo(
|
|
22
23
|
conceptSlug,
|
|
23
|
-
combinationString
|
|
24
|
+
combinationString,
|
|
25
|
+
override
|
|
24
26
|
);
|
|
25
27
|
break;
|
|
26
28
|
case 'content':
|
|
27
29
|
await this.conceptService.generateContent(
|
|
28
30
|
conceptSlug,
|
|
29
|
-
combinationString
|
|
31
|
+
combinationString,
|
|
32
|
+
override
|
|
30
33
|
);
|
|
31
34
|
break;
|
|
32
35
|
case 'leonardo-prompt':
|
package/package.json
CHANGED
package/types/scopes/legacy.ts
CHANGED
|
@@ -109,7 +109,7 @@ export type KVArchetype = {
|
|
|
109
109
|
export type KVConcept = {
|
|
110
110
|
name: string;
|
|
111
111
|
description: string;
|
|
112
|
-
content:
|
|
112
|
+
content: StructuredConceptContent; // ✅ Structured content
|
|
113
113
|
poem: string;
|
|
114
114
|
leonardoPrompt: string;
|
|
115
115
|
postImages: LeonardoImage[]; // Pre-generated in sequence
|
|
@@ -117,6 +117,12 @@ export type KVConcept = {
|
|
|
117
117
|
status: 'idle' | 'generating' | 'completed';
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
+
export type StructuredConceptContent = {
|
|
121
|
+
type: string;
|
|
122
|
+
title: string;
|
|
123
|
+
content: string[];
|
|
124
|
+
}[];
|
|
125
|
+
|
|
120
126
|
export type KVGenerationObject = {
|
|
121
127
|
crown: string;
|
|
122
128
|
gender: Gender;
|