BrowseGPT is a tool that allows you to search the web using a chat interface.
GET
, POST
, PUT
, DELETE
, etc.
To create a new route handler, create a new file in the app/api
directory.
In this example, we’ll call this file route.ts
for the chat route.
From here, we’ll import the necessary dependencies.
getDebugUrl
fetches debug information for a Browserbase session, while createSession
initializes a new Browserbase session for web interactions.
googleSearch
tool. If they want to get the content of a page, we’ll use the getPageContent
tool.
Keep in mind that you have the option to choose any LLM model that is compatible with the Vercel AI SDK.
We found that using gpt-4-turbo
was the best for tool calling, and claude-3-5-sonnet-20241022
was the best for generating responses.
createSession()
and getDebugUrl()
we made earlier to create a new Browserbase session and get the debug URL.
This is so later we can embed the debug URL in the response and our frontend can use it to view the Browserbase session.
getPageContent
tool.
This tool retrieves the content of a web page using Playwright. It then uses jsdom to parse the HTML content into a DOM structure and Readability to extract the main content of the page.
Finally, it uses the Anthropic Claude model to generate a summary of the page’s content.