mirror of
https://github.com/benstuart0/on-this-day-i-obsidian.git
synced 2026-07-22 05:38:19 +00:00
Add output length sentences setting
This commit is contained in:
parent
d5ed016897
commit
173e2f62c0
4 changed files with 33 additions and 5 deletions
3
main.ts
3
main.ts
|
|
@ -132,7 +132,8 @@ export default class OnThisDayPlugin extends Plugin {
|
|||
|
||||
const prompt = constructPrompt(
|
||||
yearToContent,
|
||||
this.settings.customPrompt
|
||||
this.settings.customPrompt,
|
||||
this.settings.outputLengthSentences
|
||||
);
|
||||
|
||||
// Show a loading indicator (persistent notice) until work is done.
|
||||
|
|
|
|||
|
|
@ -141,6 +141,27 @@ export default class OnThisDaySettingTab extends PluginSettingTab {
|
|||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Output Length (Sentences)")
|
||||
.setDesc(
|
||||
"Select how many sentences should each year's response be (between 1 and 8)."
|
||||
)
|
||||
.addDropdown((dropdown) => {
|
||||
// Populate the dropdown with options 1 through 8.
|
||||
for (let i = 1; i <= 8; i++) {
|
||||
dropdown.addOption(i.toString(), i.toString());
|
||||
}
|
||||
// Set the current value from settings; default to 3 if not set.
|
||||
const currentValue =
|
||||
this.plugin.settings.outputLengthSentences || 3;
|
||||
dropdown.setValue(currentValue.toString());
|
||||
dropdown.onChange(async (value: string) => {
|
||||
this.plugin.settings.outputLengthSentences =
|
||||
parseInt(value);
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
containerEl.createEl("h2", { text: "OpenAI Settings" });
|
||||
new Setting(containerEl)
|
||||
.setName("Model Version")
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
const userPrompt = `Below is a JSON object where each key is a year and each value is the full
|
||||
content of my daily journal for this day on that given year. For each year,
|
||||
please provide an interesting summary in 2-3 sentences that highlights the events
|
||||
of that day. Try to include who I spent time with (including their names), what I did,
|
||||
please provide an interesting summary that highlights the events
|
||||
of that day. The summary length for each year's summary should be the number of sentences defined at the end of this prompt.
|
||||
Try to include who I spent time with (including their names), what I did,
|
||||
and how I felt. Use second-person language (you), as you are referring to me -
|
||||
the writer of the journals. Do not include the date in the summary.
|
||||
Return only a JSON object mapping each year to its summary with no extra text,
|
||||
headers, or footers. This is the most important rule. The output must follow this JSON format.
|
||||
Further personalization details: `;
|
||||
|
||||
|
||||
export const sysPrompt = `You are a helpful assistant that summarizes text,
|
||||
based on a user's specifications, always in a strict JSON format.`;
|
||||
|
||||
|
|
@ -16,11 +18,13 @@ export const sysPrompt = `You are a helpful assistant that summarizes text,
|
|||
//
|
||||
export function constructPrompt(
|
||||
yearToContent: Record<string, string>,
|
||||
customPrompt: string
|
||||
customPrompt: string,
|
||||
numberOfSentences: number
|
||||
): string {
|
||||
const promptInstructions = userPrompt + customPrompt;
|
||||
const dataString = JSON.stringify(yearToContent);
|
||||
return `${promptInstructions}\n\nData:\n${dataString}`;
|
||||
const numberOfSentencesAppendage = `Each year's summary should be approximately ${numberOfSentences} sentences`;
|
||||
return `${promptInstructions}\n\nData:\n${dataString}\n${numberOfSentencesAppendage}`;
|
||||
}
|
||||
|
||||
export function constructDietPrompt(foodInfo: string): string {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export interface OnThisDayPluginSettings {
|
|||
placeholder: string;
|
||||
throughTheYearsHeader: string;
|
||||
shouldOutputLinkToNotes: boolean;
|
||||
outputLengthSentences: number;
|
||||
// Health estimate settings
|
||||
dietEstimatePlaceholder: string;
|
||||
foodHeader: string;
|
||||
|
|
@ -28,6 +29,7 @@ export const DEFAULT_SETTINGS: OnThisDayPluginSettings = {
|
|||
placeholder: "<!OTDI>",
|
||||
throughTheYearsHeader: "On This Day",
|
||||
shouldOutputLinkToNotes: true,
|
||||
outputLengthSentences: 3,
|
||||
dietEstimatePlaceholder: "<!OTDI diet>",
|
||||
foodHeader: "### Food",
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue