adds feature to inject custom context instructions

This commit is contained in:
Chris Lettieri 2025-04-18 12:55:09 -04:00
parent 223acd9851
commit 7ad0725f29
2 changed files with 137 additions and 18 deletions

View file

@ -14,27 +14,101 @@ Let Open Augi process and organize your thoughts so you can go further, faster.
Join the [Discord](https://discord.gg/d26BVBrnRP).
Parent [repo](https://github.com/bitsofchris/openaugi).
## Setup
## Example
1. Install the plugin from the Obsidian Community Plugins or manually
2. Go to Settings → OpenAugi
3. Enter your OpenAI API key
4. Set your preferred folders for summaries and atomic notes
5. Save settings
When taking a voice note say "auggie this is a task" or "auggie make a new note about X".
## Main Commands
Import your voice transcript into Obsidian.
OpenAugi offers two primary commands:
Hit `CMD+P` and run the `OpenAugi: Parse Transcript` command.
### 1. Parse Transcript
This will create:
- atomic notes for every idea in your transcript
- extract tasks
- summarize the entire voice note
This command processes a voice transcript or any text and organizes it into atomic notes, tasks, and a summary.
The summary note will be created with any relevant tasks and links to the new atomic notes.
**Usage:**
1. Import your voice transcript into Obsidian as a markdown file
2. Open the transcript file
3. Hit `CMD+P` (or `CTRL+P` on Windows/Linux) to open the command palette
4. Run `OpenAugi: Parse Transcript`
The plugin will:
- Break down your transcript into separate atomic notes (1 idea per note)
- Extract any tasks mentioned
- Create a summary note with links to the atomic notes
- Link related concepts automatically
**Special Commands in Transcripts:**
Using "auggie" as a special token during your voice note can improve accuracy of the agentic behaviors.
- Say "auggie this is a task" to explicitly mark something as a task
- Say "auggie make a new note about X" to create a specific note
- Say "auggie summarize this" to get a summary of recent thoughts
- Say "auggie this is a journal entry" to format text as a journal entry
### 2. Distill Linked Notes
This command analyzes a set of linked notes and synthesizes them into a coherent set of atomic notes.
**Usage:**
1. Create a root note that links to other notes you want to distill
- Links can be regular Obsidian links like `[[Note Name]]`
- You can also use dataview queries (if the dataview plugin is installed)
2. Open this root note
3. Hit `CMD+P` (or `CTRL+P` on Windows/Linux) to open the command palette
4. Run `OpenAugi: Distill Linked Notes`
The plugin will:
- Gather all linked notes
- Analyze their content together
- Create new atomic notes that synthesize and organize the information
- Generate a summary that connects the key concepts
- Extract any actionable tasks found across the notes
## Custom Context
You can guide how OpenAugi processes your content by adding a custom context section to your notes:
```context:
Only extract items related to project goals and key decisions.
Focus on extracting the "why" behind each decision.
```
**For Transcript Parsing:**
Add this section to your transcript file before processing.
**For Distillation:**
Add this section to your root note before running the distill command.
**Example Use Cases:**
- `Focus only on extracting research findings and methodology details`
- `Extract only content related to project risks and mitigation strategies`
- `Identify and highlight conflicting viewpoints across these notes`
- `Focus on extracting personal insights and reflections, ignoring factual content`
The custom context allows you to narrow the focus of processing to extract specific types of information relevant to your current needs.
## Requirements
Note: this requires an OpenAI API key to work.
Your transcript is sent directly to OpenAI for parsing using the best model for this task. The cost to use this plugin depends on the API credits consumed. For me ~5 minutes of voice note is about 2-3 cents of processing.
Your content is sent directly to OpenAI for processing using the best model for this task. The cost to use this plugin depends on the API credits consumed. For me ~5 minutes of voice note is about 2-3 cents of processing.
## Output Structure
OpenAugi creates two types of files:
1. **Summary files** - Placed in your designated summary folder, containing:
- A concise summary of the content
- Links to all atomic notes
- Tasks extracted from the content
2. **Atomic notes** - Placed in your designated notes folder, each containing:
- A single, self-contained idea
- Context and supporting details
- Backlinks to related notes where relevant
# Get involved, let's build augmented intelligence
@ -42,4 +116,4 @@ This plugin is meant to solve my own problems around using Obsidian as my second
Augmented intelligence is using AI to help you think faster and do more. Not to write and think for you. But rather to support and augment what you are capable of.
Open an [issue](https://github.com/bitsofchris/openaugi-obsidian-plugin/issues), join the [Discord](https://discord.gg/d26BVBrnRP), and check out my [YouTube](https://www.youtube.com/@bitsofchris) to give feedback on how this works for you or what you'd like to see next.
Open an [issue](https://github.com/bitsofchris/openaugi-obsidian-plugin/issues), join the [Discord](https://discord.gg/d26BVBrnRP), and check out my [YouTube](https://www.youtube.com/@bitsofchris) to give feedback on how this works for you or what you'd like to see next. Read more at the [parent repo](https://github.com/bitsofchris/openaugi).

View file

@ -20,13 +20,38 @@ export class OpenAIService {
this.apiKey = apiKey;
}
/**
* Extract custom context instructions from content if they exist
* @param content The content to extract the context from
* @returns The extracted context or null if none exists
*/
private extractCustomContext(content: string): string | null {
// Look for context: section in the content
const contextRegex = /```context:([\s\S]*?)```|context:([\s\S]*?)(?:\n\n|\n$|$)/;
const match = contextRegex.exec(content);
if (match) {
// Return the first matching group that has content
const rawContext = (match[1] || match[2])?.trim() || null;
if (rawContext) {
return `# USER CONTEXT\nPlease apply these additional instructions when processing. The instructions should take priority to guide and focus what you should extract:\n${rawContext}`;
}
}
return null;
}
/**
* Get the system prompt for the OpenAI API
* @param content The transcript content
* @returns The formatted prompt
*/
private getPrompt(content: string): string {
return `
// Extract any custom context
const customContext = this.extractCustomContext(content);
// Base prompt
let prompt = `
You are an expert agent helping users process their voice notes into structured, useful Obsidian notes. Your mission is to capture the user's ideas, actions, and reflections in clean, atomic form. You act like a smart second brain, formatting output as Obsidian-ready markdown.
# Special Command Handling
@ -72,9 +97,17 @@ export class OpenAIService {
2. **Group context**: Organize ideas around coherent units. These units fomr the foundation of atomic notes.
3. **Respect ambiguity**: When unsure, err on the side of creating a thoughtful atomic note.
4. **Don't repeat**: Avoid redundancy across notes, tasks, or summary.
Transcript:
${content}`;
`;
// Add custom context if available
if (customContext) {
prompt += `\n\n${customContext}`;
}
// Add transcript content
prompt += `\n\nTranscript:\n${content}`;
return prompt;
}
/**
@ -182,7 +215,11 @@ ${content}`;
* @returns The formatted prompt
*/
private getDistillPrompt(content: string): string {
return `
// Extract any custom context from the content (which should include the root note)
const customContext = this.extractCustomContext(content);
// Base prompt
let prompt = `
You are an expert knowledge curator helping users distill and organize information from their notes. Your task is to analyze multiple related notes and create a coherent set of atomic notes and a summary.
# Instructions
@ -208,9 +245,17 @@ ${content}`;
- Write a concise summary that synthesizes the key concepts
- Highlight connections between ideas
- Use \`[[Backlinks]]\` to connect to relevant atomic notes
`;
# Content to Distill:
${content}`;
// Add custom context if available
if (customContext) {
prompt += `\n\n${customContext}`;
}
// Add content to distill
prompt += `\n\n# Content to Distill:\n${content}`;
return prompt;
}
/**