ragit 0.7.1__tar.gz → 0.7.3__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.4
2
2
  Name: ragit
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Automatic RAG Pattern Optimization Engine
5
5
  Author: RODMENA LIMITED
6
6
  Maintainer-email: RODMENA LIMITED <info@rodmena.co.uk>
@@ -37,6 +37,10 @@ Provides-Extra: test
37
37
  Requires-Dist: pytest; extra == "test"
38
38
  Requires-Dist: pytest-cov; extra == "test"
39
39
  Requires-Dist: pytest-mock; extra == "test"
40
+ Provides-Extra: docs
41
+ Requires-Dist: sphinx>=7.0; extra == "docs"
42
+ Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
43
+ Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
40
44
  Dynamic: license-file
41
45
 
42
46
  # ragit
@@ -57,6 +57,12 @@ dev = [
57
57
 
58
58
  test = ["pytest", "pytest-cov", "pytest-mock"]
59
59
 
60
+ docs = [
61
+ "sphinx>=7.0",
62
+ "sphinx-rtd-theme>=2.0",
63
+ "sphinx-copybutton>=0.5",
64
+ ]
65
+
60
66
  [tool.setuptools.dynamic]
61
67
  version = { attr = "ragit.version.__version__" }
62
68
 
@@ -56,6 +56,9 @@ class OllamaProvider(BaseLLMProvider, BaseEmbeddingProvider):
56
56
  "qwen3-embedding:8b": 4096,
57
57
  }
58
58
 
59
+ # Max characters per embedding request (safe limit for 512 token models)
60
+ MAX_EMBED_CHARS = 1500
61
+
59
62
  def __init__(
60
63
  self,
61
64
  base_url: str | None = None,
@@ -162,17 +165,21 @@ class OllamaProvider(BaseLLMProvider, BaseEmbeddingProvider):
162
165
  self._current_embed_model = model
163
166
  self._current_dimensions = self.EMBEDDING_DIMENSIONS.get(model, 768)
164
167
 
168
+ # Truncate oversized inputs to prevent context length errors
169
+ if len(text) > self.MAX_EMBED_CHARS:
170
+ text = text[: self.MAX_EMBED_CHARS]
171
+
165
172
  try:
166
173
  response = requests.post(
167
- f"{self.embedding_url}/api/embed",
174
+ f"{self.embedding_url}/api/embeddings",
168
175
  headers=self._get_headers(include_auth=False),
169
- json={"model": model, "input": text},
176
+ json={"model": model, "prompt": text},
170
177
  timeout=self.timeout,
171
178
  )
172
179
  response.raise_for_status()
173
180
  data = response.json()
174
181
 
175
- embedding = data.get("embeddings", [[]])[0]
182
+ embedding = data.get("embedding", [])
176
183
  if not embedding:
177
184
  raise ValueError("Empty embedding returned from Ollama")
178
185
 
@@ -189,33 +196,42 @@ class OllamaProvider(BaseLLMProvider, BaseEmbeddingProvider):
189
196
  raise ConnectionError(f"Ollama embed failed: {e}") from e
190
197
 
191
198
  def embed_batch(self, texts: list[str], model: str) -> list[EmbeddingResponse]:
192
- """Generate embeddings for multiple texts (uses embedding_url, no auth for local)."""
199
+ """Generate embeddings for multiple texts (uses embedding_url, no auth for local).
200
+
201
+ Note: Ollama /api/embeddings only supports single prompts, so we loop.
202
+ """
193
203
  self._current_embed_model = model
194
204
  self._current_dimensions = self.EMBEDDING_DIMENSIONS.get(model, 768)
195
205
 
206
+ results = []
196
207
  try:
197
- response = requests.post(
198
- f"{self.embedding_url}/api/embed",
199
- headers=self._get_headers(include_auth=False),
200
- json={"model": model, "input": texts},
201
- timeout=self.timeout,
202
- )
203
- response.raise_for_status()
204
- data = response.json()
205
-
206
- embeddings = data.get("embeddings", [])
207
- if embeddings:
208
- self._current_dimensions = len(embeddings[0])
209
-
210
- return [
211
- EmbeddingResponse(
212
- embedding=tuple(emb),
213
- model=model,
214
- provider=self.provider_name,
215
- dimensions=len(emb),
208
+ for text in texts:
209
+ # Truncate oversized inputs to prevent context length errors
210
+ if len(text) > self.MAX_EMBED_CHARS:
211
+ text = text[: self.MAX_EMBED_CHARS]
212
+
213
+ response = requests.post(
214
+ f"{self.embedding_url}/api/embeddings",
215
+ headers=self._get_headers(include_auth=False),
216
+ json={"model": model, "prompt": text},
217
+ timeout=self.timeout,
218
+ )
219
+ response.raise_for_status()
220
+ data = response.json()
221
+
222
+ embedding = data.get("embedding", [])
223
+ if embedding:
224
+ self._current_dimensions = len(embedding)
225
+
226
+ results.append(
227
+ EmbeddingResponse(
228
+ embedding=tuple(embedding),
229
+ model=model,
230
+ provider=self.provider_name,
231
+ dimensions=len(embedding),
232
+ )
216
233
  )
217
- for emb in embeddings
218
- ]
234
+ return results
219
235
  except requests.RequestException as e:
220
236
  raise ConnectionError(f"Ollama batch embed failed: {e}") from e
221
237
 
@@ -2,4 +2,4 @@
2
2
  # Copyright RODMENA LIMITED 2025
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  #
5
- __version__ = "0.7.1"
5
+ __version__ = "0.7.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ragit
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Automatic RAG Pattern Optimization Engine
5
5
  Author: RODMENA LIMITED
6
6
  Maintainer-email: RODMENA LIMITED <info@rodmena.co.uk>
@@ -37,6 +37,10 @@ Provides-Extra: test
37
37
  Requires-Dist: pytest; extra == "test"
38
38
  Requires-Dist: pytest-cov; extra == "test"
39
39
  Requires-Dist: pytest-mock; extra == "test"
40
+ Provides-Extra: docs
41
+ Requires-Dist: sphinx>=7.0; extra == "docs"
42
+ Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
43
+ Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
40
44
  Dynamic: license-file
41
45
 
42
46
  # ragit
@@ -14,6 +14,11 @@ issuedb[web]
14
14
  ruff
15
15
  mypy
16
16
 
17
+ [docs]
18
+ sphinx>=7.0
19
+ sphinx-rtd-theme>=2.0
20
+ sphinx-copybutton>=0.5
21
+
17
22
  [test]
18
23
  pytest
19
24
  pytest-cov
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes