HARPA.AI
LIBRARYUSE CASESGUIDESAI COMMANDSBLOG

Parameters

CONTENTS

# Command parameters

Whenever you send a question (prompt) in chat, HARPA injects parameters into the prompt text. For example, if you type Please summarize this web page: {{page}} in chat, HARPA will extract text from the web page and inject it into the GPT prompt.

You can always test the parameter values by echoing them to AI chat. To echo a parameter value, type parameter name or a prompt including the parameter, and press Alt+Enter (or Alt+Click) in chat.

There are many predefined parameters you can use in your prompts:

  • {{page}} - web page text content, starting from the top of the page. Long pages are truncated to fit into GPT input. Page parameter supports extra options:
    • {{page url}} will retrieve the web page content from the specified URL. Work with the most websites except where retrieval is blocked, such as LinkedIn.com and X.com. Supports JavaScript.
    • {{page query}} will scan the page content for text semantically similar to the given query and return that as a parameter value. This is helpful when page is too large to fit into GPT input.
    • {{page limit=500}} specify a limit in tokens or percentage of the model context window, e.g. 10%.
  • {{selection}} - selected text on the web page, if any. This is useful when you want to summarize a specific portion of the web page.
  • {{title}} - web page title.
  • {{desc}} - web page meta description.
  • {{url}} - web page URL.
  • {{domain}} - web page domain.
  • {{language}} - language defined in the app settings, e.g. English; this is useful to instruct GPT to reply in a certain language across your commands. Most of the preconfigured commands use this parameter to tailor the response.
  • {{transcript}} - YouTube video transcript, useful for summarizing and extracting information from YouTube videos
  • {{transcriptPlain}} - YouTube video transcript, without timestamps.
  • {{message x}} - previous chat message, where x is a number, e.g. {{message 0}} is the first message, {{message 1}} is the second message, {{message -1}} is the last message, etc.
  • {{serp term}} - query web for the search term and find up to 10 top links. Supports search operators, e.g.: {{serp running weight loss site:ncbi.nlm.nih.gov}}.
  • {{gpt}} - last GPT response, useful for chaining prompts.
  • {{email}} - parses email content form Gmail, Outlook, Protonmail, and Fastmail. Works only on pages with an opened email. Parameter value is a JSON object with the following fields: user, sendTime, from, to, subject & content.You can see an example of the {{email}} parameter value in the screenshot above.
  • {{grab}} - allows you to extract a value of an HTML element from a web page, whether it's an h1, body, or href. Here are some examples:
    • {{grab}} extracts website body text.
    • CSS: {{grab h1}}
    • XPath: {{grab //h1}}
    • Text: {{grab Bring AI to your browser}}
    • Take innerText: {{grab h1 take=innerText}}
    • Take textContent: {{grab h1 take=textContent}}
    • Take id: {{grab h1 take=id}}
    • Take className: {{grab h1 take=className}}
    • Take class: {{grab h1 take=class}}
    • Take nodeName: {{grab h1 take=nodeName}}
    • Take nodeType: {{grab h1 take=nodeType}}
    • Take attributes: {{grab h1 take=attributes}}
    • Take [attribute]: {{grab h1 take=[class]}}
    • Take styles: {{grab h1 take=styles}}
    • Take (style): {{grab h1 take=(color)}}
    • Take innerHTML: {{grab h1 take=innerHTML}}
    • Take outerHTML: {{grab h1 take=outerHTML}}
    • Take href: {{grab a take=href}}
    • Take value: {{grab input take=value}}
    • At first: {{grab a take=href at=first}}
    • At last: {{grab a take=href at=last}}
    • At 0: {{grab a take=href at=0}}
    • At 1: {{grab a take=href at=1}}
    • At all: {{grab h2 at=all}}

In our parameter phrasing, "take" means specifying an argument's value. For example, by searching for the keyword "YouTube video summary", you can extract the text value of the entire element by setting the innerText argument value: {{grab YouTube video transcript take=innerText}}

Here are two more examples: in the first one, we search for the word "GPT" and get the text value of the first element in order, and in the second one, we ask for all elements and receive an array.

You can create and use custom parameters in commands, such as:

  • {{p1}}, {{name}}, {{param}}... - these parameters let you customize your command every time it is run. You can use automatically assigned names (p1, p2, etc.) or choose custom ones.

You can create custom parameters using CALC Set Parameter function. Inspect parameter values using SAY step, entering parameter in the text field, such as {{p1}}.

Parameters are interpolated both in the chat window as well as custom commands, e.g. in GPT, SAY and CALC steps. They may serve as the default value in the ASK step when the user provides no input and simply presses Enter.

You can also create and reuse parameters across multiple commands using g. prefix. See Global parameters section for more details.

# Global parameters

Parameters, e.g. {{p1}}, are retained for the duration of the single command. If you prefix parameter name with g., like this {{g.p1}}, parameter becomes a global one.

Global parameters are available across multiple commands, enabling the orchestration of complex command chains. Such chains can undertake tasks like gathering data from an open webpage into a list and subsequently triggering another command for data processing or Zapier integration.

You can use ASK step or CALC Set Parameter step to establish a global parameter. For example, you can prompt yourself to input a global parameter such as {{g.email}}, which could then be used in chat or commands at any time.

In this example, the SAY step is optional, but you can include it to verify that the parameter has been set.

A working example of a Global Parameter is the /set-reply-tone command. It saves your writing tone into {{g.tone}}, allowing you to rewrite any text in your unique style.

# Dot Notation

Dot notation is used in HARPA to access nested data structures, for example:

  • {{users.0.name.toUpperCase}} will get the first element of a users list parameter, access its name property and convert it to uppercase.
  • 0 is the index of the first element in the list. You can use negative indices to access elements from the end of the list, e.g. -1 is the last element, -2 is the second last element, etc.
  • toUpperCase is a JavaScript function, and you can use any JavaScript function without arguments in dot notation, e.g. trim, toUpperCase, toLowerCase, etc.

# Interpolation

Whenever HARPA encounters a parameter in commands or user input, it will be replaced with the parameter value. For example {{domain}} becomes harpa.ai This process is called interpolation.

You can avoid interpolation by adding a backslash before the parameter name, e.g. {{\p1}}. HARPA will replace the {{\p1}} with literal {{p1}} string.

# Page context

GPT input has a token limit, e.g. 4096 on GPT-3.5-turbo model, which is approximately 3000 words of English text. This limit is shared across chat history, question and response. Large web pages may not fit into the GPT input, so HARPA truncates {{page}} parameter automatically.

You can specify a keyword or query within the {{page}} parameter to extract portion of the page relevant to that keyword. For example: {{page Adobe Photoshop}} will instruct HARPA to scan the web page content for content semantically similar to "Adobe Photoshop" and return that as a parameter value.

NEXT POST
Contact us
HomeUse CasesGuidesPrivacy PolicyTerms of Service