Working with attachments
This tutorial explains how to work with attachments using Harmony. Harmony is capable of providing the current selection, the content of some element on the page, the content of the whole page, the page information, or the output of any tool.
This workflow is particularly useful for use cases like translation, explanation, text rewrite and correction, and so on.
Example: Context-aware translator
Let’s teach our assistant to translate the text selected on the page while looking into the content on the page and the page information to provide a better translation. To make it even more useful for learning a foreign language, let’s also ask the assistant to explain the translation. Here is the prompt for this:
You are the context-aware translator that translates the text that I'veselected on the page into the English language while looking into the pageinformation and the page content. Translate the selected text to English andexplain the translation word-by-word.Add the following attachments using the clip icon below the prompt input to access the attachments menu:
- Text/image: ”# Selected text”
- Selection
- Text/image: ”# Page info” (provides URL and title of the page)
- Page info
- Text/image: ”# Page text”
- Page text
This will provide the necessary information for the context-aware translation. The headers ”# …” are needed because the values of selection, page info, and page texts are directly embedded into the prompt, and some label is needed to distinguish them from each other.
Now, try selecting something in the foreign language on the browser page and executing this prompt. In my example, the selection was the text in Polish “Według większości opisów Pitagoras żył około 80 lat, chociaż relacja anonimowego autora twierdzi, iż żył on aż 104 lata” on the Pythagoras wikipedia page https://pl.wikipedia.org/wiki/Pitagoras, and the translation was “According to most descriptions, Pythagoras lived about 80 years, although an anonymous author’s account claims that he lived as long as 104 years”, with attached word-by-word explanation.
Once the prompt is debugged, you can save it as a task providing the values:
- Main
- Name: “Selection: Translate to English”
- Description: “Translate the selected text to English and explain the translation”
- Arguments
- Query: the prompt from above
- Attachments: the attachments from the above
- Options
- Context menu path: “Selection / Translate to English” - to make the task available in the context menu
Now, select some text, open the context menu with the right mouse click, and select “Harmony / Selection / Translate to English” to test it.