langchain-asimov 0.0.0__tar.gz → 0.0.1__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.
Potentially problematic release.
This version of langchain-asimov might be problematic. Click here for more details.
- {langchain_asimov-0.0.0 → langchain_asimov-0.0.1}/.gitignore +4 -1
- {langchain_asimov-0.0.0 → langchain_asimov-0.0.1}/PKG-INFO +24 -3
- langchain_asimov-0.0.1/README.md +25 -0
- langchain_asimov-0.0.1/VERSION +1 -0
- langchain_asimov-0.0.1/docs/document_loaders.md +7 -0
- langchain_asimov-0.0.1/docs/errors.md +7 -0
- langchain_asimov-0.0.1/docs/index.md +5 -0
- langchain_asimov-0.0.1/langchain_asimov/__init__.py +14 -0
- {langchain_asimov-0.0.0/src → langchain_asimov-0.0.1}/langchain_asimov/_version.py +2 -2
- langchain_asimov-0.0.1/langchain_asimov/document_loaders.py +79 -0
- langchain_asimov-0.0.1/langchain_asimov/errors.py +33 -0
- langchain_asimov-0.0.1/langchain_asimov/py.typed +0 -0
- {langchain_asimov-0.0.0 → langchain_asimov-0.0.1}/pyproject.toml +17 -6
- langchain_asimov-0.0.1/tests/__init__.py +0 -0
- langchain_asimov-0.0.1/tests/integration_tests/__init__.py +0 -0
- langchain_asimov-0.0.1/tests/unit_tests/__init__.py +0 -0
- langchain_asimov-0.0.1/uv.lock +1791 -0
- langchain_asimov-0.0.0/README.md +0 -5
- langchain_asimov-0.0.0/VERSION +0 -1
- langchain_asimov-0.0.0/src/langchain_asimov/__init__.py +0 -1
- langchain_asimov-0.0.0/uv.lock +0 -470
- {langchain_asimov-0.0.0 → langchain_asimov-0.0.1}/AUTHORS +0 -0
- {langchain_asimov-0.0.0 → langchain_asimov-0.0.1}/CHANGES.md +0 -0
- {langchain_asimov-0.0.0 → langchain_asimov-0.0.1}/Makefile +0 -0
- {langchain_asimov-0.0.0 → langchain_asimov-0.0.1}/UNLICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langchain-asimov
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.1
|
|
4
4
|
Summary: LangChain integration with the ASIMOV platform.
|
|
5
5
|
Project-URL: Homepage, https://github.com/asimov-platform
|
|
6
6
|
Project-URL: Repository, https://github.com/asimov-platform/langchain-asimov
|
|
@@ -11,11 +11,32 @@ Author-email: ASIMOV Protocol <support@asimov.so>
|
|
|
11
11
|
License-Expression: Unlicense
|
|
12
12
|
License-File: UNLICENSE
|
|
13
13
|
Requires-Python: >=3.9
|
|
14
|
-
Requires-Dist: langchain>=0.3
|
|
14
|
+
Requires-Dist: langchain-core>=0.3
|
|
15
|
+
Requires-Dist: pyld>=2
|
|
15
16
|
Description-Content-Type: text/markdown
|
|
16
17
|
|
|
17
18
|
# LangChain ASIMOV Integration
|
|
18
19
|
|
|
19
20
|
[](https://unlicense.org)
|
|
20
|
-
[](https://pypi.python.org/pypi/langchain-asimov)
|
|
21
22
|
[](https://pypi.python.org/pypi/langchain-asimov)
|
|
23
|
+
|
|
24
|
+
## 👉 Examples
|
|
25
|
+
|
|
26
|
+
### Fetching DuckDuckGo Results
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
export SERPAPI_KEY="..."
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from langchain_asimov import AsimovLoader
|
|
34
|
+
|
|
35
|
+
search = AsimovLoader(
|
|
36
|
+
module="serpapi",
|
|
37
|
+
url="https://duckduckgo.com/?q=Isaac+Asimov"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
for result in search.lazy_load():
|
|
41
|
+
print(result)
|
|
42
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# LangChain ASIMOV Integration
|
|
2
|
+
|
|
3
|
+
[](https://unlicense.org)
|
|
4
|
+
[](https://pypi.python.org/pypi/langchain-asimov)
|
|
5
|
+
[](https://pypi.python.org/pypi/langchain-asimov)
|
|
6
|
+
|
|
7
|
+
## 👉 Examples
|
|
8
|
+
|
|
9
|
+
### Fetching DuckDuckGo Results
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
export SERPAPI_KEY="..."
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from langchain_asimov import AsimovLoader
|
|
17
|
+
|
|
18
|
+
search = AsimovLoader(
|
|
19
|
+
module="serpapi",
|
|
20
|
+
url="https://duckduckgo.com/?q=Isaac+Asimov"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
for result in search.lazy_load():
|
|
24
|
+
print(result)
|
|
25
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.1
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
"""LangChain integration with the ASIMOV platform."""
|
|
4
|
+
|
|
5
|
+
from ._version import __version__, __version_tuple__
|
|
6
|
+
from .document_loaders import AsimovLoader
|
|
7
|
+
from .errors import AsimovModuleNotFound
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
'AsimovLoader',
|
|
11
|
+
'AsimovModuleNotFound',
|
|
12
|
+
'__version__',
|
|
13
|
+
'__version_tuple__',
|
|
14
|
+
]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
"""ASIMOV document loader."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations # for Python 3.9
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import logging
|
|
9
|
+
import subprocess
|
|
10
|
+
from .errors import AsimovModuleNotFound
|
|
11
|
+
from langchain_core.document_loaders.base import BaseLoader
|
|
12
|
+
from langchain_core.documents import Document
|
|
13
|
+
from pyld import jsonld
|
|
14
|
+
from typing import Any, Iterator, cast, override
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__file__)
|
|
17
|
+
|
|
18
|
+
JSONLD_CONTEXT = {
|
|
19
|
+
"@version": 1.1,
|
|
20
|
+
"know": "https://know.dev/",
|
|
21
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class AsimovLoader(BaseLoader):
|
|
25
|
+
"""
|
|
26
|
+
ASIMOV document loader integration.
|
|
27
|
+
|
|
28
|
+
Setup:
|
|
29
|
+
Install ``langchain-asimov``:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install -U langchain-asimov
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Instantiate:
|
|
36
|
+
```python
|
|
37
|
+
from langchain_asimov import AsimovLoader
|
|
38
|
+
|
|
39
|
+
loader = AsimovLoader(
|
|
40
|
+
module="serpapi",
|
|
41
|
+
url="https://duckduckgo.com/?q=Isaac+Asimov"
|
|
42
|
+
)
|
|
43
|
+
```
|
|
44
|
+
"""
|
|
45
|
+
def __init__(self, module: str, url: str, **kwargs: Any) -> None:
|
|
46
|
+
self.module = module
|
|
47
|
+
self.url = url
|
|
48
|
+
|
|
49
|
+
@override
|
|
50
|
+
def lazy_load(self) -> Iterator[Document]:
|
|
51
|
+
try:
|
|
52
|
+
result = subprocess.run(
|
|
53
|
+
[f"asimov-{self.module}-importer", self.url],
|
|
54
|
+
stdout=subprocess.PIPE,
|
|
55
|
+
stderr=subprocess.PIPE,
|
|
56
|
+
text=True,
|
|
57
|
+
)
|
|
58
|
+
result.check_returncode()
|
|
59
|
+
output = json.loads(result.stdout)
|
|
60
|
+
output = cast(dict, jsonld.flatten(output, JSONLD_CONTEXT))
|
|
61
|
+
for resource in output["@graph"]:
|
|
62
|
+
resource_id = resource["@id"]
|
|
63
|
+
page_content = describe(resource)
|
|
64
|
+
yield Document(page_content, id=resource_id, metadata=resource)
|
|
65
|
+
except FileNotFoundError as error:
|
|
66
|
+
#logger.exception(error)
|
|
67
|
+
raise AsimovModuleNotFound(self.module) from (error if __debug__ else None)
|
|
68
|
+
except subprocess.CalledProcessError as error:
|
|
69
|
+
#logger.exception(error)
|
|
70
|
+
raise error # TODO
|
|
71
|
+
except json.decoder.JSONDecodeError as error:
|
|
72
|
+
#logger.exception(error)
|
|
73
|
+
raise error # TODO
|
|
74
|
+
except jsonld.JsonLdError as error:
|
|
75
|
+
#logger.exception(error)
|
|
76
|
+
raise error # TODO
|
|
77
|
+
|
|
78
|
+
def describe(resource: dict) -> str:
|
|
79
|
+
return resource["know:summary"]["@value"] # TODO
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations # for Python 3.9
|
|
4
|
+
|
|
5
|
+
class AsimovModuleNotFound(Exception):
|
|
6
|
+
"""Exception raised when a module cannot be found or imported.
|
|
7
|
+
|
|
8
|
+
Attributes:
|
|
9
|
+
module_name: The name of the module that was not found
|
|
10
|
+
message: Explanation of the error
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, module_name: str, message: str | None = None) -> None:
|
|
14
|
+
"""Initializes the `AsimovModuleNotFound` exception.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
module_name: The name of the module that was not found
|
|
18
|
+
message: Optional custom error message. If not provided,
|
|
19
|
+
a default message will be generated.
|
|
20
|
+
"""
|
|
21
|
+
self.module_name = module_name
|
|
22
|
+
if message is None:
|
|
23
|
+
message = f"Module '{module_name}' not found"
|
|
24
|
+
self.message = message
|
|
25
|
+
super().__init__(self.message)
|
|
26
|
+
|
|
27
|
+
def __str__(self) -> str:
|
|
28
|
+
"""Returns a string representation of the exception."""
|
|
29
|
+
return self.message
|
|
30
|
+
|
|
31
|
+
def __repr__(self) -> str:
|
|
32
|
+
"""Returns a detailed string representation of the exception."""
|
|
33
|
+
return f"{self.__class__.__name__}(module_name={self.module_name!r}, message={self.message!r})"
|
|
File without changes
|
|
@@ -11,11 +11,9 @@ description = "LangChain integration with the ASIMOV platform."
|
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
license = "Unlicense"
|
|
13
13
|
license-files = ["UNLICENSE"]
|
|
14
|
-
authors = [
|
|
15
|
-
{ name = "ASIMOV Protocol", email = "support@asimov.so" }
|
|
16
|
-
]
|
|
14
|
+
authors = [{ name = "ASIMOV Protocol", email = "support@asimov.so" }]
|
|
17
15
|
requires-python = ">=3.9"
|
|
18
|
-
dependencies = ["langchain>=0.3"]
|
|
16
|
+
dependencies = ["langchain-core>=0.3", "PyLD>=2"]
|
|
19
17
|
dynamic = ["version"]
|
|
20
18
|
|
|
21
19
|
[project.urls]
|
|
@@ -26,14 +24,24 @@ Releases = "https://github.com/asimov-platform/langchain-asimov/releases"
|
|
|
26
24
|
Issues = "https://github.com/asimov-platform/langchain-asimov/issues"
|
|
27
25
|
|
|
28
26
|
[dependency-groups]
|
|
27
|
+
dev = []
|
|
28
|
+
docs = [
|
|
29
|
+
"mkdocs>=1.6",
|
|
30
|
+
"mkdocs-git-committers-plugin-2>=2.5",
|
|
31
|
+
"mkdocs-git-revision-date-localized-plugin>=1.2",
|
|
32
|
+
"mkdocs-llmstxt>=0.2",
|
|
33
|
+
"mkdocs-material[imaging]>=9.5",
|
|
34
|
+
"mkdocstrings[python]>=0.29",
|
|
35
|
+
]
|
|
29
36
|
lint = ["ruff"]
|
|
30
|
-
test = []
|
|
37
|
+
test = ["pytest"]
|
|
31
38
|
|
|
32
39
|
[tool.hatch.version]
|
|
33
40
|
source = "vcs"
|
|
41
|
+
fallback-version = "0.0.0"
|
|
34
42
|
|
|
35
43
|
[tool.hatch.build.hooks.vcs]
|
|
36
|
-
version-file = "
|
|
44
|
+
version-file = "langchain_asimov/_version.py"
|
|
37
45
|
|
|
38
46
|
[tool.hatch.build.targets.sdist]
|
|
39
47
|
exclude = [".*"]
|
|
@@ -43,3 +51,6 @@ installer = "uv"
|
|
|
43
51
|
|
|
44
52
|
[tool.mypy]
|
|
45
53
|
disallow_untyped_defs = true
|
|
54
|
+
|
|
55
|
+
[tool.uv]
|
|
56
|
+
default-groups = ["dev", "docs"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|