Spaces:
Sleeping
Sleeping
Andrew
commited on
Commit
·
6494a78
1
Parent(s):
4d5e4f9
refactor(types): update Message and MessageUpdate types for branching support
Browse files- src/lib/types/Message.ts +16 -2
- src/lib/types/MessageUpdate.ts +20 -7
src/lib/types/Message.ts
CHANGED
|
@@ -20,8 +20,16 @@ export type PersonaResponse = {
|
|
| 20 |
currentChildIndex?: number;
|
| 21 |
};
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
export type Message = Partial<Timestamps> & {
|
| 24 |
-
from:
|
| 25 |
id: ReturnType<typeof v4>;
|
| 26 |
content: string;
|
| 27 |
updates?: MessageUpdate[];
|
|
@@ -41,9 +49,15 @@ export type Message = Partial<Timestamps> & {
|
|
| 41 |
model: string;
|
| 42 |
};
|
| 43 |
|
| 44 |
-
// Multi-persona responses
|
| 45 |
personaResponses?: PersonaResponse[];
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
// needed for conversation trees
|
| 48 |
ancestors?: Message["id"][];
|
| 49 |
|
|
|
|
| 20 |
currentChildIndex?: number;
|
| 21 |
};
|
| 22 |
|
| 23 |
+
export const MessageRole = {
|
| 24 |
+
User: "user",
|
| 25 |
+
Assistant: "assistant",
|
| 26 |
+
System: "system",
|
| 27 |
+
} as const;
|
| 28 |
+
|
| 29 |
+
export type MessageRole = (typeof MessageRole)[keyof typeof MessageRole];
|
| 30 |
+
|
| 31 |
export type Message = Partial<Timestamps> & {
|
| 32 |
+
from: MessageRole;
|
| 33 |
id: ReturnType<typeof v4>;
|
| 34 |
content: string;
|
| 35 |
updates?: MessageUpdate[];
|
|
|
|
| 49 |
model: string;
|
| 50 |
};
|
| 51 |
|
| 52 |
+
// Multi-persona responses
|
| 53 |
personaResponses?: PersonaResponse[];
|
| 54 |
|
| 55 |
+
// Branch metadata
|
| 56 |
+
branchedFrom?: {
|
| 57 |
+
messageId: Message["id"];
|
| 58 |
+
personaId: string;
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
// needed for conversation trees
|
| 62 |
ancestors?: Message["id"][];
|
| 63 |
|
src/lib/types/MessageUpdate.ts
CHANGED
|
@@ -6,7 +6,8 @@ export type MessageUpdate =
|
|
| 6 |
| MessageFinalAnswerUpdate
|
| 7 |
| MessageReasoningUpdate
|
| 8 |
| MessageRouterMetadataUpdate
|
| 9 |
-
| MessagePersonaUpdate
|
|
|
|
| 10 |
|
| 11 |
export enum MessageUpdateType {
|
| 12 |
Status = "status",
|
|
@@ -17,6 +18,7 @@ export enum MessageUpdateType {
|
|
| 17 |
Reasoning = "reasoning",
|
| 18 |
RouterMetadata = "routerMetadata",
|
| 19 |
Persona = "persona",
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
// Status
|
|
@@ -93,11 +95,22 @@ export interface MessagePersonaUpdate {
|
|
| 93 |
personaOccupation?: string;
|
| 94 |
personaStance?: string;
|
| 95 |
updateType: PersonaUpdateType;
|
| 96 |
-
token?: string;
|
| 97 |
-
text?: string;
|
| 98 |
interrupted?: boolean;
|
| 99 |
-
status?: string;
|
| 100 |
-
route?: string;
|
| 101 |
-
model?: string;
|
| 102 |
-
error?: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
}
|
|
|
|
| 6 |
| MessageFinalAnswerUpdate
|
| 7 |
| MessageReasoningUpdate
|
| 8 |
| MessageRouterMetadataUpdate
|
| 9 |
+
| MessagePersonaUpdate
|
| 10 |
+
| MessagePersonaInitUpdate;
|
| 11 |
|
| 12 |
export enum MessageUpdateType {
|
| 13 |
Status = "status",
|
|
|
|
| 18 |
Reasoning = "reasoning",
|
| 19 |
RouterMetadata = "routerMetadata",
|
| 20 |
Persona = "persona",
|
| 21 |
+
PersonaInit = "personaInit",
|
| 22 |
}
|
| 23 |
|
| 24 |
// Status
|
|
|
|
| 95 |
personaOccupation?: string;
|
| 96 |
personaStance?: string;
|
| 97 |
updateType: PersonaUpdateType;
|
| 98 |
+
token?: string;
|
| 99 |
+
text?: string;
|
| 100 |
interrupted?: boolean;
|
| 101 |
+
status?: string;
|
| 102 |
+
route?: string;
|
| 103 |
+
model?: string;
|
| 104 |
+
error?: string;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
// Persona initialization - sent before streaming to establish order
|
| 108 |
+
export interface MessagePersonaInitUpdate {
|
| 109 |
+
type: MessageUpdateType.PersonaInit;
|
| 110 |
+
personas: Array<{
|
| 111 |
+
personaId: string;
|
| 112 |
+
personaName: string;
|
| 113 |
+
personaOccupation?: string;
|
| 114 |
+
personaStance?: string;
|
| 115 |
+
}>;
|
| 116 |
}
|