Connect SearchHive to LangChain agents and chains for powerful web-augmented LLM applications.
import { SearchHive } from '@searchhive/sdk'
import { Tool } from 'langchain/tools'
class SearchHiveTool extends Tool {
name = 'searchhive_search'
description = 'Search the web for current information'
async _call(query: string): Promise<string> {
const client = new SearchHive({ apiKey: process.env.SEARCHHIVE_API_KEY })
const results = await client.search({ query, maxResults: 5 })
return JSON.stringify(results.organic.map(r => ({
title: r.title,
snippet: r.snippet,
url: r.link
})))
}
}