AI for builders

AI for builders is an advanced set of tools for those who want to build their own AI functionality in Tana. Note: This Tana Labs experiment will be replaced by Tana AI in June 2024.

Overview

The Tana Labs feature AI for Builders was the first generation of AI functionality in Tana. It introduced a modular toolkit to build AI workflows and embed AI processing into Tana actions. This included things like command line actions, command nodes, the prompt workbench, Autofill, Autotag, generate image and much more.

With the introduction of the Tana Core plan, AI for Builders will graduate from being an experimental project to being an integral core feature in Tana, and will therefore cease to exist as a Tana Labs option moving forward.

AI work will be powered by Tana AI and not through OpenAI API keys brought by the user (BYOK), with the exception of one general purpose command called Generic AI query that will accept BYOK.

The advanced tools that were introduced under the AI for Builders feature will remain mostly the same. You do not need to fix or change anything once this change is in effect.

Basics

  • All AI functionality that previously worked with your own API key will now be powered by Tana AI. For more on how Tana AI works, see Tana AI.
  • Any functionality that was created as part of AI for builders will continue to exist until further notice. This page will be integrated into the main Tana AI page eventually.

Details

AI: <prompt>

Start a node with ai:, and add your prompt. You'll see an Ask AI button pop up. Press it, and this generates the AI response for you.

You can also do the same through the command line, either pre-writing your prompt in a node and running Ask AI, or taking an existing node with content and running Ask AI to → and type out your prompt in the command line.

The plug-and-play AI commands will let you:

  • 📝 quickly query GPT, or 🎨 generate art with DALL-E, using your nodes as prompts.
  • 🗃️ cluster/sort your nodes using AI.
  • 🗣️ transcribe audio files into text.

There are seven standard commands that are accessible via the command line:

📝 Ask AI commands

  • Ask AI
  • Ask AI to →
  • Ask AI (creative)

🎨 DALL-E commands

  • Generate image(s) with DALL-E
  • Generate image(s) with DALL-E (enhanced prompt)

⌨️ Other commands

  • Cluster children with embeddings
  • Transcribe

AI Fields / Autofill

AI fields are super-powered fields: through GPT, they can be automatically filled in with useful data, based on what the AI can see of the field and its context.

Turn it on by going to Field configuration, and turn on ✨AI-enhanced field. An ✨AI button will appear next to the name of the field. To autofill the fields, click it.

By default, the AI looks at the node the field is attached to plus the node's children, other fields and description.

This is packaged into a prompt and sent to the AI, with the task Decide a value for the field: [field name]. The AI then does its best to answer.

┳┳ Smart tables

AI fields can be run on a single node, or as a part of a table.

Suggest AI fields

You can also have GPT suggest appropriate AI fields for you, from the "Add column" area in tables.

Builder's corner

For more advanced implementations of AI, we have created a highly modular set of building blocks which are covered below. It is a higher threshold of entry, but allows for customizations that are not possible anywhere else.

Prompt Workbench

When triggering an AI lookup field or running a custom Ask AI command, the AI is given a prompt composed of your data + a request.

The key to creating powerful AI functionality in your Tana workflows, is understanding what is sent to the AI when you run a command.

You can view, test and edit your prompt in the Prompt Workbench.

Access the workbench in the following ways:

  • When you turn on AI-enhanced field in the field configuration (see image below)
  • On the Ask AI command node

When you open the prompt workbench, you'll see this:

The prompt workbench consists of a few sections:

Test node

You can set which node is used for testing and setting up your prompt

Custom Prompt

The Custom Prompt is the window where you feed your own prompt into the AI function you are configuring.

Prompt expressions in Tana are built like Title expressions, with some extra functionality:

  • To get the name of the node that you are targeting, use ${name}
  • To reference field values, use ${field label}.
  • To reference the entire node context with all fields and children in Tana Paste format, use ${sys:context}
  • To return a node's supertags, use ${sys:tags}
  • To show a node's children (excluding content inherited from supertag), use ${sys:content}
  • To insert the current date/date and time, use ${sys:currentDate} and ${sys:currentDateTime} respectively. Keep in mind that GPT doesn't know the current date or time natively.
  • To return the URL and ID of the node, use ${sys:nodeURL} and ${sys:nodeId} respectively.
  • All of the normal title expressions are also available.

To get the full context of the field content, use a field definition.

  • To get the field definition, put your cursor on the name of a field, Cmd/Ctrl+C to copy, put your cursor inside the prompt and Cmd/Ctrl+V to paste a reference to the field definition

The video shows the difference between the title expression pointing to a field versus the field definition in terms of what gets sent in the prompt:

You can also use dynamic content in your prompts: use a reference to a node directly in your prompt (including search nodes), or create search nodes in the prompt.

Side note: Tana Paste and AI prompts

All output from the AI is parsed with Tana Paste before being inserted into Tana. For smaller texts, this should make no difference for you, but it does offer the possibility of teaching the AI to generate rich Tana data structures.

For example, you can tell it to generate a list of cities, and tag each as city, with the population as a field. Providing examples are really helpful:

- Rio de Janeiro #city
- Population:: 4M

Other useful tricks you can tell AI to do to output in a more Tana Paste friendly format:

  • “Output as Markdown table”
  • “Output as Markdown code block”
  • “Output as hierarchical Markdown, and use indentation instead of # for headers”
  • “use - [ ] for tasks”

You can even make it generate search nodes. For more on that, read up on Tana Paste.

Expanded Prompt

The expanded prompt section shows what is being sent to the OpenAI API. To see what is being sent from and to Tana when you're using AI, use the GPT Log Monitor.

Temperature

If you frequently get unsatisfying responses that start with "As a language model”, try turning the temperature up for your prompt. Increasing the model's creativity seems to often get it to loosen up a bit.

A rule of thumb:

  • If you are generating new content, use a high temperature.
  • If you are restructuring your existing data, use a low temperature.

AI Command nodes

To learn about all custom AI command nodes, see AI Commands. Some commands are covered below.

Generic AI command

This command node only works with an OpenAI key you provide. (See BYOK setup for more info on how to connect your own key to Tana.)

Autotag

Autotag is an AI Command that is designed to help users sort and organize their content. Autotag uses AI to analyze different items, recognize what they are, and apply the relevant tags.

Set up the command Autotag with parameter Tag candidates, list a few supertag candidates in the configuration, and now run this custom command on a list of nodes.

Once supertags have been assigned, you can use Autofill to fill in fields based on the contents of the name. For example, AI can provide suggestions to fill fields, such as deadline, topic, even follow-up task, based on what it finds. You can also set it to auto-generate a new title and description. You can also exclude fields from the action, and choose to run on GPT-4 for different results. All of this can be switched on in the Supertag configuration as AI-enhanced tag.

BYOK Setup

🔑 Your OpenAI keys

All interactions with the APIs require you to connect your own OpenAI API key. To get it, go to OpenAI's API Key page.

Once you have your API key at hand, 1️⃣ open the command line and run the "Set OpenAI API Key" command. Then 2️⃣ paste your key in the field and you're good to go.

🗄️ Your data and privacy

The different AI commands require us sending your data to the OpenAI API.

There is no functionality in the system that sends data to OpenAI unless you take a specific action that sends data (e.g. using the AskGPT command.)

If we ever introduce the option of automatic/background processing, we will change our terms, and have an explicit opt-in.

💸 Your spend limit

❗️IMPORTANT: Since you are using your own API key, you will be responsible for your own Pricing.

When experimenting, it can be easy to use a lot of tokens (AI in Tana is a lot of fun 🤖). We strongly recommend setting Usage limits in your OpenAI API.

❗Note: if you are a trial user of OpenAI you are likely to be hit with rate limiting. Entering a payment method (credit card information) will improve this.



Related release notes

  • fixedFixed bug where prompt field in prompt workbench would sometimes be gone. Added a switch to turn on custom prompt from within prompt workbench. ()
  • improvedGPT-4o has been added to list of models ()
  • improvedWe now include the default transcription language in the generate field suggestions prompt ()
  • improvedWe updated to the latest GPT 4 model. ()
  • improvedWe now pass on quota errors from OpenAI API accounts to users who are using their own key, in an effort to try to be a smidge more helpful than "not helpful at all" ()
  • improvedStreaming AI responses now support 'inline code' blocks ()

Related FAQs

  • Can I retrieve the prompt I used for an AI request?

    Yes, use the open GPT log monitor via the command line. Once open, click on one of the jobs to open it. This shows you the raw inputs and output from OpenAI, including the prompt you used.

    Related docs:

  • Can I use my own OpenAI API key in Tana?

    To use AI, you need to have a subscription to Tana Core. If you subscribe to the new Tana Core plan, you get 5000 AI credits included in your plan. You also have the possibility to top up your AI credits should you run out.

    That said, with a Tana Core subscription we accept user-supplied OpenAI API keys with the use of two specific commands:

    Ask AI: Extensive command, provides result in one batch

    Generic AI query: Simpler command, provides streaming results

    When setting up the commands, set the parameter "use your own AI key" and it will utilize the saved OpenAI API key in Settings

    To set your OpenAI API key, go to Settings > API keys > OpenAI

    Related docs:

  • How can I save the image from AI-generated banners?

    Right-click on the banner > Move banner image to node. Then you can download it like you would with any image.

    Related docs:

  • How do I fix "The aiForBuilders feature is not enabled" error?

    To activate AI for Builders, go to Settings > Tana Labs > AI for Builders

    It can happen that this setting gets reset if you switch browsers or client. This setting is stored per browser/client, not per account.

    Related docs:

  • I activated "AI for Builders" but using AI commands keeps on producing errors?

    Errors when trying to run AI commands in Tana usually stem from one of two things:

    • Your OpenAI API key has not been entered
    • A payment method for using OpenAI's API has not been entered (this is a separate billing from ChatGPT i.e. not included in a ChatGPT Pro subscription)

    For more on how to setup OpenAI, read this: https://tana.inc/docs/ai-for-builders#setup

    Related docs:

  • I already pay for ChatGPT Pro, can I use that to run AI on Tana?

    No, using ChatGPT and the use of their API are two separate services according to OpenAI, and so there is separate billing for each. The API is pay-as-you-go, so you have to ensure it is activated before you can use AI in Tana.

    For more on how to setup OpenAI, read this: https://tana.inc/docs/ai-for-builders#setup

    Related docs:

  • What do the AI error messages Out of budget and 0/1 left mean?
    This writeup is from community member Theo Koster outlining a detailed walkthrough on how to set up your OpenAI account so you can use it with AI for Builders. It covers several errors like out of budget, 0/1 left, and rate limit for this api key has been hit. Here's Theo:

    There is no new information in this post, just a handy list of actions that I needed to assemble from different posts. If you get error messages using AI functionality, here is how I solved these.

    First: you've got to understand that Tana uses the OpenAI API. This is a different product than the OpenAI chatbot ChatGPT. So even if you have a paid account with the OpenAI ChatGPT, this is of no use to using the OpenAI API.

    Second: you have a limited amount of free queries available with the OpenAI API. This is why you run into error messages after a week of using the AI facilities in Tana. So you've got to pay extra. If you don't want to do that, fine, but face the limits. The good news here is that you can limit your credit to ± $5 and you can limit your maximum spend per month. My burn rate on my first day on a paid plan was 32 cents.

    How I got it all working:

    Now you should be good to go.

    Thanks Theo for the thorough writeup!

    Related docs:

  • What does "Retrying AI requests failed, giving up operation" error mean?

    This message means that the request to OpenAI was denied upon receipt, and there can be several reasons for this:

    1. Not enough funds

    • Recently, OpenAI changed their payment rules and you have to prepay to cover for API costs.

    2. Token window too small

    • Your request may be spending too many tokens on the prompt. Switch model to one that has a higher token limit

    3. OpenAI service disruption

    • If OpenAI's API is temporarily experiencing instability or down time, this may trigger this error. You can check their status here.

    There may be more causes, and if we identify them we'll add them here.

    Related docs: