π¦π Langchain
How to use Linkup with our Langchain SDK
π Overview
Linkup can be used with LangChain as a Retriever. This tutorial shows to set up a basic LangChain pipeline, leveraging Linkup as a Retriever to get contextual information from the internet.
π¦ Installation
Install the LangChain integration using pip
:
π οΈ Usage
Setting Up Your Environment
- π Get an API Key:
Create an API key for free by creating an account on the Linkup App.
-
βοΈ Set-up the API Key:
Option 1: Export the
LINKUP_API_KEY
environment variable in your shell before using the Linkup LangChain component.shellOption 2: Set the
LINKUP_API_KEY
environment variable directly within Python, using for instanceos.environ
or python-dotenv with a.env
file (python-dotenv
needs to be installed separately in this case), before creating the Linkup LangChain component.pythonOption 3: Pass the Linkup API key to the Linkup LangChain component when creating it.
python
Use the Linkup Retriever
You can then use the Linkup retriever to get information on your question from the web.
π Example
Linkup search queries can be used with one of two very different modes:
- with
depth="standard"
, the search will be straightforward and fast, suited for relatively simple queries (e.g. βWhatβs the weather in Paris today?β) - with
depth="deep"
, the search will use an agentic workflow, which makes it in general slower, but it will be able to solve more complex queries (e.g. βWhat is the company profile of LangChain accross the last few years, and how does it compare to its concurrent?β)
π Retriever (Easy)
π€ RAG with the OpenAI LLM (Intermediate)
This is a RAG example using the Linkup API and LangChainβs LCEL (LangChain Expression Language). This RAG uses OpenAI.
You need an API key for Linkup, and another one for OpenAI for the final generation.
You can get an OpenAI API key here.
You can set these keys manually as the LINKUP_API_KEY and OPENAI_API_KEY environment variables, or you can duplicate the file .env.example
in a .env
file, fill the missing values, and the environment variables will be automatically loaded from it. Alternatively, you can replace the corresponding variables below.
Facing issues? Reach out to our engineering team at support@linkup.so