HyperAgent supports Hyperbrowser as a browser provider. This gives you access to all the features supported by Hyperbrowser itself, like
import "dotenv/config";
import HyperAgent from "@hyperbrowser/agent";
import { ChatOpenAI } from "@langchain/openai";
import chalk from "chalk";
async function runEval() {
const llm = new ChatOpenAI({
apiKey: process.env.OPENAI_API_KEY,
model: "gpt-4o",
});
const agent = new HyperAgent({
llm: llm,
browserProvider: "Hyperbrowser",
});
const result = await agent.executeTask(
"Find the initial release date for Guardians of the Galaxy Vol. 3 the movie",
{
debugOnAgentOutput: (agentOutput) => {
console.log("\n" + chalk.cyan.bold("===== AGENT OUTPUT ====="));
console.dir(agentOutput, { depth: null, colors: true });
console.log(chalk.cyan.bold("===============") + "\n");
},
onStep: (step) => {
console.log("\n" + chalk.cyan.bold(`===== STEP ${step.idx} =====`));
console.dir(step, { depth: null, colors: true });
console.log(chalk.cyan.bold("===============") + "\n");
},
}
);
await agent.closeAgent();
console.log(chalk.green.bold("\nResult:"));
console.log(chalk.white(result.output));
return result;
}
(async () => {
await runEval();
})().catch((error) => {
console.error(chalk.red("Error:"), error);
process.exit(1);
});
const agent = new HyperAgent({
llm: llm,
browserProvider: "Hyperbrowser",
hyperbrowserConfig: {
hyperbrowserConfig: {
apiKey: process.env.HB_API_KEY
}
}
});