mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
MP: cleanup conversions
This commit is contained in:
@@ -16,17 +16,17 @@ export interface DConversation {
|
||||
userTitle?: string;
|
||||
autoTitle?: string;
|
||||
|
||||
// TODO: @deprecated - this should be the system purpose of current head of the conversation
|
||||
// TODO: [x Head] - this should be the system purpose of current head of the conversation
|
||||
// there should be the concept of the audience of the current head
|
||||
systemPurposeId: SystemPurposeId; // system purpose of this conversation
|
||||
|
||||
// TODO: @deprecated - should be a view-related cache
|
||||
tokenCount: number; // f(messages, llmId)
|
||||
|
||||
// when updated is null, we don't have messages yet (timestamps as Date.now())
|
||||
created: number; // creation timestamp
|
||||
updated: number | null; // last update timestamp
|
||||
|
||||
// TODO: @deprecated - should be a view-related cache
|
||||
tokenCount: number; // f(messages, llmId)
|
||||
|
||||
// Not persisted, used while in-memory, or temporarily by the UI
|
||||
// TODO: @deprecated - shouls not be in here - it's actually a per-message/operation thing
|
||||
abortController: AbortController | null;
|
||||
@@ -101,7 +101,8 @@ export function duplicateCConversation(conversation: DConversation, lastMessageI
|
||||
// helpers - conversion
|
||||
|
||||
export function convertCConversation_V3_V4(conversation: DConversation) {
|
||||
conversation.messages.forEach(message => convertDMessage_V3_V4(message));
|
||||
// .messages
|
||||
conversation.messages.forEach(convertDMessage_V3_V4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,11 +153,19 @@ export function duplicateDMessage(message: DMessage): DMessage {
|
||||
// helpers - conversion
|
||||
|
||||
export function convertDMessage_V3_V4(message: DMessage) {
|
||||
const v3 = message as DMessage & { text: string };
|
||||
if (!message.content || message.content.length === 0) {
|
||||
message.content = [createTextPart(v3.text || '')];
|
||||
delete (v3 as any).text;
|
||||
|
||||
// .content
|
||||
if (!message.content || !Array.isArray(message.content)) {
|
||||
|
||||
// v3.text -> v4.content
|
||||
message.content = [
|
||||
createTextPart((message as any).text || ''),
|
||||
];
|
||||
delete (message as any).text;
|
||||
|
||||
}
|
||||
|
||||
// .userAttachments
|
||||
if (!message.userAttachments?.length)
|
||||
message.userAttachments = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user