Skip to content

Commit

Permalink
fix: correct regex
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Nov 6, 2023
1 parent 3e0a880 commit 90761d8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugins/conversational-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export default class JanConversationalPlugin implements ConversationalPlugin {
* Called when the plugin is loaded.
*/
onLoad() {
console.debug("JanConversationalPlugin loaded")
console.debug("JanConversationalPlugin loaded");
fs.mkdir("conversations");
}

/**
* Called when the plugin is unloaded.
*/
onUnload() {
console.debug("JanConversationalPlugin unloaded")
console.debug("JanConversationalPlugin unloaded");
}

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ export default class JanConversationalPlugin implements ConversationalPlugin {
if (currentMessage)
currentMessage.message = trimmedLine.replace("- message:", "").trim();
} else if (trimmedLine.startsWith("- Message ")) {
const messageMatch = trimmedLine.match(/- Message (message-\d+):/);
const messageMatch = trimmedLine.match(/- Message (m-\d+):/);
if (messageMatch) {
if (currentMessage) {
conversation.messages.push(currentMessage);
Expand All @@ -137,11 +137,12 @@ export default class JanConversationalPlugin implements ConversationalPlugin {
currentMessage.message = currentMessage.message + "\n" + line.trim();
} else if (trimmedLine.startsWith("## Messages")) {
currentMessage = undefined;
} else {
console.log("missing field processing: ", trimmedLine);
}
}

if (currentMessage) {
conversation.messages.push(currentMessage);
}
return conversation;
}

Expand Down Expand Up @@ -203,7 +204,7 @@ export default class JanConversationalPlugin implements ConversationalPlugin {
private async writeMarkdownToFile(conversation: Conversation) {
// Generate the Markdown content
const markdownContent = this.generateMarkdown(conversation);
await fs.mkdir(`conversations/${conversation._id}`)
await fs.mkdir(`conversations/${conversation._id}`);
// Write the content to a Markdown file
await fs.writeFile(
`conversations/${conversation._id}/${conversation._id}.md`,
Expand Down

0 comments on commit 90761d8

Please sign in to comment.