langchain-nomic 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

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.
@@ -1,5 +1,3 @@
1
1
  from langchain_nomic.embeddings import NomicEmbeddings
2
2
 
3
- __all__ = [
4
- "NomicEmbeddings",
5
- ]
3
+ __all__ = ["NomicEmbeddings"]
@@ -1,9 +1,9 @@
1
1
  import os
2
- from typing import List, Optional
2
+ from typing import List, Literal, Optional, overload
3
3
 
4
- import nomic # type: ignore
4
+ import nomic # type: ignore[import]
5
5
  from langchain_core.embeddings import Embeddings
6
- from nomic import embed # type: ignore
6
+ from nomic import embed
7
7
 
8
8
 
9
9
  class NomicEmbeddings(Embeddings):
@@ -17,12 +17,50 @@ class NomicEmbeddings(Embeddings):
17
17
  model = NomicEmbeddings()
18
18
  """
19
19
 
20
+ @overload
21
+ def __init__(
22
+ self,
23
+ *,
24
+ model: str,
25
+ nomic_api_key: Optional[str] = ...,
26
+ dimensionality: Optional[int] = ...,
27
+ inference_mode: Literal["remote"] = ...,
28
+ ):
29
+ ...
30
+
31
+ @overload
32
+ def __init__(
33
+ self,
34
+ *,
35
+ model: str,
36
+ nomic_api_key: Optional[str] = ...,
37
+ dimensionality: Optional[int] = ...,
38
+ inference_mode: Literal["local", "dynamic"],
39
+ device: Optional[str] = ...,
40
+ ):
41
+ ...
42
+
43
+ @overload
44
+ def __init__(
45
+ self,
46
+ *,
47
+ model: str,
48
+ nomic_api_key: Optional[str] = ...,
49
+ dimensionality: Optional[int] = ...,
50
+ inference_mode: str,
51
+ device: Optional[str] = ...,
52
+ ):
53
+ ...
54
+
20
55
  def __init__(
21
56
  self,
22
57
  *,
23
58
  model: str,
24
59
  nomic_api_key: Optional[str] = None,
25
60
  dimensionality: Optional[int] = None,
61
+ inference_mode: str = "remote",
62
+ device: Optional[str] = None,
63
+ vision_model: Optional[str] = None,
26
64
  ):
27
65
  """Initialize NomicEmbeddings model.
28
66
 
@@ -30,12 +68,23 @@ class NomicEmbeddings(Embeddings):
30
68
  model: model name
31
69
  nomic_api_key: optionally, set the Nomic API key. Uses the NOMIC_API_KEY
32
70
  environment variable by default.
71
+ dimensionality: The embedding dimension, for use with Matryoshka-capable
72
+ models. Defaults to full-size.
73
+ inference_mode: How to generate embeddings. One of `remote`, `local`
74
+ (Embed4All), or `dynamic` (automatic). Defaults to `remote`.
75
+ device: The device to use for local embeddings. Choices include
76
+ `cpu`, `gpu`, `nvidia`, `amd`, or a specific device name. See
77
+ the docstring for `GPT4All.__init__` for more info. Typically
78
+ defaults to CPU. Do not use on macOS.
33
79
  """
34
80
  _api_key = nomic_api_key or os.environ.get("NOMIC_API_KEY")
35
81
  if _api_key:
36
82
  nomic.login(_api_key)
37
83
  self.model = model
38
84
  self.dimensionality = dimensionality
85
+ self.inference_mode = inference_mode
86
+ self.device = device
87
+ self.vision_model = vision_model
39
88
 
40
89
  def embed(self, texts: List[str], *, task_type: str) -> List[List[float]]:
41
90
  """Embed texts.
@@ -51,6 +100,8 @@ class NomicEmbeddings(Embeddings):
51
100
  model=self.model,
52
101
  task_type=task_type,
53
102
  dimensionality=self.dimensionality,
103
+ inference_mode=self.inference_mode,
104
+ device=self.device,
54
105
  )
55
106
  return output["embeddings"]
56
107
 
@@ -75,3 +126,9 @@ class NomicEmbeddings(Embeddings):
75
126
  texts=[text],
76
127
  task_type="search_query",
77
128
  )[0]
129
+
130
+ def embed_image(self, uris: List[str]) -> List[List[float]]:
131
+ return embed.image(
132
+ images=uris,
133
+ model=self.vision_model,
134
+ )["embeddings"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langchain-nomic
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: An integration package connecting Nomic and LangChain
5
5
  Home-page: https://github.com/langchain-ai/langchain
6
6
  License: MIT
@@ -12,7 +12,8 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Requires-Dist: langchain-core (>=0.1.46,<0.3)
15
- Requires-Dist: nomic (>=3.0.12,<4.0.0)
15
+ Requires-Dist: nomic (>=3.0.29,<4.0.0)
16
+ Requires-Dist: pillow (>=10.3.0,<11.0.0)
16
17
  Project-URL: Repository, https://github.com/langchain-ai/langchain
17
18
  Project-URL: Source Code, https://github.com/langchain-ai/langchain/tree/master/libs/partners/nomic
18
19
  Description-Content-Type: text/markdown
@@ -0,0 +1,7 @@
1
+ langchain_nomic/__init__.py,sha256=MYethT7Ss07B2-ZHi0Y61JONOTXUtp_VTFW1ES-ydKM,86
2
+ langchain_nomic/embeddings.py,sha256=9llrozY7UJnwB9hrJxbPamC35Opn1aVbeaoHn1wHYa8,3892
3
+ langchain_nomic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ langchain_nomic-0.1.2.dist-info/LICENSE,sha256=DppmdYJVSc1jd0aio6ptnMUn5tIHrdAhQ12SclEBfBg,1072
5
+ langchain_nomic-0.1.2.dist-info/METADATA,sha256=2vd12iP7vrr4MgFaZdekzjThLUVg1WXMlYEeHPJuyl8,1331
6
+ langchain_nomic-0.1.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
7
+ langchain_nomic-0.1.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- langchain_nomic/__init__.py,sha256=MQEfQNlmqQ0aGXXR7fngtWlJJeC6R4zcDhcXucjqvLE,93
2
- langchain_nomic/embeddings.py,sha256=S312h3vwoo_zLAjGeU7RWTbDMOFY2GnS5rLY5DC2cN8,2045
3
- langchain_nomic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- langchain_nomic-0.1.0.dist-info/LICENSE,sha256=DppmdYJVSc1jd0aio6ptnMUn5tIHrdAhQ12SclEBfBg,1072
5
- langchain_nomic-0.1.0.dist-info/METADATA,sha256=mcsG_BzcXxavKkll8JfW9xKXnxwR7bViaqc6vYamTMQ,1290
6
- langchain_nomic-0.1.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
7
- langchain_nomic-0.1.0.dist-info/RECORD,,