mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
758 lines
51 KiB
Plaintext
758 lines
51 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 2,
|
||
"metadata": {
|
||
"id": "ZRGlUb8O4fPV"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"%pip install -U langgraph langchain_google_genai langchain_community langgraph-checkpoint-postgres openai langchain_groq"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 3,
|
||
"metadata": {
|
||
"id": "cMfPUmHIxqTi"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"%%capture --no-stderr\n",
|
||
"%pip install --upgrade --quiet playwright > /dev/null\n",
|
||
"%pip install --upgrade --quiet lxml browser-use langchain_openai"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"id": "kkZ7jVUOUV7Q"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"!playwright install"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"id": "-_T1MhnGUl2q"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"!pip install \"anyio<4\""
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"id": "yARYirp1UhDR"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"# This import is required only for jupyter notebooks, since they have their own eventloop\n",
|
||
"import nest_asyncio\n",
|
||
"\n",
|
||
"nest_asyncio.apply()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"metadata": {
|
||
"id": "jyVP10O_5Qck"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"from google.colab import userdata\n",
|
||
"from langchain_openai import ChatOpenAI\n",
|
||
"\n",
|
||
"llm = ChatOpenAI(model='gpt-4o-mini', temperature=0, api_key=userdata.get('Open_api_key'))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 5,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "e9duizdv5cOH",
|
||
"outputId": "a07b1702-d485-4641-c307-601e6ab34b9b"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"AIMessage(content='Hello! How can I assist you today?', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 10, 'prompt_tokens': 8, 'total_tokens': 18, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_bd83329f63', 'finish_reason': 'stop', 'logprobs': None}, id='run-28a9088f-7539-412a-aa80-1663be40e74f-0', usage_metadata={'input_tokens': 8, 'output_tokens': 10, 'total_tokens': 18, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})"
|
||
]
|
||
},
|
||
"execution_count": 5,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"llm.invoke('hi')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 32,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "wS8ouhiVQ2dL",
|
||
"outputId": "653879a8-b3ac-4178-edee-5cd834e3404a"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"🔍 Searched for \"What is Langgraph?\" in Google\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"📄 Extracted page as markdown\n",
|
||
": \n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"## Controllable cognitive architecture for any task\n",
|
||
"\n",
|
||
"LangGraph's flexible framework supports diverse control flows – single agent,\n",
|
||
"multi-agent, hierarchical, sequential – and robustly handles realistic,\n",
|
||
"complex scenarios. \n",
|
||
" \n",
|
||
"Ensure reliability with easy-to-add moderation and quality loops that prevent\n",
|
||
"agents from veering off course. \n",
|
||
" \n",
|
||
"Use LangGraph Platform to templatize your cognitive architecture so that\n",
|
||
"tools, prompts, and models are easily configurable with LangGraph Platform\n",
|
||
"Assistants.\n",
|
||
"\n",
|
||
"[See the docs ](https://langchain-ai.github.io/langgraph/)\n",
|
||
"\n",
|
||
"## Designed for human-agent collaboration\n",
|
||
"\n",
|
||
"With built-in statefulness, LangGraph agents seamlessly collaborate with\n",
|
||
"humans by writing drafts for review and awaiting approval before acting.\n",
|
||
"Easily inspect the agent’s actions and \"time-travel\" to roll back and take a\n",
|
||
"different action to correct course.\n",
|
||
"\n",
|
||
"[Read a conceptual guide ](https://langchain-\n",
|
||
"ai.github.io/langgraph/concepts/agentic_concepts/#human-in-the-loop)\n",
|
||
"\n",
|
||
".gif)\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"## First class streaming support for better UX design\n",
|
||
"\n",
|
||
"Bridge user expectations and agent capabilities with native token-by-token\n",
|
||
"streaming and streaming of intermediate steps, helpful for showing agent\n",
|
||
"reasoning and actions back to the user as they happen. Use LangGraph\n",
|
||
"Platform's API to deliver dynamic and interactive user experiences.\n",
|
||
"\n",
|
||
"[Learn more ](https://langchain-ai.github.io/langgraph/how-tos/streaming-\n",
|
||
"tokens/)\n",
|
||
"\n",
|
||
"## Why choose LangGraph?\n",
|
||
"\n",
|
||
"### Control, moderate, and guide your agent’s actions.\n",
|
||
"\n",
|
||
"Prevent agents from veering off course and ensure reliability with easy-to-add\n",
|
||
"moderation and quality loops. Add human-in-the-loop to steer and approve agent\n",
|
||
"actions.\n",
|
||
"\n",
|
||
"### Expressive and customizable agent and multi-agent workflows.\n",
|
||
"\n",
|
||
"LangGraph’s low level abstractions offer the flexibility needed to create\n",
|
||
"sophisticated agents. Design diverse control flows – single, multi-agent,\n",
|
||
"hierarchical, sequential – all with one framework.\n",
|
||
"\n",
|
||
"### Persisted context for long-term interactions.\n",
|
||
"\n",
|
||
"With its stateful design, LangGraph stores conversation histories and session\n",
|
||
"data to maintain context over time and ensure smooth handoffs in agentic\n",
|
||
"systems.\n",
|
||
"\n",
|
||
"### First-class streaming support for better UX design.\n",
|
||
"\n",
|
||
"Bridge user expectations and agent capabilities with native token-by-token\n",
|
||
"streaming of intermediate steps, helpful for showing agent reasoning and\n",
|
||
"actions back to the user as they happen.\n",
|
||
"\n",
|
||
"## LangGraph Platform: \n",
|
||
"Deploy & develop agents at scale\n",
|
||
"\n",
|
||
"Craft agent-appropriate UXs using LangGraph Platform's APIs. Quickly deploy\n",
|
||
"and scale your agent with purpose-built infrastructure. Choose from multiple\n",
|
||
"deployment options.\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"## Dynamic APIs for designing agent UXs.\n",
|
||
"\n",
|
||
"Craft personalized experiences with the long-term memory API to recall\n",
|
||
"information across conversation sessions. Expose, update, and rewind your\n",
|
||
"app's state for better user visibility, steering, and interaction. Kick off\n",
|
||
"long-running background jobs for research-style or multi-step work.\n",
|
||
"\n",
|
||
"[See the docs ](https://langchain-ai.github.io/langgraph/how-tos/streaming-\n",
|
||
"tokens/)\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"## Fault-tolerant scalability.\n",
|
||
"\n",
|
||
"Handle large workloads gracefully with horizontally-scaling servers, task\n",
|
||
"queues, and built-in persistence. Enhance resilience with intelligent caching\n",
|
||
"and automated retries.\n",
|
||
"\n",
|
||
"[Learn more in the blog ](https://langchain-ai.github.io/langgraph/how-\n",
|
||
"tos/streaming-tokens/)\n",
|
||
"\n",
|
||
".gif)\n",
|
||
"\n",
|
||
"## An end-to-end agent experience.\n",
|
||
"\n",
|
||
"Simplify prototyping, debugging, and sharing of agents in our visual LangGraph\n",
|
||
"Studio. Deploy your application with 1-click deploy with our SaaS offering or\n",
|
||
"within your own VPC. Then, monitor app performance with LangSmith.\n",
|
||
"\n",
|
||
"[Discover LangGraph Studio ](https://langchain-ai.github.io/langgraph/how-\n",
|
||
"tos/streaming-tokens/)\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"## Introduction to LangGraph\n",
|
||
"\n",
|
||
"Learn the basics of LangGraph in this LangChain Academy Course. You'll learn\n",
|
||
"how to build agents that automate real-world tasks with LangGraph\n",
|
||
"orchestration.\n",
|
||
"\n",
|
||
"[Enroll for free](https://academy.langchain.com/courses/intro-to-\n",
|
||
"langgraph)[Book enterprise\n",
|
||
"training](https://airtable.com/appGjCAN6126Jm7K8/pagNAp7niHQzRH8zk/form)\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"## Deploy agents at scale, monitor carefully, iterate boldly\n",
|
||
"\n",
|
||
"Design agent-driven user experiences with LangGraph Platform's APIs. Quickly\n",
|
||
"deploy and scale your application with infrastructure built for agents. Choose\n",
|
||
"from multiple deployment options.\n",
|
||
"\n",
|
||
"### Fault-tolerant scalability\n",
|
||
"\n",
|
||
"Handle large workloads gracefully with horizontally-scaling servers, task\n",
|
||
"queues, and built-in persistence. Enhance resilience with intelligent caching\n",
|
||
"and automated retries.\n",
|
||
"\n",
|
||
"### Dynamic APIs for designing agent experience\n",
|
||
"\n",
|
||
"Craft personalized user experiences with APIs featuring long-term memory to\n",
|
||
"recall information across conversation sessions. Track, update, and rewind\n",
|
||
"your app's state for easy human steering and interaction. Kick off long-\n",
|
||
"running background jobs for research-style or multi-step work.\n",
|
||
"\n",
|
||
"### Integrated developer experience\n",
|
||
"\n",
|
||
"Simplify prototyping, debugging, and sharing of agents in our visual LangGraph\n",
|
||
"Studio. Deploy your application with 1-click deploy with our SaaS offering or\n",
|
||
"within your own VPC. Then, monitor app performance with LangSmith.\n",
|
||
"\n",
|
||
"### Trusted by companies taking agency in AI innovation:\n",
|
||
"\n",
|
||
"LangGraph helps teams of all sizes, across all industries, from ambitious\n",
|
||
"startups to established enterprises.\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“LangChain is streets ahead with what they've put forward with LangGraph.\n",
|
||
"LangGraph sets the foundation for how we can build and scale AI workloads —\n",
|
||
"from conversational agents, complex task automation, to custom LLM-backed\n",
|
||
"experiences that 'just work'. The next chapter in building complex production-\n",
|
||
"ready features with LLMs is agentic, and with LangGraph and LangSmith,\n",
|
||
"LangChain delivers an out-of-the-box solution to iterate quickly, debug\n",
|
||
"immediately, and scale effortlessly.”\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"Garrett Spong\n",
|
||
"\n",
|
||
"Principal SWE\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“LangGraph has been instrumental for our AI development. Its robust framework\n",
|
||
"for building stateful, multi-actor applications with LLMs has transformed how\n",
|
||
"we evaluate and optimize the performance of our AI guest-facing solutions.\n",
|
||
"LangGraph enables granular control over the agent's thought process, which has\n",
|
||
"empowered us to make data-driven and deliberate decisions to meet the diverse\n",
|
||
"needs of our guests.”\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"Andres Torres\n",
|
||
"\n",
|
||
"Sr. Solutions Architect\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“It's easy to build the prototype of a coding agent, but deceptively hard to\n",
|
||
"improve its reliability. Replit wants to give a coding agent to millions of\n",
|
||
"users — reliability is our top priority, and will remain so for a long time.\n",
|
||
"LangGraph is giving us the control and ergonomics we need to build and ship\n",
|
||
"powerful coding agents.”\n",
|
||
"\n",
|
||
"“As Ally advances its exploration of Generative AI,\n",
|
||
"\n",
|
||
"%201.webp)\n",
|
||
"\n",
|
||
"Michele Catasta\n",
|
||
"\n",
|
||
"President\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“As Ally advances its exploration of Generative AI, our tech labs is excited\n",
|
||
"by LangGraph, the new library from LangChain, which is central to our\n",
|
||
"experiments with multi-actor agentic workflows. We are committed to deepening\n",
|
||
"our partnership with LangChain.”\n",
|
||
"\n",
|
||
"“As Ally advances its exploration of Generative AI,\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"Sathish Muthukrishnan\n",
|
||
"\n",
|
||
"Chief Information, Data and Digital Officer\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“LangChain is streets ahead with what they've put forward with LangGraph.\n",
|
||
"LangGraph sets the foundation for how we can build and scale AI workloads —\n",
|
||
"from conversational agents, complex task automation, to custom LLM-backed\n",
|
||
"experiences that 'just work'. The next chapter in building complex production-\n",
|
||
"ready features with LLMs is agentic, and with LangGraph and LangSmith,\n",
|
||
"LangChain delivers an out-of-the-box solution to iterate quickly, debug\n",
|
||
"immediately, and scale effortlessly.”\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"Garrett Spong\n",
|
||
"\n",
|
||
"Principal SWE\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“LangGraph has been instrumental for our AI development. Its robust framework\n",
|
||
"for building stateful, multi-actor applications with LLMs has transformed how\n",
|
||
"we evaluate and optimize the performance of our AI guest-facing solutions.\n",
|
||
"LangGraph enables granular control over the agent's thought process, which has\n",
|
||
"empowered us to make data-driven and deliberate decisions to meet the diverse\n",
|
||
"needs of our guests.”\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"Andres Torres\n",
|
||
"\n",
|
||
"Sr. Solutions Architect\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“It's easy to build the prototype of a coding agent, but deceptively hard to\n",
|
||
"improve its reliability. Replit wants to give a coding agent to millions of\n",
|
||
"users — reliability is our top priority, and will remain so for a long time.\n",
|
||
"LangGraph is giving us the control and ergonomics we need to build and ship\n",
|
||
"powerful coding agents.”\n",
|
||
"\n",
|
||
"“As Ally advances its exploration of Generative AI,\n",
|
||
"\n",
|
||
"%201.webp)\n",
|
||
"\n",
|
||
"Michele Catasta\n",
|
||
"\n",
|
||
"President\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"“As Ally advances its exploration of Generative AI, our tech labs is excited\n",
|
||
"by LangGraph, the new library from LangChain, which is central to our\n",
|
||
"experiments with multi-actor agentic workflows. We are committed to deepening\n",
|
||
"our partnership with LangChain.”\n",
|
||
"\n",
|
||
"“As Ally advances its exploration of Generative AI,\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"Sathish Muthukrishnan\n",
|
||
"\n",
|
||
"Chief Information, Data and Digital Officer\n",
|
||
"\n",
|
||
"## LangGraph FAQs\n",
|
||
"\n",
|
||
"Do I need to use LangChain to use LangGraph? What’s the difference?\n",
|
||
"\n",
|
||
"No. LangGraph is an orchestration framework for complex agentic systems and is\n",
|
||
"more low-level and controllable than LangChain agents. LangChain provides a\n",
|
||
"standard interface to interact with models and other components, useful for\n",
|
||
"straight-forward chains and retrieval flows.\n",
|
||
"\n",
|
||
"How is LangGraph different from other agent frameworks?\n",
|
||
"\n",
|
||
"Other agentic frameworks can work for simple, generic tasks but fall short for\n",
|
||
"complex tasks bespoke to a company’s needs. LangGraph provides a more\n",
|
||
"expressive framework to handle companies’ unique tasks without restricting\n",
|
||
"users to a single black-box cognitive architecture.\n",
|
||
"\n",
|
||
"Does LangGraph impact the performance of my app?\n",
|
||
"\n",
|
||
"LangGraph will not add any overhead to your code and is specifically designed\n",
|
||
"with streaming workflows in mind.\n",
|
||
"\n",
|
||
"Is LangGraph open source? Is it free?\n",
|
||
"\n",
|
||
"Yes. LangGraph is an MIT-licensed open-source library and is free to use.\n",
|
||
"\n",
|
||
"How are LangGraph and LangGraph Platform different?\n",
|
||
"\n",
|
||
"LangGraph is a stateful, orchestration framework that brings added control to\n",
|
||
"agent workflows. LangGraph Platform is a service for deploying and scaling\n",
|
||
"LangGraph applications, with an opinionated API for building agent UXs, plus\n",
|
||
"an integrated developer studio.\n",
|
||
"\n",
|
||
"LangGraph (open source)\n",
|
||
"\n",
|
||
"LangGraph Platform\n",
|
||
"\n",
|
||
"Features\n",
|
||
"\n",
|
||
"Stateful orchestration framework for agentic applications\n",
|
||
"\n",
|
||
"Scalable infrastructure for deploying LangGraph applications \n",
|
||
"\n",
|
||
"Python and JavaScript\n",
|
||
"\n",
|
||
"Python and JavaScript \n",
|
||
"\n",
|
||
"None\n",
|
||
"\n",
|
||
"Yes - useful for retrieving & updating state or long-term memory, or creating\n",
|
||
"a configurable assistant \n",
|
||
"\n",
|
||
"Basic\n",
|
||
"\n",
|
||
"Dedicated mode for token-by-token messages \n",
|
||
"\n",
|
||
"Community contributed\n",
|
||
"\n",
|
||
"Supported out-of-the-box \n",
|
||
"\n",
|
||
"Self-managed\n",
|
||
"\n",
|
||
"Managed Postgres with efficient storage \n",
|
||
"\n",
|
||
"Self-managed\n",
|
||
"\n",
|
||
"\\- Cloud SaaS \n",
|
||
"\\- Free self-hosted \n",
|
||
"\\- Enterprise \n",
|
||
"(BYOC or paid self-hosted) \n",
|
||
"\n",
|
||
"Self-managed\n",
|
||
"\n",
|
||
"Auto-scaling of task queues and servers \n",
|
||
"\n",
|
||
"Self-managed\n",
|
||
"\n",
|
||
"Automated retries \n",
|
||
"\n",
|
||
"Simple threading\n",
|
||
"\n",
|
||
"Supports double-texting \n",
|
||
"\n",
|
||
"None\n",
|
||
"\n",
|
||
"Cron scheduling \n",
|
||
"\n",
|
||
"None\n",
|
||
"\n",
|
||
"Integrated with LangSmith for observability \n",
|
||
"\n",
|
||
"LangGraph Studio for Desktop\n",
|
||
"\n",
|
||
"LangGraph Studio for Desktop & Cloud \n",
|
||
"\n",
|
||
"What are my deployment options for LangGraph Platform?\n",
|
||
"\n",
|
||
"We currently have the following deployment options for LangGraph applications: \n",
|
||
" \n",
|
||
"**Self-Hosted Lite** : A free (up to 1M nodes executed), limited version of\n",
|
||
"LangGraph Platform that you can run locally or in a self-hosted manner. This\n",
|
||
"version requires a LangSmith API key and logs all usage to LangSmith. Fewer\n",
|
||
"features are available than in paid plans. \n",
|
||
"**Cloud SaaS:** Fully managed and hosted as part of LangSmith, with automatic\n",
|
||
"updates and zero maintenance. \n",
|
||
"**Bring Your Own Cloud (BYOC):** Deploy LangGraph Platform within your VPC,\n",
|
||
"provisioned and run as a service. Keep data in your environment while\n",
|
||
"outsourcing the management of the service. \n",
|
||
"**Self-Hosted Enterprise:** Deploy LangGraph entirely on your own\n",
|
||
"infrastructure.\n",
|
||
"\n",
|
||
"Is LangGraph Platform open source?\n",
|
||
"\n",
|
||
"No. LangGraph Platform is proprietary software. \n",
|
||
" \n",
|
||
"There is a free, self-hosted version of LangGraph Platform with access to\n",
|
||
"basic features. The Cloud SaaS deployment option is free while in beta, but\n",
|
||
"will eventually be a paid service. We will always give ample notice before\n",
|
||
"charging for a service and reward our early adopters with preferential\n",
|
||
"pricing. The Bring Your Own Cloud (BYOC) and Self-Hosted Enterprise options\n",
|
||
"are also paid services. [Contact our sales team](/contact-sales) to learn\n",
|
||
"more. \n",
|
||
" \n",
|
||
"For more information, see our [LangGraph Platform pricing page](/pricing-\n",
|
||
"langgraph-platform).\n",
|
||
"\n",
|
||
"## Ready to start shipping reliable GenAI apps faster?\n",
|
||
"\n",
|
||
"Get started with LangChain, LangSmith, and LangGraph to enhance your LLM app\n",
|
||
"development, from prototype to production.\n",
|
||
"\n",
|
||
"[Contact Us](/contact-sales)[Sign Up](https://smith.langchain.com/)\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"LangGraph is a flexible framework designed for building and scaling agentic applications. It allows for complex task handling and human-agent collaboration, supporting various control flows such as single-agent, multi-agent, hierarchical, and sequential. Key features include:\n",
|
||
"\n",
|
||
"- **Statefulness**: LangGraph agents maintain context over time, enabling smooth interactions.\n",
|
||
"- **Streaming Support**: It provides native token-by-token streaming for better user experience.\n",
|
||
"- **Moderation and Quality Loops**: These features ensure agents remain reliable and on course.\n",
|
||
"- **Dynamic APIs**: LangGraph offers APIs for crafting personalized user experiences and managing long-term memory.\n",
|
||
"- **Deployment Options**: It supports various deployment methods, including self-hosted and cloud solutions.\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import asyncio\n",
|
||
"\n",
|
||
"from langchain_openai import ChatOpenAI\n",
|
||
"\n",
|
||
"from browser_use import Agent, Browser, BrowserConfig\n",
|
||
"\n",
|
||
"# Basic configuration for the browser\n",
|
||
"config = BrowserConfig(\n",
|
||
"\theadless=True, # Run in headless mode\n",
|
||
"\t# disable_security=True # Uncomment if you want to disable security\n",
|
||
")\n",
|
||
"\n",
|
||
"# Initialize the browser with the specified configuration\n",
|
||
"browser = Browser(config=config)\n",
|
||
"\n",
|
||
"\n",
|
||
"async def main():\n",
|
||
"\t# Initialize the agent with the task and language model\n",
|
||
"\tagent = Agent(\n",
|
||
"\t\ttask='What is Langgraph',\n",
|
||
"\t\tllm=llm, # Replace with your LLM configuration\n",
|
||
"\t\tbrowser=browser,\n",
|
||
"\t\tgenerate_gif=False, # Disable GIF generation\n",
|
||
"\t)\n",
|
||
"\n",
|
||
"\t# Run the agent and get results asynchronously\n",
|
||
"\tresult = await agent.run()\n",
|
||
"\n",
|
||
"\t# Process results token-wise\n",
|
||
"\tfor action in result.action_results():\n",
|
||
"\t\tprint(action.extracted_content, end='\\r', flush=True)\n",
|
||
"\t\tprint('\\n\\n')\n",
|
||
"\t\t# if action.is_done:\n",
|
||
"\t\t# print(action.extracted_content)\n",
|
||
"\n",
|
||
"\t# Close the browser after completion\n",
|
||
"\tawait browser.close()\n",
|
||
"\n",
|
||
"\n",
|
||
"# Run the asynchronous main function\n",
|
||
"asyncio.run(main())"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 11,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "TFK-fNoLDFcF",
|
||
"outputId": "d78fbeae-c8f0-4c26-e0e3-7a0a683d3fc1"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"AgentHistoryList(all_results=[ActionResult(is_done=False, extracted_content='🔍 Searched for \"What is LangChain?\" in Google', error=None, include_in_memory=True), ActionResult(is_done=False, extracted_content=\"📄 Extracted page as markdown\\n: # Filters and Topics\\n\\n[All](/search?sca_esv=4c6b8dc13bab3e46&q=What+is+LangChain%3F&source=lnms&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ0pQJegQIEhAB)\\n\\n[Images](/search?sca_esv=4c6b8dc13bab3e46&q=What+is+LangChain%3F&udm=2&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQtKgLegQIExAB)\\n\\n[Videos](/search?sca_esv=4c6b8dc13bab3e46&q=What+is+LangChain%3F&udm=7&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQtKgLegQIERAB)\\n\\n[Forums](/search?sca_esv=4c6b8dc13bab3e46&q=What+is+LangChain%3F&udm=18&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQs6gLegQIDxAB)\\n\\nWeb\\n\\n[Flights](/travel/flights?sca_esv=4c6b8dc13bab3e46&output=search&q=What+is+LangChain%3F&source=lnms&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&ved=1t:200715&ictx=111)\\n\\n[Finance](/finance?sca_esv=4c6b8dc13bab3e46&output=search&q=What+is+LangChain%3F&source=lnms&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ0pQJegQIDBAB)\\n\\nMore\\n\\n[Books](/search?sca_esv=4c6b8dc13bab3e46&q=What+is+LangChain%3F&udm=36&source=lnms&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ0pQJegQINxAB)\\n\\n[News](/search?sca_esv=4c6b8dc13bab3e46&q=What+is+LangChain%3F&tbm=nws&source=lnms&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ0pQJegQINhAB)\\n\\n[Shopping](/search?sca_esv=4c6b8dc13bab3e46&q=What+is+LangChain%3F&udm=28&fbs=AEQNm0Aa4sjWe7Rqy32pFwRj0UkWd8nbOJfsBGGB5IQQO6L3JyWp6w6_rxLPe8F8fpm5a55blYtaduielx1say4YCS0EIyvBb6VkaLhDZSOnSC94tp-\\nJuFEDkvqUl_u6quB-Is11hrT6R6Y6jGPIGI0MqGRIdRYfHHK4Fm5f9UNWxYphEnPjChpmH-\\nusjmkJN6Sk444PHRuqJvihdKgoqwGrUjYjqVvmxA&ved=1t:220175&ictx=111)\\n\\nTools\\n\\nAny time\\n\\nAny time\\n\\n[Past\\nhour](/search?q=What+is+LangChain%3F&sca_esv=4c6b8dc13bab3e46&udm=14&source=lnt&tbs=qdr:h&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQpwV6BAgGEAc)\\n\\n[Past 24\\nhours](/search?q=What+is+LangChain%3F&sca_esv=4c6b8dc13bab3e46&udm=14&source=lnt&tbs=qdr:d&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQpwV6BAgGEAg)\\n\\n[Past\\nweek](/search?q=What+is+LangChain%3F&sca_esv=4c6b8dc13bab3e46&udm=14&source=lnt&tbs=qdr:w&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQpwV6BAgGEAk)\\n\\n[Past\\nmonth](/search?q=What+is+LangChain%3F&sca_esv=4c6b8dc13bab3e46&udm=14&source=lnt&tbs=qdr:m&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQpwV6BAgGEAo)\\n\\n[Past\\nyear](/search?q=What+is+LangChain%3F&sca_esv=4c6b8dc13bab3e46&udm=14&source=lnt&tbs=qdr:y&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQpwV6BAgGEAs)\\n\\nCustom range...\\n\\nCustom date range\\n\\nFromTo\\n\\nGo\\n\\nAll results\\n\\nAll results\\n\\n[Verbatim](/search?q=What+is+LangChain%3F&sca_esv=4c6b8dc13bab3e46&udm=14&source=lnt&tbs=li:1&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQpwV6BAgGEBM)\\n\\n[ Advanced Search\\n](https://www.google.com/advanced_search?q=What+is+LangChain%3F&udm=14)\\n\\nCtrl+Shift+X to select\\n\\n\\n\\n# Search settings\\n\\n[Search CustomizationOff](/history/optout?hl=en)\\n\\n[SafeSearchBlurring\\non](/safesearch?prev=https://www.google.com/search?q%3DWhat%2Bis%2BLangChain?%26udm%3D14&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8JsIegQIChAH)\\n\\n[LanguageEnglish](/preferences?lang=1&hl=en&prev=https://www.google.com/search?q%3DWhat%2Bis%2BLangChain%253F%26sca_esv%3D4c6b8dc13bab3e46%26udm%3D14#languages)\\n\\n[Dark themeDevice\\ndefault](/setprefs?hl=en&prev=https://www.google.com/search?q%3DWhat%2Bis%2BLangChain?%26udm%3D14%26pccc%3D1&sig=0_jfSkJcafppJyKAIkCWZpHFXzfrs%3D&cs=2&sa=X&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQqsEHegQIChAJ&ictx=1)\\n\\n[More\\nsettings](/preferences?hl=en&prev=https://www.google.com/search?q%3DWhat%2Bis%2BLangChain%253F%26sca_esv%3D4c6b8dc13bab3e46%26udm%3D14)\\n\\nSend feedback\\n\\n[Help](https://support.google.com/websearch/?p=dsrp_search_hc&hl=en) •\\n[Privacy](https://policies.google.com/privacy?hl=en&fg=1) •\\n[Terms](https://policies.google.com/terms?hl=en&fg=1)\\n\\n# Search Results\\n\\n[ \\nLangChainLangChainhttps://www.langchain.com](https://www.langchain.com/)\\n\\nLangChain\\n\\nhttps://www.langchain.com\\n\\n _LangChain_ is a composable framework to build with LLMs. LangGraph is the\\norchestration framework for controllable agentic workflows. Run.\\n\\n\\u200e[Docs](https://python.langchain.com/docs/introduction/) ·\\n\\u200e[Products](https://www.langchain.com/langchain) · \\u200e[LangChain\\nAcademy](https://academy.langchain.com/) · \\u200e[Join the LangChain\\nCommunity](https://www.langchain.com/join-community)\\n\\n[ \\nWhat is\\nLangChain?Amazon\\nWeb Serviceshttps://aws.amazon.com › ... › Generative\\nAI](https://aws.amazon.com/what-is/langchain/)\\n\\nAmazon Web Services\\n\\nhttps://aws.amazon.com › ... › Generative AI\\n\\nLangChain _provides AI developers with tools to connect language models with\\nexternal data sources_. It is open-source and supported by an active\\ncommunity.\\n\\n[ \\nWhat Is LangChain and How to Use It: A\\nGuideTechTargethttps://www.techtarget.com\\n› definition ›\\nLangChain](https://www.techtarget.com/searchenterpriseai/definition/LangChain)\\n\\nTechTarget\\n\\nhttps://www.techtarget.com › definition › LangChain\\n\\n _LangChain is an open source framework_ that enables software developers\\nworking with artificial intelligence (AI) and its machine learning subset to\\ncombine ...\\n\\n[ \\nIntroduction | 🦜️ LangChainLangChainhttps://python.langchain.com › docs › introduction](https://python.langchain.com/docs/introduction/)\\n\\nLangChain\\n\\nhttps://python.langchain.com › docs › introduction\\n\\n _LangChain_ is a framework for developing applications powered by large\\nlanguage models (LLMs). LangChain simplifies every stage of the LLM\\napplication lifecycle.\\n\\n\\u200e[Introduction](https://python.langchain.com/v0.1/docs/get_started/introduction/)\\n·\\n\\u200e[Langchain.agents...](https://api.python.langchain.com/en/latest/agents/langchain.agents.tool_calling_agent.base.create_tool_calling_agent.html)\\n· \\u200e[LangChain v0.3](https://python.langchain.com/docs/versions/v0_3/) ·\\n\\u200e[Langchain_core.tools.](https://api.python.langchain.com/en/latest/tools/langchain_core.tools.tool.html)\\n\\n[ \\nWhat Is\\nLangChain?IBMhttps://www.ibm.com\\n› think › topics › langchain](https://www.ibm.com/think/topics/langchain)\\n\\nIBM\\n\\nhttps://www.ibm.com › think › topics › langchain\\n\\nLangChain is essentially _a library of abstractions for Python and Javascript_\\n, representing common steps and concepts necessary to work with language\\nmodels.\\n\\n[ \\nWhat is\\nLangChain?YouTube\\n· IBM Technology287.6K+ views · 10 months\\nago](https://www.youtube.com/watch?v=1bUy-1hGZpI)\\n\\nYouTube · IBM Technology\\n\\n287.6K+ views · 10 months ago\\n\\nLang chain is _an open-source orchestration framework_ for the development of\\napplications that use large language models.\\n\\n[ \\nWhat is Langchain and why should I care as a\\ndeveloper?Medium\\n· Logan Kilpatrick370+ likes · 1 year ago](https://medium.com/around-the-\\nprompt/what-is-langchain-and-why-should-i-care-as-a-developer-b2d952c42b28)\\n\\nMedium · Logan Kilpatrick\\n\\n370+ likes · 1 year ago\\n\\n _Langchain_ makes creating agents using large language models simple through\\ntheir agents API. Developers can use OpenAI functions or other means ...\\n\\n[ \\nLangChainWikipediahttps://en.wikipedia.org\\n› wiki › LangChain](https://en.wikipedia.org/wiki/LangChain)\\n\\nWikipedia\\n\\nhttps://en.wikipedia.org › wiki › LangChain\\n\\nLangChain is a software framework that helps facilitate the integration of\\nlarge language models (LLMs) into applications.\\n\\n\\u200e[History](https://en.wikipedia.org/wiki/LangChain#History) ·\\n\\u200e[Capabilities](https://en.wikipedia.org/wiki/LangChain#Capabilities) ·\\n\\u200e[LangChain tools](https://en.wikipedia.org/wiki/LangChain#LangChain_tools)\\n\\n[ \\nWhat Is LangChain? A Complete Comprehensive\\nOverviewDataStaxhttps://www.datastax.com\\n› guides › what-is-langchain](https://www.datastax.com/guides/what-is-\\nlangchain)\\n\\nDataStax\\n\\nhttps://www.datastax.com › guides › what-is-langchain\\n\\nNov 9, 2023 — LangChain is _a Python framework designed to streamline AI\\napplication development_ , focusing on real-time data processing and\\nintegration with ...\\n\\n[ \\nWhat Is\\nLangChain?Google\\nCloudhttps://cloud.google.com › use-cases ›\\nlangchain](https://cloud.google.com/use-cases/langchain)\\n\\nGoogle Cloud\\n\\nhttps://cloud.google.com › use-cases › langchain\\n\\n _LangChain_ is a programming language platform that lets developers construct\\nand connect models to access, transform, and share data seamlessly.\\n\\n\\u200e[Langchain And Ai](https://cloud.google.com/use-\\ncases/langchain#:~:text=LangChain%20and%20AI) · \\u200e[How Does Langchain\\nWork?](https://cloud.google.com/use-\\ncases/langchain#:~:text=How%20does%20LangChain%20work%3F) · \\u200e[Key Features Of\\nLangchain](https://cloud.google.com/use-\\ncases/langchain#:~:text=Key%20features%20of%20LangChain)\\n\\n# Page Navigation\\n\\n| 1|\\n[2](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=10&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAE)|\\n[3](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=20&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAG)|\\n[4](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=30&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAI)|\\n[5](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=40&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAK)|\\n[6](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=50&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAM)|\\n[7](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=60&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAO)|\\n[8](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=70&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAQ)|\\n[9](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=80&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAS)|\\n[10](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=90&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8tMDegQICBAU)|\\n[Next](/search?q=What+is+LangChain?&sca_esv=4c6b8dc13bab3e46&udm=14&ei=e8iJZ425Mabg0PEP6LmQGQ&start=10&sa=N&sstk=ATObxK4t7c6xZe8J3zQzlUfrNV-\\nBchujCI0GxH83wgy_vu9jEqYrHuTxd0wVBzubCa-bn_k1uK_Zn1BBIfr2yh6eyUzMdvUxFJ-\\nmCw&ved=2ahUKEwjN4oy74vuKAxUmMDQIHegcJAMQ8NMDegQICBAW) \\n---|---|---|---|---|---|---|---|---|---|---|--- \\n \\n# Footer Links\\n\\nWasco County, Oregon \\\\- From your IP address\\n\\n\\\\-\\n\\nUpdate location\\n\\nCan't update your locationLearn more\\n\\nUpdating location...\\n\\n[Help](https://support.google.com/websearch/?p=ws_results_help&hl=en&fg=1)Send\\nfeedback[Privacy](https://policies.google.com/privacy?hl=en&fg=1)[Terms](https://policies.google.com/terms?hl=en&fg=1)\\n\\n\\n\", error=None, include_in_memory=False), ActionResult(is_done=True, extracted_content='LangChain is a composable framework designed for building applications with large language models (LLMs). It simplifies the integration of language models with external data sources and is open-source, supported by an active community. LangChain provides tools for developers to streamline the application lifecycle of LLMs.', error=None, include_in_memory=False)], all_model_outputs=[{'search_google': {'query': 'What is LangChain?'}}, {'extract_content': {'include_links': True}}, {'done': {'text': 'LangChain is a composable framework designed for building applications with large language models (LLMs). It simplifies the integration of language models with external data sources and is open-source, supported by an active community. LangChain provides tools for developers to streamline the application lifecycle of LLMs.'}}])\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"# from browser_use import Agent\n",
|
||
"import asyncio\n",
|
||
"\n",
|
||
"from langchain_openai import ChatOpenAI\n",
|
||
"\n",
|
||
"from browser_use import Browser, BrowserConfig\n",
|
||
"\n",
|
||
"# Basic configuration\n",
|
||
"config = BrowserConfig(\n",
|
||
"\theadless=True,\n",
|
||
"\t# disable_security=True\n",
|
||
")\n",
|
||
"# Reuse existing browser\n",
|
||
"browser = Browser(config=config)\n",
|
||
"# async def main():\n",
|
||
"agent = Agent(\n",
|
||
"\ttask='what is langchain',\n",
|
||
"\tllm=llm,\n",
|
||
"\tbrowser=browser,\n",
|
||
"\tgenerate_gif=False, # Browser instance will be reused\n",
|
||
")\n",
|
||
"\n",
|
||
"result = await agent.run()\n",
|
||
"print(result)\n",
|
||
"# Manually close the browser\n",
|
||
"# asyncio.run(main())\n",
|
||
"await browser.close()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 27,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "nKGC936xODry",
|
||
"outputId": "de70d715-c30a-4d5b-9d25-40bd79d410de"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"LangChain is a composable framework designed for building applications with large language models (LLMs). It simplifies the integration of language models with external data sources and is open-source, supported by an active community. LangChain provides tools for developers to streamline the application lifecycle of LLMs.\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"# display(result.action_results())\n",
|
||
"for action in result.action_results():\n",
|
||
"\tif action.is_done:\n",
|
||
"\t\tprint(action.extracted_content)"
|
||
]
|
||
}
|
||
],
|
||
"metadata": {
|
||
"colab": {
|
||
"provenance": []
|
||
},
|
||
"kernelspec": {
|
||
"display_name": "Python 3",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"name": "python"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 0
|
||
}
|