langchain-nomic 0.1.4__tar.gz → 0.1.5__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_nomic-0.1.4 → langchain_nomic-0.1.5}/PKG-INFO +7 -14
- {langchain_nomic-0.1.4 → langchain_nomic-0.1.5}/README.md +1 -1
- {langchain_nomic-0.1.4 → langchain_nomic-0.1.5}/langchain_nomic/embeddings.py +25 -20
- langchain_nomic-0.1.5/pyproject.toml +143 -0
- langchain_nomic-0.1.5/tests/__init__.py +0 -0
- langchain_nomic-0.1.5/tests/integration_tests/__init__.py +0 -0
- langchain_nomic-0.1.5/tests/integration_tests/test_compile.py +6 -0
- langchain_nomic-0.1.5/tests/integration_tests/test_embeddings.py +29 -0
- langchain_nomic-0.1.5/tests/unit_tests/__init__.py +0 -0
- langchain_nomic-0.1.5/tests/unit_tests/test_embeddings.py +8 -0
- langchain_nomic-0.1.5/tests/unit_tests/test_imports.py +9 -0
- langchain_nomic-0.1.4/pyproject.toml +0 -102
- {langchain_nomic-0.1.4 → langchain_nomic-0.1.5}/LICENSE +0 -0
- {langchain_nomic-0.1.4 → langchain_nomic-0.1.5}/langchain_nomic/__init__.py +0 -0
- {langchain_nomic-0.1.4 → langchain_nomic-0.1.5}/langchain_nomic/py.typed +0 -0
@@ -1,22 +1,15 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: langchain-nomic
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
4
4
|
Summary: An integration package connecting Nomic and LangChain
|
5
|
-
Home-page: https://github.com/langchain-ai/langchain
|
6
5
|
License: MIT
|
7
|
-
Requires-Python: >=3.9,<4.0
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
14
|
-
Requires-Dist: langchain-core (>=0.2.43,<0.4.0,!=0.3.0,!=0.3.1,!=0.3.2,!=0.3.3,!=0.3.4,!=0.3.5,!=0.3.6,!=0.3.7,!=0.3.8,!=0.3.9,!=0.3.10,!=0.3.11,!=0.3.12,!=0.3.13,!=0.3.14)
|
15
|
-
Requires-Dist: nomic (>=3.1.2,<4.0.0)
|
16
|
-
Requires-Dist: pillow (>=10.3.0,<11.0.0)
|
17
|
-
Project-URL: Repository, https://github.com/langchain-ai/langchain
|
18
|
-
Project-URL: Release Notes, https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-nomic%3D%3D0%22&expanded=true
|
19
6
|
Project-URL: Source Code, https://github.com/langchain-ai/langchain/tree/master/libs/partners/nomic
|
7
|
+
Project-URL: Release Notes, https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-nomic%3D%3D0%22&expanded=true
|
8
|
+
Project-URL: repository, https://github.com/langchain-ai/langchain
|
9
|
+
Requires-Python: >=3.9
|
10
|
+
Requires-Dist: langchain-core>=0.3.76
|
11
|
+
Requires-Dist: nomic<4.0.0,>=3.5.3
|
12
|
+
Requires-Dist: pillow<11.0.0,>=10.3.0
|
20
13
|
Description-Content-Type: text/markdown
|
21
14
|
|
22
15
|
# langchain-nomic
|
@@ -20,4 +20,4 @@ And you should configure credentials by setting the following environment variab
|
|
20
20
|
from langchain_nomic import NomicEmbeddings
|
21
21
|
|
22
22
|
embeddings = NomicEmbeddings()
|
23
|
-
embeddings.embed_query("What is the meaning of life?")
|
23
|
+
embeddings.embed_query("What is the meaning of life?")
|
@@ -1,5 +1,7 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import os
|
2
|
-
from typing import
|
4
|
+
from typing import Literal, Optional, overload
|
3
5
|
|
4
6
|
import nomic # type: ignore[import]
|
5
7
|
from langchain_core.embeddings import Embeddings
|
@@ -10,11 +12,13 @@ class NomicEmbeddings(Embeddings):
|
|
10
12
|
"""NomicEmbeddings embedding model.
|
11
13
|
|
12
14
|
Example:
|
15
|
+
|
13
16
|
.. code-block:: python
|
14
17
|
|
15
18
|
from langchain_nomic import NomicEmbeddings
|
16
19
|
|
17
20
|
model = NomicEmbeddings()
|
21
|
+
|
18
22
|
"""
|
19
23
|
|
20
24
|
@overload
|
@@ -25,8 +29,7 @@ class NomicEmbeddings(Embeddings):
|
|
25
29
|
nomic_api_key: Optional[str] = ...,
|
26
30
|
dimensionality: Optional[int] = ...,
|
27
31
|
inference_mode: Literal["remote"] = ...,
|
28
|
-
):
|
29
|
-
...
|
32
|
+
): ...
|
30
33
|
|
31
34
|
@overload
|
32
35
|
def __init__(
|
@@ -37,8 +40,7 @@ class NomicEmbeddings(Embeddings):
|
|
37
40
|
dimensionality: Optional[int] = ...,
|
38
41
|
inference_mode: Literal["local", "dynamic"],
|
39
42
|
device: Optional[str] = ...,
|
40
|
-
):
|
41
|
-
...
|
43
|
+
): ...
|
42
44
|
|
43
45
|
@overload
|
44
46
|
def __init__(
|
@@ -49,8 +51,7 @@ class NomicEmbeddings(Embeddings):
|
|
49
51
|
dimensionality: Optional[int] = ...,
|
50
52
|
inference_mode: str,
|
51
53
|
device: Optional[str] = ...,
|
52
|
-
):
|
53
|
-
...
|
54
|
+
): ...
|
54
55
|
|
55
56
|
def __init__(
|
56
57
|
self,
|
@@ -66,16 +67,18 @@ class NomicEmbeddings(Embeddings):
|
|
66
67
|
|
67
68
|
Args:
|
68
69
|
model: model name
|
69
|
-
nomic_api_key: optionally, set the Nomic API key. Uses the NOMIC_API_KEY
|
70
|
+
nomic_api_key: optionally, set the Nomic API key. Uses the ``NOMIC_API_KEY``
|
70
71
|
environment variable by default.
|
71
72
|
dimensionality: The embedding dimension, for use with Matryoshka-capable
|
72
73
|
models. Defaults to full-size.
|
73
|
-
inference_mode: How to generate embeddings. One of
|
74
|
-
(Embed4All), or
|
74
|
+
inference_mode: How to generate embeddings. One of ``'remote'``, ``'local'``
|
75
|
+
(Embed4All), or ``'dynamic'`` (automatic). Defaults to ``'remote'``.
|
75
76
|
device: The device to use for local embeddings. Choices include
|
76
|
-
|
77
|
-
the docstring for
|
78
|
-
defaults to
|
77
|
+
``'cpu'``, ``'gpu'``, ``'nvidia'``, ``'amd'``, or a specific device
|
78
|
+
name. See the docstring for ``GPT4All.__init__`` for more info.
|
79
|
+
Typically defaults to ``'cpu'``. Do not use on macOS.
|
80
|
+
vision_model: The vision model to use for image embeddings.
|
81
|
+
|
79
82
|
"""
|
80
83
|
_api_key = nomic_api_key or os.environ.get("NOMIC_API_KEY")
|
81
84
|
if _api_key:
|
@@ -86,15 +89,15 @@ class NomicEmbeddings(Embeddings):
|
|
86
89
|
self.device = device
|
87
90
|
self.vision_model = vision_model
|
88
91
|
|
89
|
-
def embed(self, texts:
|
92
|
+
def embed(self, texts: list[str], *, task_type: str) -> list[list[float]]:
|
90
93
|
"""Embed texts.
|
91
94
|
|
92
95
|
Args:
|
93
96
|
texts: list of texts to embed
|
94
|
-
task_type: the task type to use when embedding. One of
|
95
|
-
|
96
|
-
"""
|
97
|
+
task_type: the task type to use when embedding. One of ``'search_query'``,
|
98
|
+
``'search_document'``, ``'classification'``, ``'clustering'``
|
97
99
|
|
100
|
+
"""
|
98
101
|
output = embed.text(
|
99
102
|
texts=texts,
|
100
103
|
model=self.model,
|
@@ -105,29 +108,31 @@ class NomicEmbeddings(Embeddings):
|
|
105
108
|
)
|
106
109
|
return output["embeddings"]
|
107
110
|
|
108
|
-
def embed_documents(self, texts:
|
111
|
+
def embed_documents(self, texts: list[str]) -> list[list[float]]:
|
109
112
|
"""Embed search docs.
|
110
113
|
|
111
114
|
Args:
|
112
115
|
texts: list of texts to embed as documents
|
116
|
+
|
113
117
|
"""
|
114
118
|
return self.embed(
|
115
119
|
texts=texts,
|
116
120
|
task_type="search_document",
|
117
121
|
)
|
118
122
|
|
119
|
-
def embed_query(self, text: str) ->
|
123
|
+
def embed_query(self, text: str) -> list[float]:
|
120
124
|
"""Embed query text.
|
121
125
|
|
122
126
|
Args:
|
123
127
|
text: query text
|
128
|
+
|
124
129
|
"""
|
125
130
|
return self.embed(
|
126
131
|
texts=[text],
|
127
132
|
task_type="search_query",
|
128
133
|
)[0]
|
129
134
|
|
130
|
-
def embed_image(self, uris:
|
135
|
+
def embed_image(self, uris: list[str]) -> list[list[float]]:
|
131
136
|
return embed.image(
|
132
137
|
images=uris,
|
133
138
|
model=self.vision_model,
|
@@ -0,0 +1,143 @@
|
|
1
|
+
[build-system]
|
2
|
+
requires = [
|
3
|
+
"pdm-backend",
|
4
|
+
]
|
5
|
+
build-backend = "pdm.backend"
|
6
|
+
|
7
|
+
[project]
|
8
|
+
authors = []
|
9
|
+
requires-python = ">=3.9"
|
10
|
+
dependencies = [
|
11
|
+
"langchain-core>=0.3.76",
|
12
|
+
"nomic<4.0.0,>=3.5.3",
|
13
|
+
"pillow<11.0.0,>=10.3.0",
|
14
|
+
]
|
15
|
+
name = "langchain-nomic"
|
16
|
+
version = "0.1.5"
|
17
|
+
description = "An integration package connecting Nomic and LangChain"
|
18
|
+
readme = "README.md"
|
19
|
+
|
20
|
+
[project.license]
|
21
|
+
text = "MIT"
|
22
|
+
|
23
|
+
[project.urls]
|
24
|
+
"Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/nomic"
|
25
|
+
"Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-nomic%3D%3D0%22&expanded=true"
|
26
|
+
repository = "https://github.com/langchain-ai/langchain"
|
27
|
+
|
28
|
+
[dependency-groups]
|
29
|
+
test = [
|
30
|
+
"pytest<8.0.0,>=7.3.0",
|
31
|
+
"freezegun<2.0.0,>=1.2.2",
|
32
|
+
"pytest-mock<4.0.0,>=3.10.0",
|
33
|
+
"syrupy<5.0.0,>=4.0.2",
|
34
|
+
"pytest-watcher<1.0.0,>=0.3.4",
|
35
|
+
"pytest-asyncio<1.0.0,>=0.21.1",
|
36
|
+
"langchain-core",
|
37
|
+
]
|
38
|
+
codespell = [
|
39
|
+
"codespell<3.0.0,>=2.2.0",
|
40
|
+
]
|
41
|
+
test_integration = []
|
42
|
+
lint = [
|
43
|
+
"ruff<0.13,>=0.12.2",
|
44
|
+
]
|
45
|
+
typing = [
|
46
|
+
"mypy<1.0,>=0.991",
|
47
|
+
"langchain-core",
|
48
|
+
]
|
49
|
+
dev = [
|
50
|
+
"langchain-core",
|
51
|
+
]
|
52
|
+
|
53
|
+
[tool.uv.sources.langchain-core]
|
54
|
+
path = "../../core"
|
55
|
+
editable = true
|
56
|
+
|
57
|
+
[tool.ruff]
|
58
|
+
target-version = "py39"
|
59
|
+
|
60
|
+
[tool.ruff.lint]
|
61
|
+
select = [
|
62
|
+
"A",
|
63
|
+
"B",
|
64
|
+
"ASYNC",
|
65
|
+
"C4",
|
66
|
+
"COM",
|
67
|
+
"D",
|
68
|
+
"E",
|
69
|
+
"EM",
|
70
|
+
"F",
|
71
|
+
"FA",
|
72
|
+
"FBT",
|
73
|
+
"FLY",
|
74
|
+
"I",
|
75
|
+
"ICN",
|
76
|
+
"INT",
|
77
|
+
"ISC",
|
78
|
+
"PGH",
|
79
|
+
"PIE",
|
80
|
+
"PERF",
|
81
|
+
"PYI",
|
82
|
+
"Q",
|
83
|
+
"RET",
|
84
|
+
"RSE",
|
85
|
+
"RUF",
|
86
|
+
"S",
|
87
|
+
"SLF",
|
88
|
+
"SLOT",
|
89
|
+
"SIM",
|
90
|
+
"T10",
|
91
|
+
"T20",
|
92
|
+
"TID",
|
93
|
+
"UP",
|
94
|
+
"W",
|
95
|
+
"YTT",
|
96
|
+
]
|
97
|
+
ignore = [
|
98
|
+
"D100",
|
99
|
+
"D101",
|
100
|
+
"D102",
|
101
|
+
"D103",
|
102
|
+
"D104",
|
103
|
+
"D105",
|
104
|
+
"D107",
|
105
|
+
"D203",
|
106
|
+
"D407",
|
107
|
+
"COM812",
|
108
|
+
"ISC001",
|
109
|
+
"PERF203",
|
110
|
+
"S112",
|
111
|
+
"RUF012",
|
112
|
+
"SLF001",
|
113
|
+
"UP007",
|
114
|
+
"UP045",
|
115
|
+
]
|
116
|
+
unfixable = [
|
117
|
+
"B028",
|
118
|
+
]
|
119
|
+
|
120
|
+
[tool.ruff.lint.pydocstyle]
|
121
|
+
convention = "google"
|
122
|
+
|
123
|
+
[tool.ruff.lint.extend-per-file-ignores]
|
124
|
+
"tests/**/*.py" = [
|
125
|
+
"S101",
|
126
|
+
"S311",
|
127
|
+
]
|
128
|
+
|
129
|
+
[tool.mypy]
|
130
|
+
disallow_untyped_defs = "True"
|
131
|
+
|
132
|
+
[tool.coverage.run]
|
133
|
+
omit = [
|
134
|
+
"tests/*",
|
135
|
+
]
|
136
|
+
|
137
|
+
[tool.pytest.ini_options]
|
138
|
+
addopts = "--snapshot-warn-unused --strict-markers --strict-config --durations=5"
|
139
|
+
markers = [
|
140
|
+
"requires: mark tests as requiring a specific library",
|
141
|
+
"compile: mark placeholder test used to compile integration tests without running them",
|
142
|
+
]
|
143
|
+
asyncio_mode = "auto"
|
File without changes
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"""Test Nomic embeddings."""
|
2
|
+
|
3
|
+
from langchain_nomic.embeddings import NomicEmbeddings
|
4
|
+
|
5
|
+
|
6
|
+
def test_langchain_nomic_embedding_documents() -> None:
|
7
|
+
"""Test nomic embeddings."""
|
8
|
+
documents = ["foo bar"]
|
9
|
+
embedding = NomicEmbeddings(model="nomic-embed-text-v1")
|
10
|
+
output = embedding.embed_documents(documents)
|
11
|
+
assert len(output) == 1
|
12
|
+
assert len(output[0]) > 0
|
13
|
+
|
14
|
+
|
15
|
+
def test_langchain_nomic_embedding_query() -> None:
|
16
|
+
"""Test nomic embeddings."""
|
17
|
+
document = "foo bar"
|
18
|
+
embedding = NomicEmbeddings(model="nomic-embed-text-v1")
|
19
|
+
output = embedding.embed_query(document)
|
20
|
+
assert len(output) > 0
|
21
|
+
|
22
|
+
|
23
|
+
def test_langchain_nomic_embedding_dimensionality() -> None:
|
24
|
+
"""Test nomic embeddings."""
|
25
|
+
documents = ["foo bar"]
|
26
|
+
embedding = NomicEmbeddings(model="nomic-embed-text-v1.5", dimensionality=256)
|
27
|
+
output = embedding.embed_documents(documents)
|
28
|
+
assert len(output) == 1
|
29
|
+
assert len(output[0]) == 256
|
File without changes
|
@@ -1,102 +0,0 @@
|
|
1
|
-
[tool.poetry]
|
2
|
-
name = "langchain-nomic"
|
3
|
-
version = "0.1.4"
|
4
|
-
description = "An integration package connecting Nomic and LangChain"
|
5
|
-
authors = []
|
6
|
-
readme = "README.md"
|
7
|
-
repository = "https://github.com/langchain-ai/langchain"
|
8
|
-
license = "MIT"
|
9
|
-
|
10
|
-
[tool.poetry.urls]
|
11
|
-
"Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/nomic"
|
12
|
-
"Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-nomic%3D%3D0%22&expanded=true"
|
13
|
-
|
14
|
-
[tool.poetry.dependencies]
|
15
|
-
python = ">=3.9,<4.0"
|
16
|
-
langchain-core = ">=0.2.43,<0.4.0,!=0.3.0,!=0.3.1,!=0.3.2,!=0.3.3,!=0.3.4,!=0.3.5,!=0.3.6,!=0.3.7,!=0.3.8,!=0.3.9,!=0.3.10,!=0.3.11,!=0.3.12,!=0.3.13,!=0.3.14"
|
17
|
-
nomic = "^3.1.2"
|
18
|
-
pillow = "^10.3.0"
|
19
|
-
|
20
|
-
[tool.poetry.group.test]
|
21
|
-
optional = true
|
22
|
-
|
23
|
-
[tool.poetry.group.test.dependencies]
|
24
|
-
pytest = "^7.3.0"
|
25
|
-
freezegun = "^1.2.2"
|
26
|
-
pytest-mock = "^3.10.0"
|
27
|
-
syrupy = "^4.0.2"
|
28
|
-
pytest-watcher = "^0.3.4"
|
29
|
-
pytest-asyncio = "^0.21.1"
|
30
|
-
langchain-core = { path = "../../core", develop = true }
|
31
|
-
|
32
|
-
[[tool.poetry.group.test.dependencies.numpy]]
|
33
|
-
version = "^1.24.0"
|
34
|
-
python = "<3.12"
|
35
|
-
|
36
|
-
[[tool.poetry.group.test.dependencies.numpy]]
|
37
|
-
version = "^1.26.0"
|
38
|
-
python = ">=3.12"
|
39
|
-
|
40
|
-
[tool.poetry.group.codespell]
|
41
|
-
optional = true
|
42
|
-
|
43
|
-
[tool.poetry.group.codespell.dependencies]
|
44
|
-
codespell = "^2.2.0"
|
45
|
-
|
46
|
-
[tool.poetry.group.test_integration]
|
47
|
-
optional = true
|
48
|
-
|
49
|
-
[tool.poetry.group.test_integration.dependencies]
|
50
|
-
|
51
|
-
[tool.poetry.group.lint]
|
52
|
-
optional = true
|
53
|
-
|
54
|
-
[tool.poetry.group.lint.dependencies]
|
55
|
-
ruff = "^0.1.5"
|
56
|
-
|
57
|
-
[tool.poetry.group.typing.dependencies]
|
58
|
-
mypy = "^0.991"
|
59
|
-
langchain-core = { path = "../../core", develop = true }
|
60
|
-
|
61
|
-
[tool.poetry.group.dev]
|
62
|
-
optional = true
|
63
|
-
|
64
|
-
[tool.poetry.group.dev.dependencies]
|
65
|
-
langchain-core = { path = "../../core", develop = true }
|
66
|
-
|
67
|
-
[tool.ruff.lint]
|
68
|
-
select = [
|
69
|
-
"E", # pycodestyle
|
70
|
-
"F", # pyflakes
|
71
|
-
"I", # isort
|
72
|
-
"T201", # print
|
73
|
-
]
|
74
|
-
|
75
|
-
[tool.mypy]
|
76
|
-
disallow_untyped_defs = "True"
|
77
|
-
|
78
|
-
[tool.coverage.run]
|
79
|
-
omit = ["tests/*"]
|
80
|
-
|
81
|
-
[build-system]
|
82
|
-
requires = ["poetry-core>=1.0.0"]
|
83
|
-
build-backend = "poetry.core.masonry.api"
|
84
|
-
|
85
|
-
[tool.pytest.ini_options]
|
86
|
-
# --strict-markers will raise errors on unknown marks.
|
87
|
-
# https://docs.pytest.org/en/7.1.x/how-to/mark.html#raising-errors-on-unknown-marks
|
88
|
-
#
|
89
|
-
# https://docs.pytest.org/en/7.1.x/reference/reference.html
|
90
|
-
# --strict-config any warnings encountered while parsing the `pytest`
|
91
|
-
# section of the configuration file raise errors.
|
92
|
-
#
|
93
|
-
# https://github.com/tophat/syrupy
|
94
|
-
# --snapshot-warn-unused Prints a warning on unused snapshots rather than fail the test suite.
|
95
|
-
addopts = "--snapshot-warn-unused --strict-markers --strict-config --durations=5"
|
96
|
-
# Registering custom markers.
|
97
|
-
# https://docs.pytest.org/en/7.1.x/example/markers.html#registering-markers
|
98
|
-
markers = [
|
99
|
-
"requires: mark tests as requiring a specific library",
|
100
|
-
"compile: mark placeholder test used to compile integration tests without running them",
|
101
|
-
]
|
102
|
-
asyncio_mode = "auto"
|
File without changes
|
File without changes
|
File without changes
|