TriCacheLLM-MMA 0.1.6__tar.gz → 0.1.8__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.
Files changed (23) hide show
  1. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/PKG-INFO +25 -2
  2. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/README.md +24 -1
  3. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_main.py +44 -1
  4. tricachellm_mma-0.1.8/TriCacheLLM_MMA/portable_cache_utils/portable_cache_embedding_model.py +63 -0
  5. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA.egg-info/PKG-INFO +25 -2
  6. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/pyproject.toml +1 -1
  7. tricachellm_mma-0.1.6/TriCacheLLM_MMA/portable_cache_utils/portable_cache_embedding_model.py +0 -31
  8. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/LICENSE +0 -0
  9. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/__init__.py +0 -0
  10. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_Ai/portable_cache_rerankAi.py +0 -0
  11. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_bgWorkers/portable_cache_celery_conf.py +0 -0
  12. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_bgWorkers/portable_cache_workers.py +0 -0
  13. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_dbSchema.py +0 -0
  14. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_redis.py +0 -0
  15. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_schemas/portable_cache_dbBase.py +0 -0
  16. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_schemas/portable_cache_dbConf.py +0 -0
  17. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_schemas/portable_cache_schemas.py +0 -0
  18. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA/portable_cache_utils/protable_cache_DynamicEnv_maker.py +0 -0
  19. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA.egg-info/SOURCES.txt +0 -0
  20. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA.egg-info/dependency_links.txt +0 -0
  21. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA.egg-info/requires.txt +0 -0
  22. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/TriCacheLLM_MMA.egg-info/top_level.txt +0 -0
  23. {tricachellm_mma-0.1.6 → tricachellm_mma-0.1.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TriCacheLLM_MMA
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: A robust three-tier LLM-aware caching SDK using Redis, ChromaDB, and automatic SQLite bootstrap.
5
5
  Author-email: Mohib Ashfaq Butt <inboxmohib@gmail.com>
6
6
  License-Expression: LGPL-3.0-only
@@ -424,7 +424,7 @@ Or install the development version directly from the repository:
424
424
  pip install .
425
425
  ```
426
426
 
427
- PyPI link: [https://pypi.org/project/TriCacheLLM-MMA/0.1.6/](https://pypi.org/project/TriCacheLLM-MMA/0.1.6/)​
427
+ PyPI link: [https://pypi.org/project/TriCacheLLM-MMA/0.1.8/](https://pypi.org/project/TriCacheLLM-MMA/0.1.8/)​
428
428
 
429
429
  ---
430
430
 
@@ -478,6 +478,25 @@ Keep the Celery worker running while using the cache.
478
478
 
479
479
  ---
480
480
 
481
+ ### 📂 Model Caching Locations
482
+
483
+ To ensure heavy Hugging Face embedding models don't re-download or clutter your project directory, `TriCacheLLM_MMA` automatically stores them in a stable, user-level system cache directory depending on your operating system:
484
+
485
+ * **Windows:**
486
+ `%LOCALAPPDATA%\TriCacheLLM_MMA\embedding_model\`
487
+
488
+ *(Falls back to `C:\Users\<Username>\AppData\Local\TriCacheLLM_MMA\embedding_model\`)*
489
+
490
+ * **macOS:**
491
+ `~/Library/Caches/TriCacheLLM_MMA/embedding_model/`
492
+
493
+ * **Linux / Unix:**
494
+ `$XDG_CACHE_HOME/TriCacheLLM_MMA/embedding_model/`
495
+
496
+ *(Falls back to `~/.cache/TriCacheLLM_MMA/embedding_model/`)*
497
+
498
+ ---
499
+
481
500
  # Cohere
482
501
 
483
502
  The persistent cache tier uses Cohere reranking.
@@ -521,6 +540,10 @@ app = FastAPI(
521
540
  )
522
541
 
523
542
 
543
+ # NOTE: Run celery first it will download the embedding model for you then initialize create_cache_system(user_id=0)
544
+ # In upcoming versions, this process will be automated, so you won't need to manually run the Celery command.
545
+
546
+
524
547
  # 1. ADMIN SETUP (Run once on startup / first deploy with user_id=0)
525
548
  @app.post("/api/consumer/init")
526
549
  async def initialize_consumer():
@@ -382,7 +382,7 @@ Or install the development version directly from the repository:
382
382
  pip install .
383
383
  ```
384
384
 
385
- PyPI link: [https://pypi.org/project/TriCacheLLM-MMA/0.1.6/](https://pypi.org/project/TriCacheLLM-MMA/0.1.6/)​
385
+ PyPI link: [https://pypi.org/project/TriCacheLLM-MMA/0.1.8/](https://pypi.org/project/TriCacheLLM-MMA/0.1.8/)​
386
386
 
387
387
  ---
388
388
 
@@ -436,6 +436,25 @@ Keep the Celery worker running while using the cache.
436
436
 
437
437
  ---
438
438
 
439
+ ### 📂 Model Caching Locations
440
+
441
+ To ensure heavy Hugging Face embedding models don't re-download or clutter your project directory, `TriCacheLLM_MMA` automatically stores them in a stable, user-level system cache directory depending on your operating system:
442
+
443
+ * **Windows:**
444
+ `%LOCALAPPDATA%\TriCacheLLM_MMA\embedding_model\`
445
+
446
+ *(Falls back to `C:\Users\<Username>\AppData\Local\TriCacheLLM_MMA\embedding_model\`)*
447
+
448
+ * **macOS:**
449
+ `~/Library/Caches/TriCacheLLM_MMA/embedding_model/`
450
+
451
+ * **Linux / Unix:**
452
+ `$XDG_CACHE_HOME/TriCacheLLM_MMA/embedding_model/`
453
+
454
+ *(Falls back to `~/.cache/TriCacheLLM_MMA/embedding_model/`)*
455
+
456
+ ---
457
+
439
458
  # Cohere
440
459
 
441
460
  The persistent cache tier uses Cohere reranking.
@@ -479,6 +498,10 @@ app = FastAPI(
479
498
  )
480
499
 
481
500
 
501
+ # NOTE: Run celery first it will download the embedding model for you then initialize create_cache_system(user_id=0)
502
+ # In upcoming versions, this process will be automated, so you won't need to manually run the Celery command.
503
+
504
+
482
505
  # 1. ADMIN SETUP (Run once on startup / first deploy with user_id=0)
483
506
  @app.post("/api/consumer/init")
484
507
  async def initialize_consumer():
@@ -1,7 +1,9 @@
1
1
  # File: portable_cache_main.py
2
2
  import asyncio
3
+ from asyncio import subprocess
3
4
  import hashlib
4
5
  import json
6
+ import os
5
7
  from pathlib import Path
6
8
  from typing import Any
7
9
  from .portable_cache_schemas.portable_cache_dbConf import init_cache_database, init_db_tables, db_manager
@@ -29,6 +31,8 @@ from .portable_cache_redis import get_redis
29
31
  from .portable_cache_redis import redis_manager
30
32
  from .portable_cache_utils.protable_cache_DynamicEnv_maker import system_key
31
33
  from .portable_cache_dbSchema import Paths
34
+ import sys
35
+
32
36
 
33
37
  def create_vector_index_schema(dim: int, distance_metric: str = "COSINE", m: int = 16, ef_construction: int = 200, ef_runtime: int = 10) -> list:
34
38
  return [
@@ -439,10 +443,49 @@ async def create_cache_system(
439
443
  if not key_res["success"]:
440
444
  raise ValueError("Failed to initialize system keys. Verify if the keys are correct.")
441
445
 
446
+
447
+ # This bit is for 0.1.9 (at import time embedding model will be loaded anyways so run this anytime u want)
448
+ """
449
+ is_in_venv = sys.prefix != sys.base_prefix
450
+ celery_name = "celery.exe" if os.name == "nt" else "celery"
451
+ celery_executable = Path(sys.executable).parent / celery_name
452
+
453
+ if is_in_venv and celery_executable.exists():
454
+ celery_cmd = [
455
+ str(celery_executable),
456
+ "-A",
457
+ "TriCacheLLM_MMA.portable_cache_bgWorkers.portable_cache_celery_conf.celery_app",
458
+ "worker",
459
+ "--loglevel=info",
460
+ "-Q",
461
+ "ai"
462
+ ]
463
+
464
+ # Check OS and launch accordingly
465
+ if os.name == "nt":
466
+ subprocess.Popen(celery_cmd, creationflags=subprocess.CREATE_NEW_CONSOLE)
467
+ print("Don't worry, TriCacheLLM_MMA is running celery background workers automatically")
468
+
469
+ elif sys.platform == "darwin":
470
+ try:
471
+ cmd_str = " ".join(celery_cmd)
472
+ subprocess.Popen(["osascript", "-e", f'tell application "Terminal" to do script "{cmd_str}"'])
473
+ print("Don't worry, TriCacheLLM_MMA is running celery background workers automatically")
474
+ except Exception:
475
+ subprocess.Popen(celery_cmd)
476
+ print("Don't worry, TriCacheLLM_MMA is running celery background workers automatically")
477
+ else:
478
+ # Linux / Unix fallback (runs as a background child process)
479
+ subprocess.Popen(celery_cmd)
480
+ print("Don't worry, TriCacheLLM_MMA is running celery background workers automatically")
481
+ else:
482
+ print("---WARNING--- auto celery start failed manually run this command:\ncelery -A TriCacheLLM_MMA.portable_cache_bgWorkers.portable_cache_celery_conf.celery_app worker --loglevel=info -Q ai")
483
+
484
+ """
485
+
442
486
  return #user_id=0 doesnt need its own vdb! if you want to be it user-self be user_id=1 -> single user
443
487
  #if you want multi-tanent then keep sending in user_ids lol
444
488
 
445
-
446
489
  async with db_manager.async_session() as db:
447
490
  ans: None | dict = await create_cache_vdb_inishiator(user_id=user_id, db=db)
448
491
 
@@ -0,0 +1,63 @@
1
+ # File: portable_cache_utils/portable_cache_embedding_model.py
2
+
3
+ import os
4
+ import sys
5
+ from pathlib import Path
6
+ from langchain_huggingface import HuggingFaceEmbeddings
7
+ from ..portable_cache_utils.protable_cache_DynamicEnv_maker import get_settings
8
+
9
+
10
+ def get_embedding_cache_dir() -> Path:
11
+ """
12
+ Return a stable per-user cache directory for the Hugging Face
13
+ embedding model, independent of the consumer application's location,
14
+ respecting OS conventions and XDG standards.
15
+ """
16
+ if os.name == "nt":
17
+ local_app_data = os.environ.get("LOCALAPPDATA")
18
+ if local_app_data:
19
+ return Path(local_app_data) / "TriCacheLLM_MMA" / "embedding_model"
20
+ return Path.home() / "AppData" / "Local" / "TriCacheLLM_MMA" / "embedding_model"
21
+
22
+ if sys.platform == "darwin":
23
+ return Path.home() / "Library" / "Caches" / "TriCacheLLM_MMA" / "embedding_model"
24
+
25
+ # Linux / Unix: Respect XDG_CACHE_HOME if explicitly configured
26
+ xdg_cache = os.environ.get("XDG_CACHE_HOME")
27
+ if xdg_cache:
28
+ return Path(xdg_cache) / "TriCacheLLM_MMA" / "embedding_model"
29
+
30
+ return Path.home() / ".cache" / "TriCacheLLM_MMA" / "embedding_model"
31
+
32
+
33
+ # Ensure the stable cache path exists prior to initialization
34
+ embedding_cache_dir = get_embedding_cache_dir()
35
+ embedding_cache_dir.mkdir(parents=True, exist_ok=True)
36
+
37
+
38
+ #on each --reload this reads weights
39
+ embedding_model = HuggingFaceEmbeddings(
40
+ model_name=get_settings().portable_cache_cache_proj_embedding_model,
41
+ cache_folder=str(embedding_cache_dir),
42
+ )
43
+
44
+
45
+
46
+ #lazy load, on --reload it will read weights but not at the start but when needed (un-comment me if u need lazyload)
47
+ """
48
+ from langchain_huggingface import HuggingFaceEmbeddings
49
+ from ..portable_cache_utils.protable_cache_DynamicEnv_maker import get_settings
50
+
51
+ class EmbeddingModel:
52
+ def __init__(self):
53
+ self.model = None
54
+
55
+ def get_model(self):
56
+ if self.model is None:
57
+ self.model = HuggingFaceEmbeddings(
58
+ model_name=get_settings().portable_cache_cache_proj_embedding_model,
59
+ cache_folder=get_settings().portable_cache_chroma_db_dir,
60
+ )
61
+ return self.model
62
+ embedding_manager = EmbeddingModel()
63
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TriCacheLLM_MMA
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: A robust three-tier LLM-aware caching SDK using Redis, ChromaDB, and automatic SQLite bootstrap.
5
5
  Author-email: Mohib Ashfaq Butt <inboxmohib@gmail.com>
6
6
  License-Expression: LGPL-3.0-only
@@ -424,7 +424,7 @@ Or install the development version directly from the repository:
424
424
  pip install .
425
425
  ```
426
426
 
427
- PyPI link: [https://pypi.org/project/TriCacheLLM-MMA/0.1.6/](https://pypi.org/project/TriCacheLLM-MMA/0.1.6/)​
427
+ PyPI link: [https://pypi.org/project/TriCacheLLM-MMA/0.1.8/](https://pypi.org/project/TriCacheLLM-MMA/0.1.8/)​
428
428
 
429
429
  ---
430
430
 
@@ -478,6 +478,25 @@ Keep the Celery worker running while using the cache.
478
478
 
479
479
  ---
480
480
 
481
+ ### 📂 Model Caching Locations
482
+
483
+ To ensure heavy Hugging Face embedding models don't re-download or clutter your project directory, `TriCacheLLM_MMA` automatically stores them in a stable, user-level system cache directory depending on your operating system:
484
+
485
+ * **Windows:**
486
+ `%LOCALAPPDATA%\TriCacheLLM_MMA\embedding_model\`
487
+
488
+ *(Falls back to `C:\Users\<Username>\AppData\Local\TriCacheLLM_MMA\embedding_model\`)*
489
+
490
+ * **macOS:**
491
+ `~/Library/Caches/TriCacheLLM_MMA/embedding_model/`
492
+
493
+ * **Linux / Unix:**
494
+ `$XDG_CACHE_HOME/TriCacheLLM_MMA/embedding_model/`
495
+
496
+ *(Falls back to `~/.cache/TriCacheLLM_MMA/embedding_model/`)*
497
+
498
+ ---
499
+
481
500
  # Cohere
482
501
 
483
502
  The persistent cache tier uses Cohere reranking.
@@ -521,6 +540,10 @@ app = FastAPI(
521
540
  )
522
541
 
523
542
 
543
+ # NOTE: Run celery first it will download the embedding model for you then initialize create_cache_system(user_id=0)
544
+ # In upcoming versions, this process will be automated, so you won't need to manually run the Celery command.
545
+
546
+
524
547
  # 1. ADMIN SETUP (Run once on startup / first deploy with user_id=0)
525
548
  @app.post("/api/consumer/init")
526
549
  async def initialize_consumer():
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "TriCacheLLM_MMA"
7
- version = "0.1.6"
7
+ version = "0.1.8"
8
8
  description = "A robust three-tier LLM-aware caching SDK using Redis, ChromaDB, and automatic SQLite bootstrap."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -1,31 +0,0 @@
1
- # File: portable_cache_utils/portable_cache_embedding_model.py
2
-
3
- #on each --reload this reads weights
4
- from langchain_huggingface import HuggingFaceEmbeddings
5
- from ..portable_cache_utils.protable_cache_DynamicEnv_maker import get_settings
6
-
7
- embedding_model = HuggingFaceEmbeddings(
8
- model_name=get_settings().portable_cache_cache_proj_embedding_model,
9
- cache_folder=get_settings().portable_cache_chroma_db_dir
10
- )
11
-
12
-
13
-
14
- #lazy load, on --reload it will read weights but not at the start but when needed (un-comment me if u need lazyload)
15
- """
16
- from langchain_huggingface import HuggingFaceEmbeddings
17
- from ..portable_cache_utils.protable_cache_DynamicEnv_maker import get_settings
18
-
19
- class EmbeddingModel:
20
- def __init__(self):
21
- self.model = None
22
-
23
- def get_model(self):
24
- if self.model is None:
25
- self.model = HuggingFaceEmbeddings(
26
- model_name=get_settings().portable_cache_cache_proj_embedding_model,
27
- cache_folder=get_settings().portable_cache_chroma_db_dir,
28
- )
29
- return self.model
30
- embedding_manager = EmbeddingModel()
31
- """
File without changes