Update formating for response + fixed cutoff bug for mermaid charts

This commit is contained in:
Mossy1022 2024-06-25 13:04:37 -04:00
parent d2c4b9d477
commit 80edaf455f
2 changed files with 18 additions and 7 deletions

21
main.ts
View file

@ -199,20 +199,27 @@ export default class SmartMemosPlugin extends Plugin {
let LnToWrite = this.getNextNewLine(editor, currentLn);
let lastLine = LnToWrite;
const mock_env = {
chunk_handler: (chunk: string) => {
editor.setLine(LnToWrite, editor.getLine(LnToWrite) + chunk);
if(chunk.includes('\n')){
LnToWrite = this.getNextNewLine(editor, LnToWrite);
}
// Split the chunk by new line character
const lines = chunk.split('\n');
lines.forEach((line, index) => {
if (index > 0) {
LnToWrite = this.getNextNewLine(editor, LnToWrite);
LnToWrite++; // We want to add an extra break for each new line
}
editor.setLine(LnToWrite, editor.getLine(LnToWrite) + line);
});
},
done_handler: (final_resp: string) => {
LnToWrite = this.getNextNewLine(editor, lastLine);
if(this.settings.includeTranscript) {
editor.setLine(LnToWrite, editor.getLine(LnToWrite) + '\n# Transcript\n' + this.transcript);
if (this.settings.includeTranscript) {
LnToWrite = this.getNextNewLine(editor, LnToWrite);
editor.setLine(LnToWrite++, '# Transcript\n\n' + this.transcript);
}
}
};
const smart_chat_model = new SmartChatModel(
mock_env,
"openai",

View file

@ -6,6 +6,10 @@ available in the app when your plugin is enabled.
If your plugin does not need CSS, delete this file.
*/
.mermaid svg {
width: 100%;
height: auto;
}
.text-box {
width: 350px;