langchain-linkup 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ LINKUP TECHNOLOGIES
2
+ MIT License
3
+
4
+ Copyright (c) 2024 LINKUP TECHNOLOGIES
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.1
2
+ Name: langchain-linkup
3
+ Version: 0.1.0
4
+ Summary: A Langchain integration for the Linkup API
5
+ Home-page: https://github.com/LinkupPlatform/langchain-linkup
6
+ Author: LINKUP TECHNOLOGIES
7
+ Author-email: contact@linkup.so
8
+ License: MIT
9
+ Project-URL: Documentation, https://github.com/LinkupPlatform/langchain-linkup#readme
10
+ Project-URL: Source Code, https://github.com/LinkupPlatform/langchain-linkup
11
+ Project-URL: Issue Tracker, https://github.com/LinkupPlatform/langchain-linkup/issues
12
+ Keywords: linkup api langchain integration search retriever
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Requires-Python: >=3.9,<4.0
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: langchain-core
21
+ Requires-Dist: linkup-sdk>=0.1.7
22
+
23
+ # ⚡ Langchain Linkup
24
+
25
+ [![PyPI version](https://badge.fury.io/py/langchain-linkup.svg)](https://pypi.org/project/langchain-linkup/)
26
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
27
+
28
+ A [LangChain](https://www.langchain.com/) integration for the
29
+ [Linkup API](https://linkup-api.readme.io/reference/getting-started), allowing easy integration with
30
+ Linkup's services. 🔗
31
+
32
+ ## 🌟 Features
33
+
34
+ - 🔗 **Simple LangChain components to cover all Linkup API use cases.**
35
+ - 🔍 **Supports both standard and deep search queries.**
36
+ - ⚡ **Supports synchronous and asynchronous requests.**
37
+ - 🔒 **Handles authentication and request management.**
38
+
39
+ ## 📦 Installation
40
+
41
+ Simply install the LangChain integration using `pip`:
42
+
43
+ ```bash
44
+ pip install langchain-linkup
45
+ ```
46
+
47
+ ## 🛠️ Usage
48
+
49
+ ### Setting Up Your Environment
50
+
51
+ 1. **🔑 Obtain an API Key:**
52
+
53
+ Sign up on Linkup to get your API key.
54
+
55
+ 2. **⚙️ Set-up the API Key:**
56
+
57
+ Option 1: Export the `LINKUP_API_KEY` environment variable in your shell before using the Linkup
58
+ LangChain component.
59
+
60
+ ```bash
61
+ export LINKUP_API_KEY='YOUR_LINKUP_API_KEY'
62
+ ```
63
+
64
+ Option 2: Set the `LINKUP_API_KEY` environment variable directly within Python, using for
65
+ instance `os.environ` or [python-dotenv](https://github.com/theskumar/python-dotenv) with a
66
+ `.env` file (`python-dotenv` needs to be installed separately in this case), before creating the
67
+ Linkup LangChain component.
68
+
69
+ ```python
70
+ import os
71
+ from langchain_linkup import LinkupRetriever
72
+
73
+ os.environ["LINKUP_API_KEY"] = "YOUR_LINKUP_API_KEY"
74
+ # or dotenv.load_dotenv()
75
+ retriever = LinkupRetriever()
76
+ ...
77
+ ```
78
+
79
+ Option 3: Pass the Linkup API key to the Linkup LangChain component when creating it.
80
+
81
+ ```python
82
+ from langchain_linkup import LinkupRetriever
83
+
84
+ retriever = LinkupRetriever(api_key="YOUR_LINKUP_API_KEY")
85
+ ...
86
+ ```
87
+
88
+ ## 📋 Example
89
+
90
+ All search queries can be used with two very different modes:
91
+
92
+ - with `depth="standard"`, the search will be straightforward and fast, suited for relatively simple
93
+ queries (e.g. "What's the weather in Paris today?")
94
+ - with `depth="deep"`, the search will use an agentic workflow, which makes it in general slower,
95
+ but it will be able to solve more complex queries (e.g. "What is the company profile of LangChain
96
+ accross the last few years, and how does it compare to its concurrents?")
97
+
98
+ ### 🔍 Retriever
99
+
100
+ ```python
101
+ from langchain_linkup import LinkupRetriever
102
+
103
+ # Initialize the LangChain component (API key can be read from the environment variable or passed as
104
+ # an argument)
105
+ retriever = LinkupRetriever(
106
+ depth="deep", # "standard" or "deep"
107
+ )
108
+
109
+ # Perform a search query
110
+ documents = retriever.invoke(input="What is Linkup, the new French AI startup?")
111
+ print(documents)
112
+ ```
113
+
114
+ ### 📚 More Examples
115
+
116
+ See the `examples/` directory for more examples and documentation, for instance on how to use the
117
+ Linkup retriever in a simple RAG pipeline.
@@ -0,0 +1,95 @@
1
+ # ⚡ Langchain Linkup
2
+
3
+ [![PyPI version](https://badge.fury.io/py/langchain-linkup.svg)](https://pypi.org/project/langchain-linkup/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
+
6
+ A [LangChain](https://www.langchain.com/) integration for the
7
+ [Linkup API](https://linkup-api.readme.io/reference/getting-started), allowing easy integration with
8
+ Linkup's services. 🔗
9
+
10
+ ## 🌟 Features
11
+
12
+ - 🔗 **Simple LangChain components to cover all Linkup API use cases.**
13
+ - 🔍 **Supports both standard and deep search queries.**
14
+ - ⚡ **Supports synchronous and asynchronous requests.**
15
+ - 🔒 **Handles authentication and request management.**
16
+
17
+ ## 📦 Installation
18
+
19
+ Simply install the LangChain integration using `pip`:
20
+
21
+ ```bash
22
+ pip install langchain-linkup
23
+ ```
24
+
25
+ ## 🛠️ Usage
26
+
27
+ ### Setting Up Your Environment
28
+
29
+ 1. **🔑 Obtain an API Key:**
30
+
31
+ Sign up on Linkup to get your API key.
32
+
33
+ 2. **⚙️ Set-up the API Key:**
34
+
35
+ Option 1: Export the `LINKUP_API_KEY` environment variable in your shell before using the Linkup
36
+ LangChain component.
37
+
38
+ ```bash
39
+ export LINKUP_API_KEY='YOUR_LINKUP_API_KEY'
40
+ ```
41
+
42
+ Option 2: Set the `LINKUP_API_KEY` environment variable directly within Python, using for
43
+ instance `os.environ` or [python-dotenv](https://github.com/theskumar/python-dotenv) with a
44
+ `.env` file (`python-dotenv` needs to be installed separately in this case), before creating the
45
+ Linkup LangChain component.
46
+
47
+ ```python
48
+ import os
49
+ from langchain_linkup import LinkupRetriever
50
+
51
+ os.environ["LINKUP_API_KEY"] = "YOUR_LINKUP_API_KEY"
52
+ # or dotenv.load_dotenv()
53
+ retriever = LinkupRetriever()
54
+ ...
55
+ ```
56
+
57
+ Option 3: Pass the Linkup API key to the Linkup LangChain component when creating it.
58
+
59
+ ```python
60
+ from langchain_linkup import LinkupRetriever
61
+
62
+ retriever = LinkupRetriever(api_key="YOUR_LINKUP_API_KEY")
63
+ ...
64
+ ```
65
+
66
+ ## 📋 Example
67
+
68
+ All search queries can be used with two very different modes:
69
+
70
+ - with `depth="standard"`, the search will be straightforward and fast, suited for relatively simple
71
+ queries (e.g. "What's the weather in Paris today?")
72
+ - with `depth="deep"`, the search will use an agentic workflow, which makes it in general slower,
73
+ but it will be able to solve more complex queries (e.g. "What is the company profile of LangChain
74
+ accross the last few years, and how does it compare to its concurrents?")
75
+
76
+ ### 🔍 Retriever
77
+
78
+ ```python
79
+ from langchain_linkup import LinkupRetriever
80
+
81
+ # Initialize the LangChain component (API key can be read from the environment variable or passed as
82
+ # an argument)
83
+ retriever = LinkupRetriever(
84
+ depth="deep", # "standard" or "deep"
85
+ )
86
+
87
+ # Perform a search query
88
+ documents = retriever.invoke(input="What is Linkup, the new French AI startup?")
89
+ print(documents)
90
+ ```
91
+
92
+ ### 📚 More Examples
93
+
94
+ See the `examples/` directory for more examples and documentation, for instance on how to use the
95
+ Linkup retriever in a simple RAG pipeline.
@@ -0,0 +1,5 @@
1
+ from .retriever import LinkupRetriever
2
+
3
+ __all__ = [
4
+ "LinkupRetriever",
5
+ ]
File without changes
@@ -0,0 +1,77 @@
1
+ from typing import Literal, Optional
2
+
3
+ from langchain_core.callbacks import (
4
+ AsyncCallbackManagerForRetrieverRun,
5
+ CallbackManagerForRetrieverRun,
6
+ )
7
+ from langchain_core.documents import Document
8
+ from langchain_core.retrievers import BaseRetriever
9
+ from linkup import LinkupClient, LinkupSearchResults
10
+
11
+
12
+ class LinkupRetriever(BaseRetriever):
13
+ """A retriever which using the Linkup API to retrieve documents.
14
+
15
+ This retriever is a wrapper around the Linkup API, allowing you to search for documents from
16
+ the Linkup API sources, that is the web and the Linkup Premium Partner sources.
17
+ """
18
+
19
+ # NOTE: we could want to make the LinkupClient a class attribute, but we would need to make it
20
+ # serializable for this to work, as langchain_core.retrievers.BaseRetriever inherits from
21
+ # langchain_core.load.Serializable. There's no real overhead in creating a new LinkupClient
22
+ # instance for each query, so we don't need to do this at the moment.
23
+
24
+ depth: Literal["standard", "deep"]
25
+ """The depth of the search. Can be either "standard", for a straighforward and fast search, or
26
+ "deep" for a more powerful agentic workflow."""
27
+ linkup_api_key: Optional[str] = None
28
+ """The API key for the Linkup API. If None, the API key will be read from the environment
29
+ variable `LINKUP_API_KEY`."""
30
+
31
+ def _get_relevant_documents(
32
+ self,
33
+ query: str,
34
+ *,
35
+ run_manager: CallbackManagerForRetrieverRun,
36
+ ) -> list[Document]:
37
+ client = LinkupClient(api_key=self.linkup_api_key)
38
+ search_results: LinkupSearchResults = client.search(
39
+ query=query,
40
+ depth=self.depth,
41
+ output_type="searchResults",
42
+ )
43
+
44
+ return [
45
+ Document(
46
+ page_content=result.content,
47
+ metadata=dict(
48
+ name=result.name,
49
+ url=result.url,
50
+ ),
51
+ )
52
+ for result in search_results.results
53
+ ]
54
+
55
+ async def _aget_relevant_documents(
56
+ self,
57
+ query: str,
58
+ *,
59
+ run_manager: AsyncCallbackManagerForRetrieverRun,
60
+ ) -> list[Document]:
61
+ client = LinkupClient(api_key=self.linkup_api_key)
62
+ search_results: LinkupSearchResults = await client.async_search(
63
+ query=query,
64
+ depth=self.depth,
65
+ output_type="searchResults",
66
+ )
67
+
68
+ return [
69
+ Document(
70
+ page_content=result.content,
71
+ metadata=dict(
72
+ name=result.name,
73
+ url=result.url,
74
+ ),
75
+ )
76
+ for result in search_results.results
77
+ ]
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.1
2
+ Name: langchain-linkup
3
+ Version: 0.1.0
4
+ Summary: A Langchain integration for the Linkup API
5
+ Home-page: https://github.com/LinkupPlatform/langchain-linkup
6
+ Author: LINKUP TECHNOLOGIES
7
+ Author-email: contact@linkup.so
8
+ License: MIT
9
+ Project-URL: Documentation, https://github.com/LinkupPlatform/langchain-linkup#readme
10
+ Project-URL: Source Code, https://github.com/LinkupPlatform/langchain-linkup
11
+ Project-URL: Issue Tracker, https://github.com/LinkupPlatform/langchain-linkup/issues
12
+ Keywords: linkup api langchain integration search retriever
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Requires-Python: >=3.9,<4.0
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: langchain-core
21
+ Requires-Dist: linkup-sdk>=0.1.7
22
+
23
+ # ⚡ Langchain Linkup
24
+
25
+ [![PyPI version](https://badge.fury.io/py/langchain-linkup.svg)](https://pypi.org/project/langchain-linkup/)
26
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
27
+
28
+ A [LangChain](https://www.langchain.com/) integration for the
29
+ [Linkup API](https://linkup-api.readme.io/reference/getting-started), allowing easy integration with
30
+ Linkup's services. 🔗
31
+
32
+ ## 🌟 Features
33
+
34
+ - 🔗 **Simple LangChain components to cover all Linkup API use cases.**
35
+ - 🔍 **Supports both standard and deep search queries.**
36
+ - ⚡ **Supports synchronous and asynchronous requests.**
37
+ - 🔒 **Handles authentication and request management.**
38
+
39
+ ## 📦 Installation
40
+
41
+ Simply install the LangChain integration using `pip`:
42
+
43
+ ```bash
44
+ pip install langchain-linkup
45
+ ```
46
+
47
+ ## 🛠️ Usage
48
+
49
+ ### Setting Up Your Environment
50
+
51
+ 1. **🔑 Obtain an API Key:**
52
+
53
+ Sign up on Linkup to get your API key.
54
+
55
+ 2. **⚙️ Set-up the API Key:**
56
+
57
+ Option 1: Export the `LINKUP_API_KEY` environment variable in your shell before using the Linkup
58
+ LangChain component.
59
+
60
+ ```bash
61
+ export LINKUP_API_KEY='YOUR_LINKUP_API_KEY'
62
+ ```
63
+
64
+ Option 2: Set the `LINKUP_API_KEY` environment variable directly within Python, using for
65
+ instance `os.environ` or [python-dotenv](https://github.com/theskumar/python-dotenv) with a
66
+ `.env` file (`python-dotenv` needs to be installed separately in this case), before creating the
67
+ Linkup LangChain component.
68
+
69
+ ```python
70
+ import os
71
+ from langchain_linkup import LinkupRetriever
72
+
73
+ os.environ["LINKUP_API_KEY"] = "YOUR_LINKUP_API_KEY"
74
+ # or dotenv.load_dotenv()
75
+ retriever = LinkupRetriever()
76
+ ...
77
+ ```
78
+
79
+ Option 3: Pass the Linkup API key to the Linkup LangChain component when creating it.
80
+
81
+ ```python
82
+ from langchain_linkup import LinkupRetriever
83
+
84
+ retriever = LinkupRetriever(api_key="YOUR_LINKUP_API_KEY")
85
+ ...
86
+ ```
87
+
88
+ ## 📋 Example
89
+
90
+ All search queries can be used with two very different modes:
91
+
92
+ - with `depth="standard"`, the search will be straightforward and fast, suited for relatively simple
93
+ queries (e.g. "What's the weather in Paris today?")
94
+ - with `depth="deep"`, the search will use an agentic workflow, which makes it in general slower,
95
+ but it will be able to solve more complex queries (e.g. "What is the company profile of LangChain
96
+ accross the last few years, and how does it compare to its concurrents?")
97
+
98
+ ### 🔍 Retriever
99
+
100
+ ```python
101
+ from langchain_linkup import LinkupRetriever
102
+
103
+ # Initialize the LangChain component (API key can be read from the environment variable or passed as
104
+ # an argument)
105
+ retriever = LinkupRetriever(
106
+ depth="deep", # "standard" or "deep"
107
+ )
108
+
109
+ # Perform a search query
110
+ documents = retriever.invoke(input="What is Linkup, the new French AI startup?")
111
+ print(documents)
112
+ ```
113
+
114
+ ### 📚 More Examples
115
+
116
+ See the `examples/` directory for more examples and documentation, for instance on how to use the
117
+ Linkup retriever in a simple RAG pipeline.
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ langchain_linkup/__init__.py
6
+ langchain_linkup/py.typed
7
+ langchain_linkup/retriever.py
8
+ langchain_linkup.egg-info/PKG-INFO
9
+ langchain_linkup.egg-info/SOURCES.txt
10
+ langchain_linkup.egg-info/dependency_links.txt
11
+ langchain_linkup.egg-info/requires.txt
12
+ langchain_linkup.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ langchain-core
2
+ linkup-sdk>=0.1.7
@@ -0,0 +1 @@
1
+ langchain_linkup
@@ -0,0 +1,24 @@
1
+ [tool.mypy]
2
+ exclude = ['^tests/']
3
+ strict = true
4
+
5
+ [tool.pytest.ini_options]
6
+ asyncio_default_fixture_loop_scope = "function"
7
+
8
+ [tool.coverage.report]
9
+ exclude_also = ["raise ValueError", "raise TypeError"]
10
+
11
+ [tool.ruff]
12
+ line-length = 100
13
+ target-version = "py39"
14
+
15
+ [tool.ruff.lint]
16
+ select = [
17
+ "E", # pycodestyle
18
+ "F", # pyflakes
19
+ "I", # isort
20
+ "S", # flake8-bandit
21
+ ]
22
+
23
+ [tool.ruff.lint.extend-per-file-ignores]
24
+ "tests/**/test_*.py" = ["S101"] # Use of assert detected
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,36 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ # Read the contents of README.md for the long_description
4
+ with open("README.md", "r", encoding="utf-8") as fh:
5
+ long_description = fh.read()
6
+
7
+ setup(
8
+ name="langchain-linkup",
9
+ version="0.1.0",
10
+ author="LINKUP TECHNOLOGIES",
11
+ author_email="contact@linkup.so",
12
+ description="A Langchain integration for the Linkup API",
13
+ long_description=long_description,
14
+ long_description_content_type="text/markdown",
15
+ url="https://github.com/LinkupPlatform/langchain-linkup",
16
+ project_urls={
17
+ "Documentation": "https://github.com/LinkupPlatform/langchain-linkup#readme",
18
+ "Source Code": "https://github.com/LinkupPlatform/langchain-linkup",
19
+ "Issue Tracker": "https://github.com/LinkupPlatform/langchain-linkup/issues",
20
+ },
21
+ license="MIT",
22
+ classifiers=[
23
+ "Intended Audience :: Developers",
24
+ "Topic :: Software Development :: Libraries :: Python Modules",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Operating System :: OS Independent",
27
+ ],
28
+ keywords="linkup api langchain integration search retriever",
29
+ packages=find_packages(),
30
+ package_data={"langchain_linkup": ["py.typed"]},
31
+ python_requires=">=3.9,<4.0", # Like langchain
32
+ install_requires=[
33
+ "langchain-core",
34
+ "linkup-sdk>=0.1.7", # Need >= 0.1.7 for async features and type checking
35
+ ],
36
+ )