in src/main.ts [814:856]
messageId: generateUID(),
});
this.chatWrappers[tabId].updateLastChatAnswer(updateWith);
}
}
};
/**
* Updates the chat item with the given messageId
* @param tabId Corresponding tab ID.
* @param messageId Corresponding tab ID.
* @param updateWith ChatItem object to update with.
*/
public updateChatAnswerWithMessageId = (tabId: string, messageId: string, updateWith: Partial<ChatItem>): void => {
if (MynahUITabsStore.getInstance().getTab(tabId) !== null) {
this.chatWrappers[tabId].updateChatAnswerWithMessageId(messageId, updateWith);
}
};
/**
* Serialize all (non-empty) chat messages in a tab into a string
* @param tabId Corresponding tab ID.
* @param format Whether to serialize to markdown or HTML format
*/
public serializeChat = (tabId: string, format: 'markdown' | 'html'): string => {
if (format === 'markdown') {
return serializeMarkdown(tabId);
}
return serializeHtml(tabId);
};
/**
* Converts a card to an ANSWER if it is an ANSWER_STREAM
* @param tabId Corresponding tab ID.
* @param messageId Corresponding tab ID.
* @param updateWith Optional, if you like update the card while converting it to
* a normal ANSWER instead of a stream one, you can send a ChatItem object to update with.
*/
public endMessageStream = (tabId: string, messageId: string, updateWith?: Partial<ChatItem>): CardRenderDetails => {
if (MynahUITabsStore.getInstance().getTab(tabId) !== null) {
const chatMessage = this.chatWrappers[tabId].getChatItem(messageId);
if (chatMessage != null && ![ ChatItemType.AI_PROMPT, ChatItemType.PROMPT, ChatItemType.SYSTEM_PROMPT ].includes(chatMessage.chatItem.type)) {
this.chatWrappers[tabId].endStreamWithMessageId(messageId, {