osbot-utils 2.39.0__py3-none-any.whl → 2.41.0__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.
@@ -48,15 +48,30 @@ class LLM_Request__Cache(Type_Safe):
48
48
 
49
49
  if request_hash in self.cache_index.cache_id__from__hash__request: # Check if we have an exact match
50
50
  cache_id = self.cache_index.cache_id__from__hash__request[request_hash]
51
- cache_entry = self.get_cache_entry(cache_id)
51
+ cache_entry = self.get__cache_entry__from__cache_id(cache_id)
52
52
  if cache_entry:
53
53
  return cache_entry.llm_response
54
54
 
55
55
  return None
56
56
 
57
57
  @type_safe
58
- def get_cache_entry(self, cache_id: Obj_Id) -> Optional[Schema__LLM_Response__Cache]: # Get cache entry by ID
59
- return self.cache_entries.get(cache_id)
58
+ def get__cache_entry__from__cache_id(self, cache_id: Obj_Id) -> Optional[Schema__LLM_Response__Cache]: # Get cache entry by ID
59
+ if cache_id:
60
+ return self.cache_entries.get(cache_id)
61
+
62
+ @type_safe
63
+ def get__cache_entry__from__request(self, request: Schema__LLM_Request):
64
+ cache_id = self.get__cache_id__from__request(request)
65
+ return self.get__cache_entry__from__cache_id(cache_id)
66
+
67
+ @type_safe
68
+ def get__cache_id__from__request(self, request: Schema__LLM_Request):
69
+ request_hash = self.compute_request_hash(request)
70
+ return self.get__cache_id__from__request_hash(request_hash)
71
+
72
+ @type_safe
73
+ def get__cache_id__from__request_hash(self, request_hash: Safe_Str__Hash):
74
+ return self.cache_index.cache_id__from__hash__request.get(request_hash)
60
75
 
61
76
  def exists(self, request: Schema__LLM_Request) -> bool: # True if in cache
62
77
  request_hash = self.compute_request_hash(request)
@@ -78,7 +93,7 @@ class LLM_Request__Cache(Type_Safe):
78
93
  return self.save()
79
94
 
80
95
  def get_by_id(self, cache_id : Obj_Id)-> Optional[Schema__LLM_Response]: # Cached response or None
81
- cache_entry = self.get_cache_entry(cache_id)
96
+ cache_entry = self.get__cache_entry__from__cache_id(cache_id)
82
97
  if cache_entry:
83
98
  return cache_entry.llm_response
84
99
  return None
@@ -43,7 +43,7 @@ class LLM_Request__Cache__File_System(LLM_Request__Cache):
43
43
  return cache_entry
44
44
  return None
45
45
 
46
- def get_cache_entry(self, cache_id: Obj_Id) -> Optional[Schema__LLM_Response__Cache]: # Get cache entry by ID (overridden)
46
+ def get__cache_entry__from__cache_id(self, cache_id: Obj_Id) -> Optional[Schema__LLM_Response__Cache]: # Get cache entry by ID (overridden)
47
47
  if cache_id in self.cache_entries: # Check memory first
48
48
  return self.cache_entries[cache_id]
49
49
  return self.load_cache_entry(cache_id) # Load from disk if not in memory
@@ -220,7 +220,7 @@ class LLM_Request__Cache__File_System(LLM_Request__Cache):
220
220
  # cache_id_str = os.path.splitext(os.path.basename(item_path))[0]
221
221
  # if is_obj_id(cache_id_str):
222
222
  # cache_id = Obj_Id(cache_id_str)
223
- # cache_entry = self.get_cache_entry(cache_id)
223
+ # cache_entry = self.get_cache_entry__from__cache_id(cache_id)
224
224
  # if cache_entry:
225
225
  # results.append(cache_entry)
226
226
  #
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v2.39.0
1
+ v2.41.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: osbot_utils
3
- Version: 2.39.0
3
+ Version: 2.41.0
4
4
  Summary: OWASP Security Bot - Utils
5
5
  License: MIT
6
6
  Author: Dinis Cruz
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
23
23
 
24
24
  Powerful Python util methods and classes that simplify common apis and tasks.
25
25
 
26
- ![Current Release](https://img.shields.io/badge/release-v2.39.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v2.41.0-blue)
27
27
  [![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
28
28
 
29
29
 
@@ -198,8 +198,8 @@ osbot_utils/helpers/llms/builders/LLM_Request__Builder__Open_AI.py,sha256=JwyPDe
198
198
  osbot_utils/helpers/llms/builders/LLM_Request__Factory.py,sha256=bpFXVTKpalBL7ZONjaHU5c0-2Rwzzd2vgdD1FpYxfGw,6291
199
199
  osbot_utils/helpers/llms/builders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
200
200
  osbot_utils/helpers/llms/cache/LLM_Cache__Path_Generator.py,sha256=7kDY-aaUWR4Da6lj5RPwjqTLUTGrOUYhbNfOPM30e40,4442
201
- osbot_utils/helpers/llms/cache/LLM_Request__Cache.py,sha256=LJM33aNi7teCUMNr6mpgl6MBfvOaa38H2KuJicBXMwg,6999
202
- osbot_utils/helpers/llms/cache/LLM_Request__Cache__File_System.py,sha256=eIWHqUuODyG3WYoB6SmAowb-yc4Zk28SH2GjyxGDOVg,15392
201
+ osbot_utils/helpers/llms/cache/LLM_Request__Cache.py,sha256=xmHZ8hV1w6aUjPp8zmHIydjr84keUT--Ug_ABpNSVlE,7684
202
+ osbot_utils/helpers/llms/cache/LLM_Request__Cache__File_System.py,sha256=fCCNaC9Tb3W4wQixlMjn7YDaSWOBog-83iNBfSISkP4,15425
203
203
  osbot_utils/helpers/llms/cache/LLM_Request__Cache__Storage.py,sha256=0ok7z2kGiK3edlgD0hwD5z2hYFZ91Viar1JgD7SNoxg,5434
204
204
  osbot_utils/helpers/llms/cache/Virtual_Storage__Local__Folder.py,sha256=xNM2xy0-2ROvhEFXa_jwqth7eApIcRTqcRUDxo0THXI,3214
205
205
  osbot_utils/helpers/llms/cache/Virtual_Storage__Sqlite.py,sha256=j8EWuKFVMtDBxrCEi8yNdpzwvTxO6Bri2Bi4-KwO-3s,4638
@@ -398,8 +398,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
398
398
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
399
399
  osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
400
400
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
401
- osbot_utils/version,sha256=qJGCI5s9nSw82EuuElCNdr2zaUbltf_E-fswKeYsGRI,8
402
- osbot_utils-2.39.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
403
- osbot_utils-2.39.0.dist-info/METADATA,sha256=qcgUeDsG2DpUyAbFtYabOjDWUL9lqlFQdgvBIzC4wbU,1329
404
- osbot_utils-2.39.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
405
- osbot_utils-2.39.0.dist-info/RECORD,,
401
+ osbot_utils/version,sha256=eLky5p9AdsZAnSe35UUtnXdMgjfZruQEDTickm2it3Q,8
402
+ osbot_utils-2.41.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
403
+ osbot_utils-2.41.0.dist-info/METADATA,sha256=iVynYwp95Ihql-v-k4y-kPNWeFfhLkcIe4q8rdMQ2b0,1329
404
+ osbot_utils-2.41.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
405
+ osbot_utils-2.41.0.dist-info/RECORD,,