Andrew commited on
Commit
6600478
·
1 Parent(s): f1c76dc

fix(server): send persona initialization to establish order before streaming

Browse files
src/lib/server/textGeneration/multiPersona.ts CHANGED
@@ -31,9 +31,6 @@ export async function* multiPersonaTextGeneration(
31
  return;
32
  }
33
 
34
- // Single persona now uses the same flow as multiple personas for consistency
35
- // This ensures all responses have the same personaResponses structure
36
-
37
  const { conv, messages } = ctx;
38
  const convId = conv._id;
39
 
@@ -43,6 +40,17 @@ export async function* multiPersonaTextGeneration(
43
  status: MessageUpdateStatus.Started,
44
  };
45
 
 
 
 
 
 
 
 
 
 
 
 
46
  // Preprocess messages ONCE for all personas (performance optimization)
47
  // This downloads files and prepares messages for the model
48
  const preprocessedMessages = await preprocessMessages(messages, convId);
 
31
  return;
32
  }
33
 
 
 
 
34
  const { conv, messages } = ctx;
35
  const convId = conv._id;
36
 
 
40
  status: MessageUpdateStatus.Started,
41
  };
42
 
43
+ // Send persona initialization to establish order before streaming
44
+ yield {
45
+ type: MessageUpdateType.PersonaInit,
46
+ personas: personas.map((p) => ({
47
+ personaId: p.id,
48
+ personaName: p.name,
49
+ personaOccupation: p.jobSector,
50
+ personaStance: p.stance,
51
+ })),
52
+ };
53
+
54
  // Preprocess messages ONCE for all personas (performance optimization)
55
  // This downloads files and prepares messages for the model
56
  const preprocessedMessages = await preprocessMessages(messages, convId);