Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add google search tool #99

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

njhale
Copy link
Member

@njhale njhale commented Oct 15, 2024

Add the Google Search tool.

This is a modified version of answers-from-the-internet that responds with knowledge-like references to relevant search result page content instead of answering questions directly.

e.g.

{
  "question": "what is an opossum?",
  "results": [
    {
      "url": "https://www.merriam-webster.com/dictionary/opossum",
      "title": "Merriam-Webster Dictionary - Opossum",
      "relevantContent": [
        "Opossum: any of a family (Didelphidae) of small- to medium-sized American marsupials that usually have a pointed snout and nearly hairless scaly prehensile tail, are typically active at night, and are sometimes hunted for their fur or meat.",
        "Especially: a common omnivorous largely nocturnal mammal (Didelphis virginiana) of North and Central America that is a skilled climber, that typically has a white face and grayish body and in the female a well-developed fur-lined pouch, and that when threatened may feign death by curling up the body and remaining motionless and unresponsive."
      ]
    },
    {
      "url": "https://en.wikipedia.org/wiki/Opossum",
      "title": "Wikipedia - Opossum",
      "relevantContent": [
        "Opossums are members of the marsupial order Didelphimorphia endemic to the Americas. The largest order of marsupials in the Western Hemisphere, it comprises 126 species in 18 genera.",
        "The Virginia opossum is the only species found in the United States and Canada. It is often simply referred to as an opossum, and in North America it is commonly referred to as a possum.",
        "Opossums are typically nonaggressive animals and almost never carry the virus that causes rabies.",
        "The word opossum is derived from the Powhatan language and was first recorded between 1607 and 1611 by John Smith (as opassom) and William Strachey (as aposoum).",
        "Opossums are often considered to be \"living fossils\", and as a result they are often used to approximate the ancestral therian condition in comparative studies.",
        "Opossums probably originated in the Amazonia region of northern South America, where they began their initial diversification.",
        "Didelphimorphs are small to medium-sized marsupials that grow to the size of a house cat. They tend to be semi-arboreal omnivores, although there are many exceptions.",
        "Opossums have a plantigrade stance (feet flat on the ground) and the hind feet have an opposable digit with no claw.",
        "Opossums eat insects, rodents, birds, eggs, frogs, plants, fruits and grain. Some species may eat the skeletal remains of rodents and roadkill animals to fulfill their calcium requirements.",
        "Opossums are found in North, Central, and South America. The Virginia opossum lives in regions as far north as Canada and as far south as Central America.",
        "Opossums are generally found in areas like forests, shrubland, mangrove swamps, rainforests and eucalyptus forests."
      ]
    },
    {
      "url": "https://dictionary.cambridge.org/us/dictionary/english/opossum",
      "title": "Cambridge Dictionary - Opossum",
      "relevantContent": [
        "Opossum: a small American marsupial that lives in trees and has thick fur, a long nose, and a tail without fur.",
        "The opossum is a marsupial that lives in North America."
      ]
    }
  ]
}

@njhale njhale force-pushed the feat/add-google-search branch 3 times, most recently from cb6c31b to 2984c29 Compare October 16, 2024 04:51
@njhale njhale marked this pull request as ready for review October 16, 2024 04:53
Add the Google Search tool.

This is a modified version of answers-from-the-internet that responds
with knowledge-like references to relevant search result page content
instead of answering questions directly.

Signed-off-by: Nick Hale <[email protected]>
@njhale njhale force-pushed the feat/add-google-search branch from 2984c29 to e932502 Compare October 16, 2024 05:01
Remove all results with no relevant content and deduplicate semantically equivalent relevant content before
responding with the minified JSON of the FocusedSearch object.

Do not include any additional preamble or commentary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In knowledge, I had to prompt it to not use syntax highlighting (i.e. backticks surrounding the JSON), as it was adding them every now and then (not always)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've been pumping the output through jq as I've tested this and haven't hit that problem yet. I think this line may be why

Comment on lines +100 to +102
For all search results, silently select all the chunks of text from each result's content that:
- answer the search query directly or provide additional information to support an answer to the search query
- contain enough context from the source text to complete the thought expressed by them in the original source text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it'd make sense at some point to extract this into a separate, reusable tool?
It seems to not be specific to Google 🤔

@njhale njhale merged commit cd5fee6 into obot-platform:main Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants