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.1.5.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

langchain_linkup-0.1.5-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_linkup-0.1.5.tar.gz
Algorithm Hash digest
SHA256 69287db3a5137e32b05e8faeafbb055b57b728a2a644a9d04d2b928ae264258f
MD5 e65d8eab6a87f850f08e35f3c15f5dc5
BLAKE2b-256 46bf881492dbcb77459e83c47914e5387a0741b4eb05b41c5ec047bfe77253c1

See more details on using hashes here.

Provenance

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

Publisher: publish-to-pypi.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.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_linkup-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0a288e2b13871773e211bfd514d630f81ee6f2cc21c20ea758236d5c214f2361
MD5 50e4f5ca62ab0139cc53960667232d04
BLAKE2b-256 86b1c9bbc40ac1d909b3c7e6e59a62dcf5b5894da5d4ae720dfef9720370a7b1

See more details on using hashes here.

Provenance

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

Publisher: publish-to-pypi.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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page