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

Stagehand tools integration #7177

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

filip-michalsky
Copy link

@filip-michalsky filip-michalsky commented Nov 10, 2024

This PR introduces an integration of Langchain with Stagehand, the best in class AI web automation framework from Browserbase HQ.

Users can now use Stagehand web navigation tooling to power their agents with simple atomic web interactions!

Copy link

vercel bot commented Nov 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Nov 14, 2024 5:52am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Nov 14, 2024 5:52am

@filip-michalsky filip-michalsky changed the title Stagehand tools [DRAFT] Stagehand tools Nov 10, 2024
@filip-michalsky filip-michalsky changed the title [DRAFT] Stagehand tools [DRAFT] Stagehand tools integration Nov 10, 2024
@filip-michalsky filip-michalsky changed the title [DRAFT] Stagehand tools integration Stagehand tools integration Nov 14, 2024
@filip-michalsky filip-michalsky marked this pull request as ready for review November 14, 2024 05:07
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder labels Nov 14, 2024
@dosubot dosubot bot added the auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features label Nov 14, 2024
If you plan to run the browser locally, you'll also need to install Playwright's browser dependencies.

```bash
npm exec playwright install
Copy link
Collaborator

Choose a reason for hiding this comment

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

```typescript
import { Stagehand } from "@browserbasehq/stagehand";
import { StagehandActTool } from "./StagehandActTool";
import { initializeAgentExecutor } from "@langchain/agents";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah this is quite old, we should show how to use this with LangGraph instead:

https://langchain-ai.github.io/langgraphjs/how-tos/create-react-agent/?h=create#code

@@ -0,0 +1,42 @@
import { StagehandToolkit } from "@langchain/community/agents/toolkits/stagehand";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just import it into your .mdx file so that you get type checking, linting etc.

@@ -65,6 +65,7 @@ export const config = {
"agents/toolkits/aws_sfn": "agents/toolkits/aws_sfn",
"agents/toolkits/base": "agents/toolkits/base",
"agents/toolkits/connery": "agents/toolkits/connery/index",
"agents/toolkits/stagehand": "agents/toolkits/stagehand",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to add this to requiresOptionalDependencies below

@@ -190,6 +192,7 @@
"node-llama-cpp": "3.1.1",
"notion-to-md": "^3.1.0",
"officeparser": "^4.0.4",
"openai": "^4.72.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did we need to add this?

}
}

abstract class StagehandToolBase extends Tool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably want to extend StructuredTool instead since you can specify Zod schemas for tool inputs

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

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

Thanks! See comments, please also remember to run yarn format and yarn lint.

@jacoblee93 jacoblee93 added the close PRs that need one or two touch-ups to be ready label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features close PRs that need one or two touch-ups to be ready size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants