mirror of
https://github.com/binxly/Atomizer.git
synced 2026-07-22 11:30:28 +00:00
commit
bb96ce9792
2 changed files with 13 additions and 4 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import {
|
||||
App,
|
||||
Editor,
|
||||
MarkdownView,
|
||||
MarkdownFileInfo,
|
||||
|
|
@ -9,8 +8,8 @@ import {
|
|||
|
||||
import {
|
||||
AtomizerSettings,
|
||||
DEFAULT_SETTINGS,
|
||||
AtomizerSettingTab,
|
||||
DEFAULT_SETTINGS,
|
||||
} from "./settings";
|
||||
|
||||
import { OpenAIService } from "./openai-service";
|
||||
|
|
@ -89,9 +88,13 @@ export default class AtomizerPlugin extends Plugin {
|
|||
this.settings.outputFolder,
|
||||
);
|
||||
|
||||
// Get the source file name to include in the generated notes
|
||||
const sourceFileName = view.file?.basename || "Unknown Source";
|
||||
|
||||
const responseContent = await openAIService.generateAtomicNotes(
|
||||
content,
|
||||
getISOTimestamp(),
|
||||
sourceFileName,
|
||||
);
|
||||
if (!responseContent)
|
||||
throw new Error("No content received from OpenAI");
|
||||
|
|
|
|||
|
|
@ -15,10 +15,14 @@ export class OpenAIService {
|
|||
|
||||
/**
|
||||
* Generate atomic notes from content using OpenAI
|
||||
* @param content The content to process
|
||||
* @param timestamp ISO timestamp
|
||||
* @param sourceFilePath Path to the source file
|
||||
*/
|
||||
async generateAtomicNotes(
|
||||
content: string,
|
||||
timestamp: string,
|
||||
sourceFilePath: string,
|
||||
): Promise<string> {
|
||||
if (!this.apiKey) {
|
||||
new Notice(
|
||||
|
|
@ -40,7 +44,7 @@ export class OpenAIService {
|
|||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: this.getSystemPrompt(),
|
||||
content: this.getSystemPrompt(sourceFilePath),
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
|
|
@ -56,8 +60,9 @@ export class OpenAIService {
|
|||
|
||||
/**
|
||||
* Generate the system prompt for OpenAI
|
||||
* @param sourceFilePath Path to the source file for back-linking
|
||||
*/
|
||||
private getSystemPrompt(): string {
|
||||
private getSystemPrompt(sourceFilePath: string): string {
|
||||
return `You are an expert at creating atomic notes from a single, larger note.
|
||||
Take the content from a larger note and break it down into separate compact yet detailed atomic notes. Each note MUST be separated by placing '<<<>>>' on its own line between notes. Do not include an index or main note. Follow these rules:
|
||||
1. Each note should contain exactly one clear idea. This can contain multiple lines.
|
||||
|
|
@ -65,6 +70,7 @@ export class OpenAIService {
|
|||
---
|
||||
date: "${getFormattedDateTime()}"
|
||||
tags: ${this.settings.enableAtomizedTag ? "atomized" : ""}${this.settings.customTags ? (this.settings.enableAtomizedTag ? ", " : "") + this.settings.customTags : ""}
|
||||
source: "[[${sourceFilePath}]]"
|
||||
---
|
||||
3. You MUST separate each note by placing '<<<>>>' on its own line between notes
|
||||
4. After the frontmatter, each note must start with a level 1 heading (# Title)
|
||||
|
|
|
|||
Loading…
Reference in a new issue