Getting unstructured data
This tutorial explains how to get the unstructured data from pages using Harmony and access them dynamically. This is particularly useful when you want to ask an agent to open a page and do some operations on the content of this page.
Example
The agent can be instructed to get the page content and do something with it, for example, by executing the query:
Call the tool `get_page_content` with `url: https://en.wikipedia.org/w/index.php?search=Pythagorean_theorem`,`selector: #bodyContent`, `format: inner_text` and write one sentence summaryof its content.The output would be something like:
The Pythagorean theorem is a fundamental principle in Euclidean geometrystating that in a right triangle, the square of the hypotenuse's length isequal to the sum of the squares of the other two sides' lengths, expressed as(a^2 + b^2 = c^2).It’s not particularly useful yet as it’s tedious to execute this prompt each time when you want to search for something with Wikipedia. Let’s try to fix this by making this prompt more reusable by rewriting it and attaching the selection:
You are the assistant that helps me to check wikipedia content for the wordthat I have selected on the page. Call the tool `get_page_content` with`url: https://en.wikipedia.org/w/index.php?search=SELECTED_TEXT`,`selector: #bodyContent`, `format: inner_text` and write one sentence summarizeof the it's content. The value for "SELECTED_TEXT" is provided below.
# Selected textAttach the current page’s selection by clicking on the clip icon below the query and choosing “Selection”. Note that the header ”# Selected text” is needed because attachments are added right after the main prompt as plain text, and it’s needed to let the agent know what this text means (without the header, the provided text wouldn’t make sense). Select some word on the current browser page and try to execute this prompt. In our test run, the selection was “Warsaw”, and the output was:
Warsaw, the capital and largest city of Poland, is a major cultural, political,and economic hub located on the River Vistula, known for its rich history,diverse architecture, and a significant role in European affairs.Now, save the prompt as a task and provide the values:
- Main
- Name: “Selection: Search Wikipedia”
- Description: “Search selected text in Wikipedia and provide its short summary”
- Arguments
- Query: the prompt from above
- Attachments: attach the selection
- Additional options
- Allowed tools:
get_page_content
- Allowed tools:
- Options
- Context menu path: “Selection / Search Wikipedia” - 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 / Search Wikipedia” to test it.