langchain-nomic 0.0.2__tar.gz → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langchain-nomic
3
- Version: 0.0.2
3
+ Version: 0.1.1
4
4
  Summary: An integration package connecting Nomic and LangChain
5
5
  Home-page: https://github.com/langchain-ai/langchain
6
6
  License: MIT
@@ -11,8 +11,8 @@ Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
- Requires-Dist: langchain-core (>=0.1,<0.2)
15
- Requires-Dist: nomic (>=3.0.12,<4.0.0)
14
+ Requires-Dist: langchain-core (>=0.1.46,<0.3)
15
+ Requires-Dist: nomic (>=3.0.29,<4.0.0)
16
16
  Project-URL: Repository, https://github.com/langchain-ai/langchain
17
17
  Project-URL: Source Code, https://github.com/langchain-ai/langchain/tree/master/libs/partners/nomic
18
18
  Description-Content-Type: text/markdown
@@ -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,46 @@ class NomicEmbeddings(Embeddings):
17
17
  model = NomicEmbeddings()
18
18
  """
19
19
 
20
+ @overload
21
+ def __init__(
22
+ self,
23
+ *,
24
+ model: str,
25
+ dimensionality: Optional[int] = ...,
26
+ inference_mode: Literal["remote"] = ...,
27
+ ):
28
+ ...
29
+
30
+ @overload
31
+ def __init__(
32
+ self,
33
+ *,
34
+ model: str,
35
+ dimensionality: Optional[int] = ...,
36
+ inference_mode: Literal["local", "dynamic"],
37
+ device: Optional[str] = ...,
38
+ ):
39
+ ...
40
+
41
+ @overload
42
+ def __init__(
43
+ self,
44
+ *,
45
+ model: str,
46
+ dimensionality: Optional[int] = ...,
47
+ inference_mode: str,
48
+ device: Optional[str] = ...,
49
+ ):
50
+ ...
51
+
20
52
  def __init__(
21
53
  self,
22
54
  *,
23
55
  model: str,
24
56
  nomic_api_key: Optional[str] = None,
25
57
  dimensionality: Optional[int] = None,
58
+ inference_mode: str = "remote",
59
+ device: Optional[str] = None,
26
60
  ):
27
61
  """Initialize NomicEmbeddings model.
28
62
 
@@ -30,12 +64,22 @@ class NomicEmbeddings(Embeddings):
30
64
  model: model name
31
65
  nomic_api_key: optionally, set the Nomic API key. Uses the NOMIC_API_KEY
32
66
  environment variable by default.
67
+ dimensionality: The embedding dimension, for use with Matryoshka-capable
68
+ models. Defaults to full-size.
69
+ inference_mode: How to generate embeddings. One of `remote`, `local`
70
+ (Embed4All), or `dynamic` (automatic). Defaults to `remote`.
71
+ device: The device to use for local embeddings. Choices include
72
+ `cpu`, `gpu`, `nvidia`, `amd`, or a specific device name. See
73
+ the docstring for `GPT4All.__init__` for more info. Typically
74
+ defaults to CPU. Do not use on macOS.
33
75
  """
34
76
  _api_key = nomic_api_key or os.environ.get("NOMIC_API_KEY")
35
77
  if _api_key:
36
78
  nomic.login(_api_key)
37
79
  self.model = model
38
80
  self.dimensionality = dimensionality
81
+ self.inference_mode = inference_mode
82
+ self.device = device
39
83
 
40
84
  def embed(self, texts: List[str], *, task_type: str) -> List[List[float]]:
41
85
  """Embed texts.
@@ -51,6 +95,8 @@ class NomicEmbeddings(Embeddings):
51
95
  model=self.model,
52
96
  task_type=task_type,
53
97
  dimensionality=self.dimensionality,
98
+ inference_mode=self.inference_mode,
99
+ device=self.device,
54
100
  )
55
101
  return output["embeddings"]
56
102
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langchain-nomic"
3
- version = "0.0.2"
3
+ version = "0.1.1"
4
4
  description = "An integration package connecting Nomic and LangChain"
5
5
  authors = []
6
6
  readme = "README.md"
@@ -12,8 +12,8 @@ license = "MIT"
12
12
 
13
13
  [tool.poetry.dependencies]
14
14
  python = ">=3.8.1,<4.0"
15
- langchain-core = "^0.1"
16
- nomic = "^3.0.12"
15
+ langchain-core = ">=0.1.46,<0.3"
16
+ nomic = "^3.0.29"
17
17
 
18
18
  [tool.poetry.group.test]
19
19
  optional = true
File without changes