osbot-utils 2.51.0__py3-none-any.whl → 2.53.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.
@@ -40,11 +40,15 @@ class LLM_Request__Builder(Type_Safe):
40
40
  self.llm_request_data.function_call = function_call
41
41
  return self
42
42
 
43
- def set__model (self, model : Safe_Str__Text): self.llm_request_data.model = model ; return self
44
- def set__platform (self, platform: Safe_Str__Text): self.llm_request_data.platform = platform; return self
45
- def set__provider (self, provider: Safe_Str__Text): self.llm_request_data.provider = provider; return self
46
- def set__model__gpt_4o (self ): return self.set__model('gpt-4o' )
47
- def set__model__gpt_4o_mini(self ): return self.set__model('gpt-4o-mini')
43
+ def set__model (self, model : Safe_Str__Text): self.llm_request_data.model = model ; return self
44
+ def set__platform (self, platform: Safe_Str__Text): self.llm_request_data.platform = platform; return self
45
+ def set__provider (self, provider: Safe_Str__Text): self.llm_request_data.provider = provider; return self
46
+ def set__model__gpt_4o (self ): return self.set__model('gpt-4o' )
47
+ def set__model__gpt_4o_mini (self ): return self.set__model('gpt-4o-mini' )
48
+ def set__model__gpt_4_1 (self ): return self.set__model('gpt-4.1' )
49
+ def set__model__gpt_4_1_mini(self ): return self.set__model('gpt-4.1-mini')
50
+ def set__model__gpt_4_1_nano(self ): return self.set__model('gpt-4.1-nano')
51
+
48
52
 
49
53
  @type_safe
50
54
  def build_request_payload(self) -> Dict[str, Any]:
@@ -1,6 +1,6 @@
1
1
  import re
2
- from osbot_utils.helpers.safe_str.Safe_Str import Safe_Str
3
- from osbot_utils.utils.Misc import str_md5
2
+ from osbot_utils.helpers.safe_str.Safe_Str import Safe_Str
3
+ from osbot_utils.utils.Misc import str_md5
4
4
 
5
5
  # Constants for hash validation
6
6
  SIZE__VALUE_HASH = 10
@@ -0,0 +1,13 @@
1
+
2
+ import re
3
+ from osbot_utils.helpers.safe_str.Safe_Str import Safe_Str
4
+
5
+ TYPE_SAFE_STR__URL__MAX_LENGTH = 2048 # Common maximum URL length
6
+ TYPE_SAFE_STR__URL__REGEX = re.compile(r'^(?!https?://).*|[^a-zA-Z0-9:/\-._~&=?#+%@]') # Allow characters valid in URLs
7
+
8
+ class Safe_Str__Url(Safe_Str):
9
+ regex = TYPE_SAFE_STR__URL__REGEX
10
+ max_length = TYPE_SAFE_STR__URL__MAX_LENGTH
11
+ allow_empty = False
12
+ trim_whitespace = True
13
+ allow_all_replacement_char = False
@@ -33,7 +33,8 @@ class Type_Safe__Step__From_Json:
33
33
 
34
34
  # todo: this needs refactoring, since the logic and code is getting quite complex (to be inside methods like this)
35
35
  def deserialize_from_dict(self, _self, data, raise_on_not_found=False):
36
-
36
+ if data is None:
37
+ return
37
38
  if hasattr(data, 'items') is False:
38
39
  raise ValueError(f"Expected a dictionary, but got '{type(data)}'")
39
40
 
@@ -81,12 +82,13 @@ class Type_Safe__Step__From_Json:
81
82
  if attribute_annotation_args:
82
83
  expected_type = get_args(attribute_annotation)[0] # get the first arg (which is the type)
83
84
  type_safe_list = Type_Safe__List(expected_type) # create a new instance of Type_Safe__List
84
- for item in value: # next we need to convert all items (to make sure they all match the type)
85
- if type(item) is dict:
86
- new_item = expected_type(**item) # create new object
87
- else:
88
- new_item = expected_type(item)
89
- type_safe_list.append(new_item) # and add it to the new type_safe_list obejct
85
+ if value:
86
+ for item in value: # next we need to convert all items (to make sure they all match the type)
87
+ if type(item) is dict:
88
+ new_item = expected_type(**item) # create new object
89
+ else:
90
+ new_item = expected_type(item)
91
+ type_safe_list.append(new_item) # and add it to the new type_safe_list obejct
90
92
  value = type_safe_list # todo: refactor out this create list code, maybe to an deserialize_from_list method
91
93
  else:
92
94
  if value is not None:
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v2.51.0
1
+ v2.53.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: osbot_utils
3
- Version: 2.51.0
3
+ Version: 2.53.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.51.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v2.53.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
 
@@ -193,7 +193,7 @@ osbot_utils/helpers/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
193
193
  osbot_utils/helpers/llms/actions/LLM_Request__Execute.py,sha256=IsC5gzQXG__j5M2dSWVCmV77Kf133pKbZRvbiQyeihU,2453
194
194
  osbot_utils/helpers/llms/actions/Type_Safe__Schema_For__LLMs.py,sha256=em9RoSZqSSo6BQBZvEKH8Qv8f8f8oubNpy0LIDsak-E,12024
195
195
  osbot_utils/helpers/llms/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
196
- osbot_utils/helpers/llms/builders/LLM_Request__Builder.py,sha256=PvLvDdZsvwb_W5Na0JUyQpboX00-6lrP3lEXnaHs79E,3488
196
+ osbot_utils/helpers/llms/builders/LLM_Request__Builder.py,sha256=2Zp4Ka4q2XcZNUuR47kP7iyhfLsY2A_rxOME3i6olgE,3811
197
197
  osbot_utils/helpers/llms/builders/LLM_Request__Builder__Open_AI.py,sha256=JwyPDeBUQd70Ltm801y5qvS883IIC7TcfG04D3LWdGI,3430
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
@@ -236,9 +236,10 @@ osbot_utils/helpers/python_compatibility/python_3_8.py,sha256=kh846vs3ir8xD0RSAR
236
236
  osbot_utils/helpers/safe_str/Safe_Str.py,sha256=BKyS0hTRvP-f0uLFtT8KCE9rVQBzhWKNoSxlttEjrEE,3261
237
237
  osbot_utils/helpers/safe_str/Safe_Str__File__Name.py,sha256=ncjkQ2hAhw0a3UulrCuQsA9ytrFwg5CT1XRJIGChMpY,289
238
238
  osbot_utils/helpers/safe_str/Safe_Str__File__Path.py,sha256=K0yBcvH_Ncqiw7tMqjGqaNyWQh1Zs9qxZ-TR8nEIAow,550
239
- osbot_utils/helpers/safe_str/Safe_Str__Hash.py,sha256=0qL-C418UX6xYwSh05Vl_TgBZjLYgW_sUkkZTwNRW64,935
239
+ osbot_utils/helpers/safe_str/Safe_Str__Hash.py,sha256=Tb2QeVpVDNWpCJGHNFjZPCQ_ZTaI7Z5BDzi19LiO_cI,952
240
240
  osbot_utils/helpers/safe_str/Safe_Str__Text.py,sha256=QxuWqF8hNYdOPDn3Yac86h_1ZaX-THbTBDakberiJcs,313
241
241
  osbot_utils/helpers/safe_str/Safe_Str__Text__Dangerous.py,sha256=6-fkXBuWgjz70eQicD07f38eEuKqNzJzaFFY6hozhNQ,388
242
+ osbot_utils/helpers/safe_str/Safe_Str__Url.py,sha256=5ioWlU0H8kQfmNwpJ5REpFvxAyBBCPFjWHiyXqBGeFg,588
242
243
  osbot_utils/helpers/safe_str/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
243
244
  osbot_utils/helpers/sqlite/Capture_Sqlite_Error.py,sha256=GSuRYgs1yKQjxMszPoaI7fsfMfuUqhb64AaIysRE6Cs,1747
244
245
  osbot_utils/helpers/sqlite/Sqlite__Cursor.py,sha256=4Im0pCOiERX6Nnf6iagRlSvTR3CPjyPVkdx4NMQV0P0,3342
@@ -362,7 +363,7 @@ osbot_utils/type_safe/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
362
363
  osbot_utils/type_safe/steps/Type_Safe__Step__Class_Kwargs.py,sha256=snoyJKvZ1crgF2fp0zexwNPnV_E63RfyRIsMAZdrKNY,6995
363
364
  osbot_utils/type_safe/steps/Type_Safe__Step__Default_Kwargs.py,sha256=tzKXDUc0HVP5QvCWsmcPuuZodNvQZ9FeMDNI2x00Ngw,1943
364
365
  osbot_utils/type_safe/steps/Type_Safe__Step__Default_Value.py,sha256=b5vsgM8eg9yq2KM0wRMntVHma6OhN_HnU76LxhEIpoA,4483
365
- osbot_utils/type_safe/steps/Type_Safe__Step__From_Json.py,sha256=33nlJC9WymFHf5JQzbpCF5sUpfsAcziyhNXkKC9YAPk,14517
366
+ osbot_utils/type_safe/steps/Type_Safe__Step__From_Json.py,sha256=AguNcZwKKnyNY87bSAF1xLwYW5h_IDfUad70QqIiK3I,14622
366
367
  osbot_utils/type_safe/steps/Type_Safe__Step__Init.py,sha256=dQRwFxEMdmoW2ogmYZ6ZxLOvt1XnALx41LPpIB6yp3s,4473
367
368
  osbot_utils/type_safe/steps/Type_Safe__Step__Set_Attr.py,sha256=VuKHH9QEYlbAL9R4zwQ5dwexx2sFY6wMx52QmF7eqcg,5219
368
369
  osbot_utils/type_safe/steps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -398,8 +399,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
398
399
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
399
400
  osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
400
401
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
401
- osbot_utils/version,sha256=3pjyCNI6feI53jNDvOPiiOgb7XbYsxyo7WABfsNLeYw,8
402
- osbot_utils-2.51.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
403
- osbot_utils-2.51.0.dist-info/METADATA,sha256=AGRyZ9xloQ28HoIAwgjWRkaFtOusYgANISdEBm89RZ8,1329
404
- osbot_utils-2.51.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
405
- osbot_utils-2.51.0.dist-info/RECORD,,
402
+ osbot_utils/version,sha256=dP4NljgheSgZk8AOOmmRsf9q_jvd1EAlse1RSgLPF94,8
403
+ osbot_utils-2.53.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
404
+ osbot_utils-2.53.0.dist-info/METADATA,sha256=yj_jvJ4Y7ldU2hdyK53bGY28vXWtU1wRUQNu79AKHuo,1329
405
+ osbot_utils-2.53.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
406
+ osbot_utils-2.53.0.dist-info/RECORD,,