Obsidian and AI: Using OpenAI on your PKM

obsidian ai

Powered by DALL-E 3

OBSIDIAN AND AI

Imagine using OpenAI to summarize a note’s content in your Personal Knowledge Management (PMK) System. It is possible, if you build your PKM using Obsidian! What would it be like to summarize the content of that note? Better yet, what if you could chat with the AI about the content?

You can do all this and more using the new plugin AI for Templater (AIT) created by Obsidian maven and Tools for Thought expert TfTHacker, located here.

Here’s how to start installing, setting up, and running example use cases, as well as the privacy implications of using OpenAI.

 

Installation Steps:

  1. This plugin leverages the Templater plugin, a powerful extension of Obsidian’s template functionality. Please install, enable, and set up that plugin first. The source can be found here, or you can install it through the Community Plugin “Browse” feature. Be sure to designate in the Templater plugin settings the folder where you keep your Templates.
  2. Next, you’ll want to install the AI for Templater plugin in the usual way.
  3. Now that the plugin is installed, make sure it is also enabled. You’ll see a new plugin called “AI for Templater” in your Settings panel.

 

Before you use this tool, you’ll need to insert your OpenAI API Key. Here’s how to get it:

  1. Login to Openai.com. If you don’t have an account, create one.
  2. Go to https://platform.openai.com/apps and select “API” (not ChatGPT). Now you’re at https://platform.openai.com/docs/overview
  3. In the far left hover bar, click the “lock” icon (API keys). Now you should be at https://platform.openai.com/api-keys
  4. Click on “Create new secret key”. Give it any name that makes sense to you (like “AI for Templater”), and then copy the string.
  5. Paste it into the API Key box, pictured here:Home_-Sarah_Bentley_Vault-_Obsidian_v1_5_12 1.png

NOTE: OpenAI’s revenue model is evolving quickly. You may need to buy tokens to use the API. To do that:

  1. Go to https://platform.openai.com/account/billing/overview. Add a Payment method: a credit card. Start with $5 or $10.
  2. It may require you to set up “automatic recharge” before continuing. If so, you can go back later and disable this later:Auto-renew.jpg

 

Now, you should be all setup and ready to go.

 

AIT Uses

On TfTHacker’s website here, he lists several examples. Let’s look at two of them.

 

1. Summarize Note

On this page here, you can find a Description and the code to put into a Templater template.

 

Setup

  1. Copy and paste the “Template Code” into a file in your designated Template folder. Call it whatever you like; for example, “AI-Summarize.”
  2. NOTE: this code will call for a customized “prompt” for OpenAI. That is in a separate file that you can easily tweak.
  3. Copy the content of the prompt from the section on the page under “Prompt.” You need to paste that prompt text into a file named “SumarizeNote” that you can place anywhere in your Obsidian vault.

 

Running

Now, you’re ready to use this “Summarize Note” template.

  1. Open a note you want to work on. In my example, I created a note containing Abraham Lincoln‘s Gettysburg Address.
  2. Once inside that note, bring up the command palette (CMD-P on Mac, CTL-P on Windows)
  3. Select “Templater: Open Insert Template modal”
  4. You’ll be presented with a list of files from your Template folder. Pick the one you created for the Summarize Note functionality, like my example “AI-Summarize”
  5. This is where the magic happens. The Templater template will execute. It will do two things:
    a. It will pop up a report of its activity, including the token use and the number of characters scanned:AIT-report.jpg
    b. It will create a new Property called “Summary” either at the top of your note or in the Property sidebar. In my case, the summary appeared as follows:Gettysburg_Address_-Bill_Petro-_Obsidian_v1_5_12.png

 

2. Chat conversation

On this page here you can find a Description and the code that you can put into a Templater template.

 

Setup

  • Copy and paste the “Template Code” into a file in your designated Template folder. Call it whatever you like; for example, “AI-Chat.”

 

Running

Now, you’re ready to use this “Chat conversation” template.

    1. Open a note you want to work on. In my example, I’ll use the same file: Gettysburg Address.
    2. Once inside that note, bring up the command palette (CMD-P on Mac, CTL-P on Windows)
    3. Select “Templater: Open Insert Template modal”
    4. You’ll be presented with a list of files from your Template folder. Pick the one you created for the Summarize Note functionality, like my example “AI-Chat.”
    5. In the midst of the note, you’ll see a bold ‘You’. Below it, type a question of the content of that note. In my case, I typed:

      You
      What ancient sources did Lincoln use in creating this address?

      OpenAI will place the reply directly below the question with an italicized ‘AI’

AI
Abraham Lincoln drew inspiration from various ancient sources in creating the Gettysburg Address. Some scholars have identified similarities between Lincoln’s words and concepts found in ancient texts such as the Bible, the Greek philosopher Pericles’ Funeral Oration, and the speeches of Roman senator and philosopher Cicero. Lincoln was likely influenced by the ideas of honoring the dead, the solemnity of dedicating a battlefield, and the importance of preserving a nation for future generations—themes that resonate across different cultures and time periods. Lincoln’s ability to weave together elements from different sources contributed to the enduring power and significance of his address.

This is impressive! I’d previously written a blog article on the origins and significance of Lincoln’s Gettysburg Address, and this answer came close to the research I’d done. See that here

 

How is this plugin different from other Obsidian AI plugins?

      • This approach can the query inside Obsidian
      • It leverages the powerful and popular Templater plugin
      • It allows for easy customization of the prompt, kept in a separate file
      • And the results show up in the original file.

 

Privacy Implications with OpenAI

TfTHacker points out that:

Warning
Additionally, when you use this plugin, unless you have configured it to use a local LLM, it will make internet requests to the OpenAI API. Please be aware of this when using this plugin.

That means you control what gets sent outside your Obsidian Vault to OpenAI.

No Data Sent

      • Some examples simply invoke the AI by asking a question without accessing any data in your Obsidian Vault.
      • The Daily Quote example pulls from the AI but does not send any of your data or perform background processing on your Obsidian Vault.

Some Data Sent

      • The plugin is configured by default to use the OpenAI service such that if, for example, you use the Summary template example I mentioned above, the note (file) you are summarizing is sent to the AI.
      • Similarly, asking the AI questions about the note, as with the Chat conversation template example above, will send that note to the AI.

 

Take a look at this new plugin here.

 

Bill Petro, your friendly neighborhood technologist
billpetro.com

Subscribe to have future articles delivered to your email. If you enjoyed this article, please consider leaving a comment.

About billpetro

Bill Petro writes articles on history, technology, pop culture, and travel. He has been a technology sales enablement executive with extensive experience in Cloud Computing, Automation, Data Center, Information Storage, Big Data/Analytics, Mobile, and Social technologies.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.