langchain-asimov 0.0.4__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.
- langchain_asimov-0.0.4/.gitignore +40 -0
- langchain_asimov-0.0.4/AUTHORS +1 -0
- langchain_asimov-0.0.4/CHANGES.md +13 -0
- langchain_asimov-0.0.4/Makefile +0 -0
- langchain_asimov-0.0.4/PKG-INFO +145 -0
- langchain_asimov-0.0.4/README.md +125 -0
- langchain_asimov-0.0.4/UNLICENSE +24 -0
- langchain_asimov-0.0.4/VERSION +1 -0
- langchain_asimov-0.0.4/langchain_asimov/__init__.py +14 -0
- langchain_asimov-0.0.4/langchain_asimov/_version.py +34 -0
- langchain_asimov-0.0.4/langchain_asimov/document_loaders.py +85 -0
- langchain_asimov-0.0.4/langchain_asimov/errors.py +33 -0
- langchain_asimov-0.0.4/langchain_asimov/py.typed +0 -0
- langchain_asimov-0.0.4/pyproject.toml +72 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# macOS
|
|
2
|
+
.DS_Store
|
|
3
|
+
|
|
4
|
+
# Environment variables
|
|
5
|
+
.env
|
|
6
|
+
|
|
7
|
+
# JetBrains IntelliJ IDEA
|
|
8
|
+
.idea/
|
|
9
|
+
|
|
10
|
+
# Visual Studio Code
|
|
11
|
+
.vscode/
|
|
12
|
+
|
|
13
|
+
# Editor backup files
|
|
14
|
+
*~
|
|
15
|
+
|
|
16
|
+
# mypy artifacts
|
|
17
|
+
.mypy_cache/
|
|
18
|
+
|
|
19
|
+
# pytest artifacts
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
|
|
22
|
+
# tox artifacts
|
|
23
|
+
.tox/
|
|
24
|
+
|
|
25
|
+
# Python object files
|
|
26
|
+
__pycache__/
|
|
27
|
+
*.py[cdo]
|
|
28
|
+
|
|
29
|
+
# Python distutils
|
|
30
|
+
build/
|
|
31
|
+
|
|
32
|
+
# Python setuptools
|
|
33
|
+
dist/
|
|
34
|
+
*.egg-info/
|
|
35
|
+
|
|
36
|
+
# hatch-vcs artifacts
|
|
37
|
+
**/_version.py
|
|
38
|
+
|
|
39
|
+
# MkDocs artifacts
|
|
40
|
+
.cache/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* Arto Bendiken <arto@asimov.systems>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## 0.0.4 - 2026-02-02
|
|
9
|
+
|
|
10
|
+
## 0.0.3 - 2025-06-05
|
|
11
|
+
### Changed
|
|
12
|
+
- Add more information to the README
|
|
13
|
+
- [CD] Tweet new releases automatically
|
|
File without changes
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-asimov
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: LangChain integration with the ASIMOV platform.
|
|
5
|
+
Project-URL: Homepage, https://github.com/asimov-platform
|
|
6
|
+
Project-URL: Repository, https://github.com/asimov-platform/langchain-asimov
|
|
7
|
+
Project-URL: Changelog, https://github.com/asimov-platform/langchain-asimov/blob/master/CHANGES.md
|
|
8
|
+
Project-URL: Releases, https://github.com/asimov-platform/langchain-asimov/releases
|
|
9
|
+
Project-URL: Issues, https://github.com/asimov-platform/langchain-asimov/issues
|
|
10
|
+
Project-URL: Documentation, https://langchain-asimov.readthedocs.io
|
|
11
|
+
Author-email: ASIMOV Systems <support@asimov.systems>
|
|
12
|
+
License-Expression: Unlicense
|
|
13
|
+
License-File: UNLICENSE
|
|
14
|
+
Keywords: asimov
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: asimov-py
|
|
17
|
+
Requires-Dist: langchain-core>=0.3
|
|
18
|
+
Requires-Dist: pyld>=2
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# langchain-asimov
|
|
22
|
+
|
|
23
|
+
[](https://unlicense.org)
|
|
24
|
+
[](https://pypi.python.org/pypi/langchain-asimov)
|
|
25
|
+
[](https://pypi.org/pypi/langchain-asimov)
|
|
26
|
+
[](https://langchain-asimov.readthedocs.io)
|
|
27
|
+
|
|
28
|
+
[LangChain] integration with [ASIMOV], a polyglot development platform for
|
|
29
|
+
trustworthy, neurosymbolic AI.
|
|
30
|
+
|
|
31
|
+
## 🛠️ Prerequisites
|
|
32
|
+
|
|
33
|
+
- [Python] 3.10+
|
|
34
|
+
- [ASIMOV] [modules] available in the [`PATH`] and/or `$HOME/.asimov/libexec`
|
|
35
|
+
|
|
36
|
+
## ⬇️ Installation
|
|
37
|
+
|
|
38
|
+
### Installation from PyPI
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install -U langchain-asimov
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 👉 Examples
|
|
45
|
+
|
|
46
|
+
### Loading DuckDuckGo Results
|
|
47
|
+
|
|
48
|
+
Use e.g. the [SerpApi module] to fetch search results from DuckDuckGo,
|
|
49
|
+
Google, or Bing:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from langchain_asimov import AsimovLoader
|
|
53
|
+
|
|
54
|
+
search = AsimovLoader(
|
|
55
|
+
module="serpapi",
|
|
56
|
+
url="https://duckduckgo.com/?q=LangChain+roadmap"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
for result in search.lazy_load():
|
|
60
|
+
print(result)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> [!TIP]
|
|
64
|
+
> On your host, make sure that `asimov-serpapi-importer` can be found in your
|
|
65
|
+
> `PATH` and that you've defined the `SERPAPI_KEY` environment variable:
|
|
66
|
+
>
|
|
67
|
+
> ```bash
|
|
68
|
+
> export SERPAPI_KEY="..."
|
|
69
|
+
> ```
|
|
70
|
+
|
|
71
|
+
### Loading X (Twitter) Profiles
|
|
72
|
+
|
|
73
|
+
Use e.g. the [Bright Data module] to fetch a public X profile:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from langchain_asimov import AsimovLoader
|
|
77
|
+
|
|
78
|
+
profiles = AsimovLoader(
|
|
79
|
+
module="brightdata",
|
|
80
|
+
url="https://x.com/LangChainAI"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
for profile in profiles.lazy_load():
|
|
84
|
+
print(profile)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
> [!TIP]
|
|
88
|
+
> On your host, make sure that `asimov-brightdata-importer` can be found in your
|
|
89
|
+
> `PATH` and that you've defined the `BRIGHTDATA_API_KEY` environment variable:
|
|
90
|
+
>
|
|
91
|
+
> ```bash
|
|
92
|
+
> export BRIGHTDATA_API_KEY="..."
|
|
93
|
+
> ```
|
|
94
|
+
|
|
95
|
+
### Loading X (Twitter) Followers
|
|
96
|
+
|
|
97
|
+
Use e.g. the [Apify module] to fetch the followers/followees for an X profile:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from langchain_asimov import AsimovLoader
|
|
101
|
+
|
|
102
|
+
followers = AsimovLoader(
|
|
103
|
+
module="apify",
|
|
104
|
+
url="https://x.com/LangChainAI/followers"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
for follower in followers.lazy_load():
|
|
108
|
+
print(follower)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> [!TIP]
|
|
112
|
+
> On your host, make sure that `asimov-apify-importer` can be found in your
|
|
113
|
+
> `PATH` and that you've defined the `APIFY_TOKEN` environment variable:
|
|
114
|
+
>
|
|
115
|
+
> ```bash
|
|
116
|
+
> export APIFY_TOKEN="..."
|
|
117
|
+
> ```
|
|
118
|
+
|
|
119
|
+
## 📚 Reference
|
|
120
|
+
|
|
121
|
+
[langchain-asimov.readthedocs.io](https://langchain-asimov.readthedocs.io)
|
|
122
|
+
|
|
123
|
+
## 👨💻 Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
git clone https://github.com/asimov-platform/langchain-asimov.git
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
[](https://x.com/intent/post?url=https://github.com/asimov-platform/langchain-asimov&text=langchain-asimov)
|
|
132
|
+
[](https://reddit.com/submit?url=https://github.com/asimov-platform/langchain-asimov&title=langchain-asimov)
|
|
133
|
+
[](https://news.ycombinator.com/submitlink?u=https://github.com/asimov-platform/langchain-asimov&t=langchain-asimov)
|
|
134
|
+
[](https://www.facebook.com/sharer/sharer.php?u=https://github.com/asimov-platform/langchain-asimov)
|
|
135
|
+
[](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/asimov-platform/langchain-asimov)
|
|
136
|
+
|
|
137
|
+
[ASIMOV]: https://github.com/asimov-platform
|
|
138
|
+
[LangChain]: https://github.com/langchain-ai/langchain
|
|
139
|
+
[`PATH`]: https://en.wikipedia.org/wiki/PATH_(variable)
|
|
140
|
+
[Python]: https://python.org
|
|
141
|
+
[modules]: https://github.com/asimov-modules
|
|
142
|
+
|
|
143
|
+
[Apify module]: https://github.com/asimov-modules/asimov-apify-module
|
|
144
|
+
[Bright Data module]: https://github.com/asimov-modules/asimov-brightdata-module
|
|
145
|
+
[SerpApi module]: https://github.com/asimov-modules/asimov-serpapi-module
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# langchain-asimov
|
|
2
|
+
|
|
3
|
+
[](https://unlicense.org)
|
|
4
|
+
[](https://pypi.python.org/pypi/langchain-asimov)
|
|
5
|
+
[](https://pypi.org/pypi/langchain-asimov)
|
|
6
|
+
[](https://langchain-asimov.readthedocs.io)
|
|
7
|
+
|
|
8
|
+
[LangChain] integration with [ASIMOV], a polyglot development platform for
|
|
9
|
+
trustworthy, neurosymbolic AI.
|
|
10
|
+
|
|
11
|
+
## 🛠️ Prerequisites
|
|
12
|
+
|
|
13
|
+
- [Python] 3.10+
|
|
14
|
+
- [ASIMOV] [modules] available in the [`PATH`] and/or `$HOME/.asimov/libexec`
|
|
15
|
+
|
|
16
|
+
## ⬇️ Installation
|
|
17
|
+
|
|
18
|
+
### Installation from PyPI
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install -U langchain-asimov
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 👉 Examples
|
|
25
|
+
|
|
26
|
+
### Loading DuckDuckGo Results
|
|
27
|
+
|
|
28
|
+
Use e.g. the [SerpApi module] to fetch search results from DuckDuckGo,
|
|
29
|
+
Google, or Bing:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from langchain_asimov import AsimovLoader
|
|
33
|
+
|
|
34
|
+
search = AsimovLoader(
|
|
35
|
+
module="serpapi",
|
|
36
|
+
url="https://duckduckgo.com/?q=LangChain+roadmap"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
for result in search.lazy_load():
|
|
40
|
+
print(result)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> [!TIP]
|
|
44
|
+
> On your host, make sure that `asimov-serpapi-importer` can be found in your
|
|
45
|
+
> `PATH` and that you've defined the `SERPAPI_KEY` environment variable:
|
|
46
|
+
>
|
|
47
|
+
> ```bash
|
|
48
|
+
> export SERPAPI_KEY="..."
|
|
49
|
+
> ```
|
|
50
|
+
|
|
51
|
+
### Loading X (Twitter) Profiles
|
|
52
|
+
|
|
53
|
+
Use e.g. the [Bright Data module] to fetch a public X profile:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from langchain_asimov import AsimovLoader
|
|
57
|
+
|
|
58
|
+
profiles = AsimovLoader(
|
|
59
|
+
module="brightdata",
|
|
60
|
+
url="https://x.com/LangChainAI"
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
for profile in profiles.lazy_load():
|
|
64
|
+
print(profile)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
> [!TIP]
|
|
68
|
+
> On your host, make sure that `asimov-brightdata-importer` can be found in your
|
|
69
|
+
> `PATH` and that you've defined the `BRIGHTDATA_API_KEY` environment variable:
|
|
70
|
+
>
|
|
71
|
+
> ```bash
|
|
72
|
+
> export BRIGHTDATA_API_KEY="..."
|
|
73
|
+
> ```
|
|
74
|
+
|
|
75
|
+
### Loading X (Twitter) Followers
|
|
76
|
+
|
|
77
|
+
Use e.g. the [Apify module] to fetch the followers/followees for an X profile:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from langchain_asimov import AsimovLoader
|
|
81
|
+
|
|
82
|
+
followers = AsimovLoader(
|
|
83
|
+
module="apify",
|
|
84
|
+
url="https://x.com/LangChainAI/followers"
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
for follower in followers.lazy_load():
|
|
88
|
+
print(follower)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
> [!TIP]
|
|
92
|
+
> On your host, make sure that `asimov-apify-importer` can be found in your
|
|
93
|
+
> `PATH` and that you've defined the `APIFY_TOKEN` environment variable:
|
|
94
|
+
>
|
|
95
|
+
> ```bash
|
|
96
|
+
> export APIFY_TOKEN="..."
|
|
97
|
+
> ```
|
|
98
|
+
|
|
99
|
+
## 📚 Reference
|
|
100
|
+
|
|
101
|
+
[langchain-asimov.readthedocs.io](https://langchain-asimov.readthedocs.io)
|
|
102
|
+
|
|
103
|
+
## 👨💻 Development
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone https://github.com/asimov-platform/langchain-asimov.git
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
[](https://x.com/intent/post?url=https://github.com/asimov-platform/langchain-asimov&text=langchain-asimov)
|
|
112
|
+
[](https://reddit.com/submit?url=https://github.com/asimov-platform/langchain-asimov&title=langchain-asimov)
|
|
113
|
+
[](https://news.ycombinator.com/submitlink?u=https://github.com/asimov-platform/langchain-asimov&t=langchain-asimov)
|
|
114
|
+
[](https://www.facebook.com/sharer/sharer.php?u=https://github.com/asimov-platform/langchain-asimov)
|
|
115
|
+
[](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/asimov-platform/langchain-asimov)
|
|
116
|
+
|
|
117
|
+
[ASIMOV]: https://github.com/asimov-platform
|
|
118
|
+
[LangChain]: https://github.com/langchain-ai/langchain
|
|
119
|
+
[`PATH`]: https://en.wikipedia.org/wiki/PATH_(variable)
|
|
120
|
+
[Python]: https://python.org
|
|
121
|
+
[modules]: https://github.com/asimov-modules
|
|
122
|
+
|
|
123
|
+
[Apify module]: https://github.com/asimov-modules/asimov-apify-module
|
|
124
|
+
[Bright Data module]: https://github.com/asimov-modules/asimov-brightdata-module
|
|
125
|
+
[SerpApi module]: https://github.com/asimov-modules/asimov-serpapi-module
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.4
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
"""ASIMOV for LangChain."""
|
|
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,34 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TYPE_CHECKING = False
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from typing import Tuple
|
|
16
|
+
from typing import Union
|
|
17
|
+
|
|
18
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
20
|
+
else:
|
|
21
|
+
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
23
|
+
|
|
24
|
+
version: str
|
|
25
|
+
__version__: str
|
|
26
|
+
__version_tuple__: VERSION_TUPLE
|
|
27
|
+
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
30
|
+
|
|
31
|
+
__version__ = version = '0.0.4'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 0, 4)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
"""ASIMOV for LangChain: Document loaders."""
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
import subprocess
|
|
8
|
+
from .errors import AsimovModuleNotFound
|
|
9
|
+
from langchain_core.document_loaders.base import BaseLoader
|
|
10
|
+
from langchain_core.documents import Document
|
|
11
|
+
from pyld import jsonld
|
|
12
|
+
from typing_extensions import Any, Iterator, cast, override
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__file__)
|
|
15
|
+
|
|
16
|
+
JSONLD_CONTEXT = {
|
|
17
|
+
"@version": 1.1,
|
|
18
|
+
"know": "https://know.dev/",
|
|
19
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class AsimovLoader(BaseLoader):
|
|
23
|
+
"""
|
|
24
|
+
ASIMOV document loader integration.
|
|
25
|
+
|
|
26
|
+
Setup:
|
|
27
|
+
Install ``langchain-asimov``:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install -U langchain-asimov
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Instantiate:
|
|
34
|
+
```python
|
|
35
|
+
from langchain_asimov import AsimovLoader
|
|
36
|
+
|
|
37
|
+
loader = AsimovLoader(
|
|
38
|
+
module="serpapi",
|
|
39
|
+
url="https://duckduckgo.com/?q=Isaac+Asimov"
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
"""
|
|
43
|
+
def __init__(self, module: str, url: str, **kwargs: Any) -> None:
|
|
44
|
+
self.module = module
|
|
45
|
+
self.url = url
|
|
46
|
+
|
|
47
|
+
@override
|
|
48
|
+
def lazy_load(self) -> Iterator[Document]:
|
|
49
|
+
try:
|
|
50
|
+
result = subprocess.run(
|
|
51
|
+
[f"asimov-{self.module}-importer", self.url],
|
|
52
|
+
stdout=subprocess.PIPE,
|
|
53
|
+
stderr=subprocess.PIPE,
|
|
54
|
+
text=True,
|
|
55
|
+
)
|
|
56
|
+
result.check_returncode()
|
|
57
|
+
output = json.loads(result.stdout)
|
|
58
|
+
output = cast(dict, jsonld.flatten(output, JSONLD_CONTEXT))
|
|
59
|
+
for resource in output["@graph"]:
|
|
60
|
+
resource_id = resource["@id"]
|
|
61
|
+
page_content = describe(resource)
|
|
62
|
+
yield Document(page_content, id=resource_id, metadata=resource)
|
|
63
|
+
except FileNotFoundError as error:
|
|
64
|
+
#logger.exception(error)
|
|
65
|
+
raise AsimovModuleNotFound(self.module) from (error if __debug__ else None)
|
|
66
|
+
except subprocess.CalledProcessError as error:
|
|
67
|
+
#logger.exception(error)
|
|
68
|
+
raise error # TODO
|
|
69
|
+
except json.decoder.JSONDecodeError as error:
|
|
70
|
+
#logger.exception(error)
|
|
71
|
+
raise error # TODO
|
|
72
|
+
except jsonld.JsonLdError as error:
|
|
73
|
+
#logger.exception(error)
|
|
74
|
+
raise error # TODO
|
|
75
|
+
|
|
76
|
+
def describe(resource: dict) -> str:
|
|
77
|
+
if "know:summary" in resource:
|
|
78
|
+
return resource["know:summary"]["@value"]
|
|
79
|
+
if "know:title" in resource:
|
|
80
|
+
return resource["know:title"]["@value"]
|
|
81
|
+
if "know:name" in resource:
|
|
82
|
+
return resource["know:name"]["@value"]
|
|
83
|
+
if "know:link" in resource:
|
|
84
|
+
return resource["know:link"]
|
|
85
|
+
return resource["@id"]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
"""ASIMOV for LangChain: Exception classes."""
|
|
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
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# See: https://packaging.python.org/en/latest/tutorials/packaging-projects/
|
|
2
|
+
# See: https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
|
|
3
|
+
|
|
4
|
+
[build-system]
|
|
5
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
6
|
+
build-backend = "hatchling.build"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "langchain-asimov"
|
|
10
|
+
description = "LangChain integration with the ASIMOV platform."
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
authors = [{ name = "ASIMOV Systems", email = "support@asimov.systems" }]
|
|
13
|
+
license = "Unlicense"
|
|
14
|
+
license-files = ["UNLICENSE"]
|
|
15
|
+
dynamic = ["version"]
|
|
16
|
+
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
dependencies = ["asimov.py", "langchain-core>=0.3", "PyLD>=2"]
|
|
19
|
+
|
|
20
|
+
keywords = ["asimov"]
|
|
21
|
+
classifiers = []
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/asimov-platform"
|
|
25
|
+
Repository = "https://github.com/asimov-platform/langchain-asimov"
|
|
26
|
+
Changelog = "https://github.com/asimov-platform/langchain-asimov/blob/master/CHANGES.md"
|
|
27
|
+
Releases = "https://github.com/asimov-platform/langchain-asimov/releases"
|
|
28
|
+
Issues = "https://github.com/asimov-platform/langchain-asimov/issues"
|
|
29
|
+
Documentation = "https://langchain-asimov.readthedocs.io"
|
|
30
|
+
|
|
31
|
+
[dependency-groups]
|
|
32
|
+
dev = []
|
|
33
|
+
docs = [
|
|
34
|
+
"mkdocs>=1.6",
|
|
35
|
+
"mkdocs-git-committers-plugin-2>=2.5",
|
|
36
|
+
"mkdocs-git-revision-date-localized-plugin>=1.2",
|
|
37
|
+
"mkdocs-github-admonitions-plugin>=0.1",
|
|
38
|
+
"mkdocs-llmstxt>=0.2",
|
|
39
|
+
"mkdocs-material[imaging]>=9.5",
|
|
40
|
+
"mkdocstrings[python]>=0.29",
|
|
41
|
+
]
|
|
42
|
+
lint = ["ruff"]
|
|
43
|
+
test = ["pytest"]
|
|
44
|
+
|
|
45
|
+
[tool.hatch.version]
|
|
46
|
+
source = "vcs"
|
|
47
|
+
fallback-version = "0.0.0"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.hooks.vcs]
|
|
50
|
+
version-file = "langchain_asimov/_version.py"
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.sdist]
|
|
53
|
+
only-include = [
|
|
54
|
+
"AUTHORS",
|
|
55
|
+
"CHANGES.md",
|
|
56
|
+
"Makefile",
|
|
57
|
+
"VERSION",
|
|
58
|
+
"langchain_asimov",
|
|
59
|
+
]
|
|
60
|
+
exclude = [".*"]
|
|
61
|
+
|
|
62
|
+
[tool.hatch.envs.default]
|
|
63
|
+
installer = "uv"
|
|
64
|
+
|
|
65
|
+
[tool.mypy]
|
|
66
|
+
disallow_untyped_defs = true
|
|
67
|
+
|
|
68
|
+
[tool.uv]
|
|
69
|
+
default-groups = ["dev", "docs"]
|
|
70
|
+
|
|
71
|
+
[tool.pytest.ini_options]
|
|
72
|
+
testpaths = ["tests"]
|