Skip to main content

How to Set Up Aluvia With LangChain

Integrating Aluvia with LangChain enhances LLM-powered agents with reliable, scalable web connectivity using Aluvia's mobile network infrastructure for real-world applications.

The langchain-aluvia-webbrowser package is the official LangChain integration for Aluvia, providing AluviaWebBrowser - a LangChain WebBrowser tool that uses Aluvia's mobile network connectivity to browse websites and extract information. This tool is fully compatible with LangChain's WebBrowser and can be used as a drop-in replacement.

The tool is described to agents as:

"aluvia-powered web browser - useful for when you need to find something on or summarize a webpage. input should be a comma separated list of 'valid URL including protocol','what you want to find on the page or empty string for a summary'."

How to Integrate Aluvia With LangChain

1

Obtain Your Aluvia Token

💡Tip

Your Aluvia Token looks like: 2dceb1aa0***************************

2

Install the Aluvia Integration

Install the Aluvia integration package for LangChain by running the following command:

npm install langchain-aluvia-webbrowser
3

Set the environment variable

Set your Aluvia token as an environment variable:

ALUVIA_TOKEN="your-aluvia-token";
💡Tip

Or pass it directly when initializing the tool:

import AluviaWebBrowser from "langchain-aluvia-webbrowser";

const browser = new AluviaWebBrowser({
aluviaToken: "your-aluvia-token"
});
4

Use the Aluvia WebBrowser tool

import AluviaWebBrowser from "langchain-aluvia-webbrowser";
import { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai";

export async function run() {
const model = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 });
const embeddings = new OpenAIEmbeddings();

const browser = new AluviaWebBrowser({
model,
embeddings,
aluviaToken: "your-aluvia-token", // or set ALUVIA_TOKEN env var
});

const result = await browser.invoke(
`"https://www.themarginalian.org/2015/04/09/find-your-bliss-joseph-campbell-power-of-myth","who is joseph campbell"`
);

console.log(result);
/*
Joseph Campbell was a mythologist and writer who discussed spirituality,
psychological archetypes, cultural myths, and the mythology of self. He sat down with
Bill Moyers for a lengthy conversation at George Lucas's Skywalker Ranch in
California, which continued the following year at the American Museum of Natural
History in New York. The resulting 24 hours of raw footage were edited down to six
one-hour episodes and broadcast on PBS in 1988, shortly after Campbell's death,
in what became one of the most popular in the history of public television.

Relevant Links:
- [The Holstee Manifesto](http://holstee.com/manifesto-bp)
- [The Silent Music of the Mind: Remembering Oliver Sacks](https://www.themarginalian.org/2015/08/31/remembering-oliver-sacks)
- [Joseph Campbell series](http://billmoyers.com/spotlight/download-joseph-campbell-and-the-power-of-myth-audio/)
- [Bill Moyers](https://www.themarginalian.org/tag/bill-moyers/)
- [books](https://www.themarginalian.org/tag/books/)
*/
}