speedy-utils 1.1.15__tar.gz → 1.1.17__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.
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/PKG-INFO +1 -1
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/pyproject.toml +1 -1
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/async_lm/async_llm_task.py +0 -2
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/vector_cache/core.py +15 -2
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/README.md +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/chat_format/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/chat_format/display.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/chat_format/transform.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/chat_format/utils.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/group_messages.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/async_lm/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/async_lm/_utils.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/async_lm/async_lm.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/async_lm/async_lm_base.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/async_lm/lm_specific.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/openai_memoize.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/lm/utils.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/scripts/README.md +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/scripts/vllm_load_balancer.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/scripts/vllm_serve.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/vector_cache/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/vector_cache/cli.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/vector_cache/types.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/llm_utils/vector_cache/utils.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/all.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/clock.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/function_decorator.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/logger.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/notebook_utils.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/report_manager.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/utils_cache.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/utils_io.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/utils_misc.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/common/utils_print.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/multi_worker/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/multi_worker/process.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/multi_worker/thread.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/scripts/__init__.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/scripts/mpython.py +0 -0
- {speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/scripts/openapi_client_codegen.py +0 -0
|
@@ -11,8 +11,6 @@ from venv import logger
|
|
|
11
11
|
|
|
12
12
|
from openai.types.chat import ChatCompletionMessageParam
|
|
13
13
|
from pydantic import BaseModel
|
|
14
|
-
from pytest import Cache
|
|
15
|
-
from speedy_utils import jdumps
|
|
16
14
|
from speedy_utils.all import dump_json_or_pickle, identify
|
|
17
15
|
|
|
18
16
|
from llm_utils.chat_format.display import get_conversation_one_turn
|
|
@@ -167,12 +167,11 @@ class VectorCache:
|
|
|
167
167
|
return "vllm"
|
|
168
168
|
def _try_infer_model_name(self, model_name: Optional[str]) -> Optional[str]:
|
|
169
169
|
"""Infer model name for OpenAI backend if not explicitly provided."""
|
|
170
|
-
# if self.backend != "openai":
|
|
171
|
-
# return model_name
|
|
172
170
|
if model_name:
|
|
173
171
|
return model_name
|
|
174
172
|
if 'https://' in self.url_or_model:
|
|
175
173
|
model_name = "text-embedding-3-small"
|
|
174
|
+
|
|
176
175
|
if 'http://localhost' in self.url_or_model:
|
|
177
176
|
from openai import OpenAI
|
|
178
177
|
client = OpenAI(base_url=self.url_or_model, api_key='abc')
|
|
@@ -277,6 +276,8 @@ class VectorCache:
|
|
|
277
276
|
|
|
278
277
|
def _get_embeddings(self, texts: list[str]) -> list[list[float]]:
|
|
279
278
|
"""Get embeddings using the configured backend."""
|
|
279
|
+
assert isinstance(texts, list), "texts must be a list"
|
|
280
|
+
assert all(isinstance(t, str) for t in texts), "all elements in texts must be strings"
|
|
280
281
|
if self.backend == "openai":
|
|
281
282
|
return self._get_openai_embeddings(texts)
|
|
282
283
|
elif self.backend == "vllm":
|
|
@@ -288,6 +289,8 @@ class VectorCache:
|
|
|
288
289
|
|
|
289
290
|
def _get_openai_embeddings(self, texts: list[str]) -> list[list[float]]:
|
|
290
291
|
"""Get embeddings using OpenAI API."""
|
|
292
|
+
assert isinstance(texts, list), "texts must be a list"
|
|
293
|
+
assert all(isinstance(t, str) for t in texts), "all elements in texts must be strings"
|
|
291
294
|
# Assert valid model_name for OpenAI backend
|
|
292
295
|
model_name = self.config["model_name"]
|
|
293
296
|
assert model_name is not None and model_name.strip(), f"Invalid model_name for OpenAI backend: {model_name}. Model name must be provided and non-empty."
|
|
@@ -304,6 +307,8 @@ class VectorCache:
|
|
|
304
307
|
|
|
305
308
|
def _get_vllm_embeddings(self, texts: list[str]) -> list[list[float]]:
|
|
306
309
|
"""Get embeddings using vLLM."""
|
|
310
|
+
assert isinstance(texts, list), "texts must be a list"
|
|
311
|
+
assert all(isinstance(t, str) for t in texts), "all elements in texts must be strings"
|
|
307
312
|
if self._model is None:
|
|
308
313
|
self._load_model()
|
|
309
314
|
|
|
@@ -313,6 +318,8 @@ class VectorCache:
|
|
|
313
318
|
|
|
314
319
|
def _get_transformers_embeddings(self, texts: list[str]) -> list[list[float]]:
|
|
315
320
|
"""Get embeddings using transformers directly."""
|
|
321
|
+
assert isinstance(texts, list), "texts must be a list"
|
|
322
|
+
assert all(isinstance(t, str) for t in texts), "all elements in texts must be strings"
|
|
316
323
|
if self._model is None:
|
|
317
324
|
self._load_model()
|
|
318
325
|
|
|
@@ -380,6 +387,8 @@ class VectorCache:
|
|
|
380
387
|
handle very large input lists. A tqdm progress bar is shown while
|
|
381
388
|
computing missing embeddings.
|
|
382
389
|
"""
|
|
390
|
+
assert isinstance(texts, list), "texts must be a list"
|
|
391
|
+
assert all(isinstance(t, str) for t in texts), "all elements in texts must be strings"
|
|
383
392
|
if not texts:
|
|
384
393
|
return np.empty((0, 0), dtype=np.float32)
|
|
385
394
|
t = time()
|
|
@@ -436,6 +445,8 @@ class VectorCache:
|
|
|
436
445
|
return np.vstack([hit_map[h] for h in hashes])
|
|
437
446
|
|
|
438
447
|
def __call__(self, texts: list[str], cache: bool = True) -> np.ndarray:
|
|
448
|
+
assert isinstance(texts, list), "texts must be a list"
|
|
449
|
+
assert all(isinstance(t, str) for t in texts), "all elements in texts must be strings"
|
|
439
450
|
return self.embeds(texts, cache)
|
|
440
451
|
|
|
441
452
|
def _bulk_insert(self, data: list[tuple[str, str, bytes]]) -> None:
|
|
@@ -454,6 +465,8 @@ class VectorCache:
|
|
|
454
465
|
Precompute embeddings for a large list of texts efficiently.
|
|
455
466
|
This is optimized for bulk operations when you know all texts upfront.
|
|
456
467
|
"""
|
|
468
|
+
assert isinstance(texts, list), "texts must be a list"
|
|
469
|
+
assert all(isinstance(t, str) for t in texts), "all elements in texts must be strings"
|
|
457
470
|
if not texts:
|
|
458
471
|
return
|
|
459
472
|
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{speedy_utils-1.1.15 → speedy_utils-1.1.17}/src/speedy_utils/scripts/openapi_client_codegen.py
RENAMED
|
File without changes
|