Skip to main content

Overview

LangChain is a powerful framework for building AI agents that can interact with GBOX’s headless browser infrastructure. It allows you to create sophisticated AI assistants that can automate tasks, perform web scraping, and interact with web applications.

Getting Started

1

Install Dependencies

Install the necessary dependencies for your project.
2

Add Environment Variables

Create a .env file in your project root and add your GBOX API key and OpenAI API key:
3

Create Agent Flow

Create index.ts with the following content:
4

Implement Initialize Node

Implement the initialize node to set up the agent’s initial state:
TypeScript
5

Implement Take Action Node

Implement the takeAction node to perform actions based on the agent’s task:
TypeScript
Utility functions like handleModelAction can be implemented to handle specific actions based on the model’s response.
TypeScript
6

Implement Finish Node

Implement the finish node to summarize the agent’s actions and clean up resources:
TypeScript
7

Add conditional logic

Implement the shouldContinue function to determine if the agent should continue taking actions or finish:
TypeScript
8

Run the Agent

Run the agent with the following command:
You can run the TypeScript file using tsx:
Make sure to replace index.ts with the path to your TypeScript file if it’s located elsewhere.