Skip to main content

A Langchain integration for the Linkup API

Project description

⚡ Langchain Linkup

PyPI version License: MIT

A LangChain integration for the Linkup API, allowing easy integration with Linkup's services. 🔗

🌟 Features

  • 🔗 Simple LangChain components to cover all Linkup API use cases.
  • 🔍 Supports both standard and deep search queries.
  • Supports synchronous and asynchronous requests.
  • 🔒 Handles authentication and request management.

📦 Installation

Simply install the LangChain integration using pip:

pip install langchain-linkup

🛠️ Usage

Setting Up Your Environment

  1. 🔑 Obtain an API Key:

    Sign up on Linkup to get your API key.

  2. ⚙️ Set-up the API Key:

    Option 1: Export the LINKUP_API_KEY environment variable in your shell before using the Linkup LangChain component.

    export LINKUP_API_KEY='YOUR_LINKUP_API_KEY'
    

    Option 2: Set the LINKUP_API_KEY environment variable directly within Python, using for instance os.environ or python-dotenv with a .env file (python-dotenv needs to be installed separately in this case), before creating the Linkup LangChain component.

    import os
    from langchain_linkup import LinkupSearchRetriever
    
    os.environ["LINKUP_API_KEY"] = "YOUR_LINKUP_API_KEY"
    # or dotenv.load_dotenv()
    retriever = LinkupSearchRetriever(...)
    ...
    

    Option 3: Pass the Linkup API key to the Linkup LangChain component when creating it.

    from langchain_linkup import LinkupSearchRetriever
    
    retriever = LinkupSearchRetriever(api_key="YOUR_LINKUP_API_KEY", ...)
    ...
    

📋 Example

All search queries can be used with 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 concurrents?")

🔍 Linkup Search Retriever

A retriever is a LangChain component which simply retrieves documents based on a query. It is typically the first step of a RAG (Retrival Augmented Generation) pipeline. See this page for more information. The LinkupSearchRetriever makes available the Linkup API search as a LangChain retriever.

from langchain_linkup import LinkupSearchRetriever

# Initialize the LangChain component (API key can be read from the environment variable or passed as
# an argument)
retriever = LinkupSearchRetriever(
    depth="deep",  # "standard" or "deep"
)

# Perform a search query
documents = retriever.invoke(input="What is Linkup, the new French AI startup?")
print(documents)

⚒️ Linkup Search Tool

A tool is a LangChain component which enables agents to perform a specific task, like a web search. Tools are designed to be called autonomously by the agent, and their output is fed back to the agent, allowing them to perform some kind of reasoning based on the tool usage. See this page for more information. The LinkupSearchTool makes available the Linkup API search as a LangChain tool.

from langchain_linkup import LinkupSearchTool

# Initialize the LangChain component (API key can be read from the environment variable or passed as
# an argument)
tool = LinkupSearchTool(
    depth="deep",  # "standard" or "deep"
    output_type="searchResults",  # "searchResults", "sourcedAnswer" or "structured"
)

# Perform a search query
search_results = tool.invoke(input="What is Linkup, the new French AI startup?")
print(search_results)

📚 More Examples

See the examples/ directory for more contextualized examples and documentation, for instance on how to use the Linkup Search Retriever in a simple RAG pipeline.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_linkup-0.2.1.tar.gz (171.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_linkup-0.2.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_linkup-0.2.1.tar.gz.

File metadata

  • Download URL: langchain_linkup-0.2.1.tar.gz
  • Upload date:
  • Size: 171.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_linkup-0.2.1.tar.gz
Algorithm Hash digest
SHA256 959401f5340e522bfff047e97396abe48e19a4df3a5b47f892b33c747ee0021c
MD5 2eaa691e15d3aa78d599105d8b631211
BLAKE2b-256 d6eda82e897f98f60f0eba765b1667ac620993cbb81c1cc4230ddf22b0c6b4ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_linkup-0.2.1.tar.gz:

Publisher: release.yml on LinkupPlatform/langchain-linkup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_linkup-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_linkup-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 959e84523d756080aa7045be078d9ac43869be926fd5be3596128ece984170a3
MD5 4c0de461fe146138d821c487df518dd2
BLAKE2b-256 d88246a8878d5d2fb002c40373fc4678818ccb809adb4efa8054b911b7347e94

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_linkup-0.2.1-py3-none-any.whl:

Publisher: release.yml on LinkupPlatform/langchain-linkup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page