osbot-utils 2.87.0__py3-none-any.whl → 2.89.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.
- osbot_utils/helpers/duration/decorators/capture_duration.py +0 -1
- osbot_utils/helpers/html/schemas/Schema__Html_Node__Data__Type.py +1 -1
- osbot_utils/helpers/llms/builders/LLM_Request__Builder.py +11 -11
- osbot_utils/helpers/llms/schemas/Schema__LLM_Request__Data.py +6 -6
- osbot_utils/type_safe/Type_Safe.py +1 -1
- osbot_utils/type_safe/primitives/safe_str/Safe_Str.py +7 -5
- osbot_utils/type_safe/primitives/safe_str/llm/Enum__LLM__Role.py +10 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Description.py +14 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__Assistant.py +7 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__System.py +7 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__Tool.py +7 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__User.py +7 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Modality.py +14 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Model_ID.py +14 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Model_Name.py +13 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Model_Slug.py +12 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Prompt.py +7 -0
- osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Tokenizer.py +13 -0
- osbot_utils/type_safe/primitives/safe_str/llm/__init__.py +0 -0
- osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Code__Snippet.py +9 -0
- osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__API__Parameter.py +13 -0
- osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Email.py +12 -0
- osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Password.py +14 -0
- osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Username.py +8 -0
- osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Raise_Exception.py +6 -2
- osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Validation.py +6 -6
- osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Class_Kwargs.py +1 -1
- osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Init.py +6 -3
- osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Set_Attr.py +5 -5
- osbot_utils/utils/Objects.py +22 -9
- osbot_utils/version +1 -1
- {osbot_utils-2.87.0.dist-info → osbot_utils-2.89.0.dist-info}/METADATA +2 -2
- {osbot_utils-2.87.0.dist-info → osbot_utils-2.89.0.dist-info}/RECORD +35 -18
- osbot_utils/helpers/llms/schemas/Safe_Str__LLM__Model_Name.py +0 -10
- {osbot_utils-2.87.0.dist-info → osbot_utils-2.89.0.dist-info}/LICENSE +0 -0
- {osbot_utils-2.87.0.dist-info → osbot_utils-2.89.0.dist-info}/WHEEL +0 -0
@@ -1,14 +1,14 @@
|
|
1
|
-
from typing
|
2
|
-
from osbot_utils.helpers.llms.actions.Type_Safe__Schema_For__LLMs
|
3
|
-
from osbot_utils.
|
4
|
-
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request
|
5
|
-
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Data
|
6
|
-
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Function_Call
|
7
|
-
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Message__Content
|
8
|
-
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Message__Role
|
9
|
-
from osbot_utils.type_safe.Type_Safe
|
10
|
-
from osbot_utils.type_safe.primitives.safe_str.text.Safe_Str__Text
|
11
|
-
from osbot_utils.type_safe.type_safe_core.decorators.type_safe
|
1
|
+
from typing import Dict, Any, Type
|
2
|
+
from osbot_utils.helpers.llms.actions.Type_Safe__Schema_For__LLMs import Type_Safe__Schema_For__LLMs
|
3
|
+
from osbot_utils.type_safe.primitives.safe_str.llm.Safe_Str__LLM__Model_Name import Safe_Str__LLM__Model_Name
|
4
|
+
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request import Schema__LLM_Request
|
5
|
+
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Data import Schema__LLM_Request__Data
|
6
|
+
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Function_Call import Schema__LLM_Request__Function_Call
|
7
|
+
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Message__Content import Schema__LLM_Request__Message__Content
|
8
|
+
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Message__Role import Schema__LLM_Request__Message__Role
|
9
|
+
from osbot_utils.type_safe.Type_Safe import Type_Safe
|
10
|
+
from osbot_utils.type_safe.primitives.safe_str.text.Safe_Str__Text import Safe_Str__Text
|
11
|
+
from osbot_utils.type_safe.type_safe_core.decorators.type_safe import type_safe
|
12
12
|
|
13
13
|
|
14
14
|
class LLM_Request__Builder(Type_Safe):
|
@@ -1,9 +1,9 @@
|
|
1
|
-
from typing
|
2
|
-
from osbot_utils.helpers.llms.schemas.
|
3
|
-
from osbot_utils.helpers.llms.schemas.
|
4
|
-
from osbot_utils.
|
5
|
-
from osbot_utils.type_safe.
|
6
|
-
from osbot_utils.type_safe.primitives.safe_str.text.Safe_Str__Text
|
1
|
+
from typing import List, Optional
|
2
|
+
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Function_Call import Schema__LLM_Request__Function_Call
|
3
|
+
from osbot_utils.helpers.llms.schemas.Schema__LLM_Request__Message__Content import Schema__LLM_Request__Message__Content
|
4
|
+
from osbot_utils.type_safe.Type_Safe import Type_Safe
|
5
|
+
from osbot_utils.type_safe.primitives.safe_str.llm.Safe_Str__LLM__Model_Name import Safe_Str__LLM__Model_Name
|
6
|
+
from osbot_utils.type_safe.primitives.safe_str.text.Safe_Str__Text import Safe_Str__Text
|
7
7
|
|
8
8
|
|
9
9
|
class Schema__LLM_Request__Data(Type_Safe): # Schema for LLM API request data
|
@@ -88,7 +88,7 @@ class Type_Safe:
|
|
88
88
|
if value is not None:
|
89
89
|
if hasattr(self,'__annotations__'): # can only do type safety checks if the class does not have annotations
|
90
90
|
if type_safe_validation.check_if__type_matches__obj_annotation__for_attr(self, key, value) is False:
|
91
|
-
raise ValueError(f"
|
91
|
+
raise ValueError(f"On {self.__class__.__name__} invalid type for attribute '{key}'. Expected '{self.__annotations__.get(key)}' but got '{type(value)}'")
|
92
92
|
setattr(self, key, value)
|
93
93
|
return self
|
94
94
|
|
@@ -8,16 +8,16 @@ TYPE_SAFE__STR__MAX_LENGTH = 512
|
|
8
8
|
|
9
9
|
|
10
10
|
class Safe_Str(Type_Safe__Primitive, str):
|
11
|
+
allow_all_replacement_char: bool = True
|
12
|
+
allow_empty : bool = True # note: making this False does cause some side effects on .json() on cases like auto serialization in environments like FastAPI (like it requires more explict value setting), so all have now been converted into a value of True
|
13
|
+
exact_length : bool = False # If True, require exact length match, not just max length
|
11
14
|
max_length : int = TYPE_SAFE__STR__MAX_LENGTH
|
12
15
|
regex : re.Pattern = TYPE_SAFE__STR__REGEX__SAFE_STR
|
13
16
|
regex_mode : Enum__Safe_Str__Regex_Mode = Enum__Safe_Str__Regex_Mode.REPLACE
|
14
17
|
replacement_char : str = '_'
|
15
|
-
allow_empty : bool = True # note: making this False does cause some side effects on .json() on cases like auto serialization in environments like FastAPI (like it requires more explict value setting), so all have now been converted into a value of True
|
16
|
-
trim_whitespace : bool = False
|
17
|
-
allow_all_replacement_char: bool = True
|
18
18
|
strict_validation : bool = False # If True, don't replace invalid chars, raise an error instead
|
19
|
-
|
20
|
-
|
19
|
+
to_lower_case : bool = False # If True, convert string to lowercase
|
20
|
+
trim_whitespace : bool = False
|
21
21
|
|
22
22
|
def __new__(cls, value: Optional[str] = None) -> 'Safe_Str':
|
23
23
|
|
@@ -46,6 +46,8 @@ class Safe_Str(Type_Safe__Primitive, str):
|
|
46
46
|
|
47
47
|
sanitized_value = cls.validate_and_sanitize(value)
|
48
48
|
|
49
|
+
if cls.to_lower_case:
|
50
|
+
sanitized_value = sanitized_value.lower()
|
49
51
|
|
50
52
|
return str.__new__(cls, sanitized_value)
|
51
53
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__LLM__Description(Safe_Str): # LLM model or feature description
|
5
|
+
max_length = 4096
|
6
|
+
regex = re.compile(r'[^a-zA-Z0-9_ ()\[\]\-+=:;,.?*/\\×\n`&"\'#%<>{}$@|!\s~]') # Allows common description chars
|
7
|
+
|
8
|
+
# Supports rich descriptions with:
|
9
|
+
# - Basic punctuation and formatting
|
10
|
+
# - Mathematical symbols (×, +, -)
|
11
|
+
# - Common special characters for technical descriptions
|
12
|
+
# - Newlines for multi-line descriptions
|
13
|
+
# - Brackets for annotations [like this]
|
14
|
+
# - Quotes for "emphasis" or 'terms'
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
|
5
|
+
class Safe_Str__LLM__Message__Assistant(Safe_Str): # For assistant/AI responses
|
6
|
+
max_length = 32768 # Full context window for responses
|
7
|
+
regex = re.compile(r'[\x00-\x08\x0B\x0C\x0E-\x1F]') # Permissive - only control chars
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
|
5
|
+
class Safe_Str__LLM__Message__System(Safe_Str): # For system prompts
|
6
|
+
max_length = 4096 # Shorter than full prompts
|
7
|
+
regex = re.compile(r'[\x00-\x08\x0B\x0C\x0E-\x1F]') # Remove control chars EXCEPT tab (\x09), newline (\x0A), and carriage return (\x0D)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
|
5
|
+
class Safe_Str__LLM__Message__Tool(Safe_Str): # For tool/function responses
|
6
|
+
max_length = 16384 # Tool responses often shorter
|
7
|
+
regex = re.compile(r'[\x00-\x08\x0B\x0C\x0E-\x1F]') # Permissive for JSON/structured data
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
|
5
|
+
class Safe_Str__LLM__Message__User(Safe_Str): # For user messages
|
6
|
+
max_length = 32768 # Full context window for user input
|
7
|
+
regex = re.compile(r'[\x00-\x08\x0B\x0C\x0E-\x1F]') # Permissive - only control chars
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__LLM__Modality(Safe_Str): # LLM model modality descriptor
|
5
|
+
max_length = 128
|
6
|
+
regex = re.compile(r'[^a-zA-Z0-9+\->\s]') # Allows: alphanumeric, +, -, >, space
|
7
|
+
|
8
|
+
# Supports modality descriptions:
|
9
|
+
# - "text"
|
10
|
+
# - "text->image"
|
11
|
+
# - "image+text->text"
|
12
|
+
# - "multimodal"
|
13
|
+
# - "text + vision"
|
14
|
+
# - "audio->text"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__LLM__Model_ID(Safe_Str): # Generic LLM model identifier
|
5
|
+
max_length = 256
|
6
|
+
regex = re.compile(r'[^a-zA-Z0-9/\-.:_@]') # Allows: alphanumeric, /, -, ., :, _, @
|
7
|
+
|
8
|
+
|
9
|
+
# Supports various model ID formats:
|
10
|
+
# - OpenRouter: "openai/gpt-4", "anthropic/claude-3-opus"
|
11
|
+
# - OpenAI: "gpt-4", "gpt-3.5-turbo"
|
12
|
+
# - Anthropic: "claude-3-opus-20240229", "claude-3-sonnet@20240229"
|
13
|
+
# - Cohere: "command-r-plus"
|
14
|
+
# - Google: "models/gemini-pro"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__LLM__Model_Name(Safe_Str): # Human-readable LLM model name
|
5
|
+
max_length = 256
|
6
|
+
regex = re.compile(r'[^a-zA-Z0-9: .\-()+,]') # Allows: alphanumeric, :, space, ., -, (, ), +, &, ,
|
7
|
+
|
8
|
+
# Supports various display names:
|
9
|
+
# - "GPT-4 Turbo"
|
10
|
+
# - "Claude 3 Opus (Latest)"
|
11
|
+
# - "Llama 3.1: Instruct (70B)"
|
12
|
+
# - "Command R+"
|
13
|
+
# - "Gemini Pro 1.5"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__LLM__Model_Slug(Safe_Str): # URL-safe LLM model slug
|
5
|
+
max_length = 256
|
6
|
+
regex = re.compile(r'[^a-zA-Z0-9/\-._]') # Allows: alphanumeric, /, -, ., _
|
7
|
+
|
8
|
+
# URL-safe slugs for routing/APIs:
|
9
|
+
# - "gpt-4-turbo"
|
10
|
+
# - "claude-3-opus"
|
11
|
+
# - "llama-3.1-70b"
|
12
|
+
# - "command_r_plus"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
|
5
|
+
class Safe_Str__LLM__Prompt(Safe_Str): # Or Safe_Str__LLM__Message
|
6
|
+
max_length = 32768 # Common context window size
|
7
|
+
regex = re.compile(r'[\x00\x01-\x08\x0B\x0C\x0E-\x1F]') # Remove control chars only
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__LLM__Tokenizer(Safe_Str): # LLM tokenizer type identifier
|
5
|
+
max_length = 64
|
6
|
+
regex = re.compile(r'[^a-zA-Z0-9\-_\s]') # Allows: alphanumeric, -, _, space
|
7
|
+
|
8
|
+
# Supports tokenizer names:
|
9
|
+
# - "cl100k_base"
|
10
|
+
# - "tiktoken"
|
11
|
+
# - "GPT-4 Tokenizer"
|
12
|
+
# - "sentencepiece"
|
13
|
+
# - "BPE"
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import re
|
2
|
+
|
3
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
4
|
+
|
5
|
+
|
6
|
+
class Safe_Str__Code__Snippet(Safe_Str): # Allows various characters needed for code snippets.
|
7
|
+
regex = re.compile(r'[^a-zA-Z0-9_\-.\s(),;:=+\[\]{}\'"]<>')
|
8
|
+
max_length = 1024
|
9
|
+
trim_whitespace = False # Preserve leading whitespace for code indentation
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__API__Parameter(Safe_Str): # Generic API parameter name
|
5
|
+
max_length = 64
|
6
|
+
regex = re.compile(r'[^a-zA-Z0-9_]') # Allows: alphanumeric, _
|
7
|
+
|
8
|
+
# Standard API parameter names:
|
9
|
+
# - "max_tokens"
|
10
|
+
# - "temperature"
|
11
|
+
# - "top_p"
|
12
|
+
# - "stream"
|
13
|
+
# - "response_format"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
class Safe_Str__Email(Safe_Str): # Special class for emails with simple custom validation.
|
5
|
+
regex = re.compile(r'[^a-zA-Z0-9_\-.@]')
|
6
|
+
max_length = 256
|
7
|
+
|
8
|
+
def __new__(cls, value=None):
|
9
|
+
result = super().__new__(cls, value)
|
10
|
+
if '@' not in result: # Additional validation for email format
|
11
|
+
raise ValueError(f"in {cls.__name__}, email must contain an @ symbol")
|
12
|
+
return result
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import re
|
2
|
+
|
3
|
+
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
4
|
+
|
5
|
+
|
6
|
+
class Safe_Str__Password(Safe_Str): # Password with minimum requirements.
|
7
|
+
regex = re.compile(r'[^a-zA-Z0-9_\-.\s!@#$%^&*()]')
|
8
|
+
min_length = 8 # Custom attribute
|
9
|
+
|
10
|
+
def __new__(cls, value=None):
|
11
|
+
result = super().__new__(cls, value)
|
12
|
+
if len(result) < cls.min_length:
|
13
|
+
raise ValueError(f"Password must be at least {cls.min_length} characters long")
|
14
|
+
return result
|
@@ -3,8 +3,12 @@ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Shared__Variables im
|
|
3
3
|
|
4
4
|
class Type_Safe__Raise_Exception:
|
5
5
|
|
6
|
-
def
|
7
|
-
exception_message = f"
|
6
|
+
def type_mismatch_error__on_instance(self, _self, var_name: str, expected_type: type, actual_type: type) -> None: # Raises formatted error for type validation failures
|
7
|
+
exception_message = f"On {_self.__class__.__name__}, invalid type for attribute '{var_name}'. Expected '{expected_type}' but got '{actual_type}'"
|
8
|
+
raise ValueError(exception_message) from None
|
9
|
+
|
10
|
+
def type_mismatch_error__on_type(self, cls, var_name: str, expected_type: type, actual_type: type) -> None: # Raises formatted error for type validation failures
|
11
|
+
exception_message = f"On {cls.__name__}, invalid type for attribute '{var_name}'. Expected '{expected_type}' but got '{actual_type}'"
|
8
12
|
raise ValueError(exception_message) from None
|
9
13
|
|
10
14
|
def immutable_type_error(self, var_name, var_type):
|
@@ -270,11 +270,11 @@ class Type_Safe__Validation:
|
|
270
270
|
def validate_if_value_has_been_set(self, _self, annotations, name, value):
|
271
271
|
if hasattr(_self, name) and annotations.get(name) : # don't allow previously set variables to be set to None
|
272
272
|
if getattr(_self, name) is not None: # unless it is already set to None
|
273
|
-
raise ValueError(f"
|
273
|
+
raise ValueError(f"On {_self.__class__.__name__}, can't be set to None, to a variable that is already set. Invalid type for attribute '{name}'. Expected '{_self.__annotations__.get(name)}' but got '{type(value)}'")
|
274
274
|
|
275
|
-
def validate_if__types_are_compatible_for_assigment(self, name, current_type, expected_type):
|
275
|
+
def validate_if__types_are_compatible_for_assigment(self, _self, name, current_type, expected_type):
|
276
276
|
if not type_safe_validation.are_types_compatible_for_assigment(current_type, expected_type):
|
277
|
-
type_safe_raise_exception.
|
277
|
+
type_safe_raise_exception.type_mismatch_error__on_instance(_self, name, expected_type, current_type)
|
278
278
|
|
279
279
|
def validate_type_compatibility(self, target : Any , # Target object to validate
|
280
280
|
annotations : Dict[str, Any] , # Type annotations
|
@@ -295,7 +295,7 @@ class Type_Safe__Validation:
|
|
295
295
|
actual_type = value
|
296
296
|
else:
|
297
297
|
actual_type = type(value)
|
298
|
-
raise ValueError(f"
|
298
|
+
raise ValueError(f"On {target.__class__.__name__}, invalid type for attribute '{name}'. Expected '{expected_type}' but got '{actual_type}'") from None
|
299
299
|
|
300
300
|
# todo: see if need to add cache support to this method (it looks like this method is not called very often)
|
301
301
|
def validate_type_immutability(self, var_name: str, var_type: Any) -> None: # Validates that type is immutable or in supported format
|
@@ -321,8 +321,8 @@ class Type_Safe__Validation:
|
|
321
321
|
# if not (isinstance(var_type, type) and issubclass(var_type, (int,str, float))):
|
322
322
|
# type_safe_raise_exception.immutable_type_error(var_name, var_type)
|
323
323
|
|
324
|
-
def validate_variable_type(self, var_name, var_type, var_value): # Validate type compatibility
|
324
|
+
def validate_variable_type(self, base_cls, var_name, var_type, var_value): # Validate type compatibility
|
325
325
|
if type(var_type) is type and not isinstance(var_value, var_type):
|
326
|
-
type_safe_raise_exception.
|
326
|
+
type_safe_raise_exception.type_mismatch_error__on_type(base_cls, var_name, var_type, type(var_value))
|
327
327
|
|
328
328
|
type_safe_validation = Type_Safe__Validation()
|
@@ -96,7 +96,7 @@ class Type_Safe__Step__Class_Kwargs:
|
|
96
96
|
# If conversion fails, let the original validation handle it
|
97
97
|
pass
|
98
98
|
|
99
|
-
type_safe_validation.validate_variable_type(var_name, var_type, var_value)
|
99
|
+
type_safe_validation.validate_variable_type(base_cls, var_name, var_type, var_value)
|
100
100
|
type_safe_validation.validate_type_immutability(var_name, var_type)
|
101
101
|
|
102
102
|
def process_annotation(self, cls : Type , # Process single annotation
|
@@ -33,13 +33,16 @@ class Type_Safe__Step__Init:
|
|
33
33
|
raise ValueError(f"{__self.__class__.__name__} has no attribute '{key}' and cannot be assigned the value '{value}'. "
|
34
34
|
f"Use {__self.__class__.__name__}.__default_kwargs__() see what attributes are available") from None
|
35
35
|
|
36
|
-
def convert_value_to_type_safe_objects(self, __self, key, value):
|
36
|
+
def convert_value_to_type_safe_objects(self, __self, key, value):
|
37
37
|
annotation = type_safe_annotations.obj_attribute_annotation(__self, key)
|
38
38
|
if annotation:
|
39
39
|
if isinstance(annotation, EnumMeta) and type(value) is str:
|
40
|
-
if value
|
40
|
+
if value in annotation.__members__: # First check if it's a valid name (e.g., 'SYSTEM')
|
41
|
+
value = annotation[value]
|
42
|
+
elif hasattr(annotation, '_value2member_map_') and value in annotation._value2member_map_: # Then check if it's a valid value (e.g., 'system')
|
43
|
+
value = annotation._value2member_map_[value]
|
44
|
+
else:
|
41
45
|
raise ValueError(f"Invalid value '{value}' for enum {annotation.__name__}")
|
42
|
-
value = annotation[value]
|
43
46
|
else:
|
44
47
|
|
45
48
|
origin = type_safe_annotations.get_origin(annotation)
|
@@ -22,7 +22,7 @@ class Type_Safe__Step__Set_Attr:
|
|
22
22
|
else:
|
23
23
|
value = self.resolve_value__from_origin(value)
|
24
24
|
|
25
|
-
self.validate_literal_value(annotations, name, value) # Check Literal value constraints before generic type checking
|
25
|
+
self.validate_literal_value(_self, annotations, name, value) # Check Literal value constraints before generic type checking
|
26
26
|
|
27
27
|
type_safe_validation.validate_type_compatibility(_self, annotations, name, value)
|
28
28
|
return value
|
@@ -106,7 +106,7 @@ class Type_Safe__Step__Set_Attr:
|
|
106
106
|
if name in immutable_vars:
|
107
107
|
expected_type = immutable_vars[name]
|
108
108
|
current_type = type if value is type else type(value)
|
109
|
-
type_safe_validation.validate_if__types_are_compatible_for_assigment(name, current_type, expected_type)
|
109
|
+
type_safe_validation.validate_if__types_are_compatible_for_assigment(_self, name, current_type, expected_type)
|
110
110
|
_super.__setattr__(name, value)
|
111
111
|
return True
|
112
112
|
return False
|
@@ -129,7 +129,7 @@ class Type_Safe__Step__Set_Attr:
|
|
129
129
|
|
130
130
|
_super.__setattr__(name, value)
|
131
131
|
|
132
|
-
def validate_literal_value(self, annotations, name, value): # Check if a value is valid for a Literal type annotation
|
132
|
+
def validate_literal_value(self, _self, annotations, name, value): # Check if a value is valid for a Literal type annotation
|
133
133
|
|
134
134
|
annotation = annotations.get(name)
|
135
135
|
if not annotation:
|
@@ -145,7 +145,7 @@ class Type_Safe__Step__Set_Attr:
|
|
145
145
|
allowed_values = get_args(arg) # Found Literal inside Optional
|
146
146
|
if value is not None and value not in allowed_values:
|
147
147
|
allowed_str = ', '.join(repr(v) for v in allowed_values)
|
148
|
-
raise ValueError(f"
|
148
|
+
raise ValueError(f"On {_self.__class__.__name__}, invalid value for '{name}': must be one of [{allowed_str}], got {repr(value)}")
|
149
149
|
return
|
150
150
|
|
151
151
|
|
@@ -153,7 +153,7 @@ class Type_Safe__Step__Set_Attr:
|
|
153
153
|
allowed_values = get_args(annotation)
|
154
154
|
if value not in allowed_values:
|
155
155
|
allowed_str = ', '.join(repr(v) for v in allowed_values)
|
156
|
-
raise ValueError(f"
|
156
|
+
raise ValueError(f"On {_self.__class__.__name__}, invalid value for '{name}': must be one of [{allowed_str}], got {repr(value)}")
|
157
157
|
|
158
158
|
|
159
159
|
type_safe_step_set_attr = Type_Safe__Step__Set_Attr()
|
osbot_utils/utils/Objects.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
from types
|
2
|
-
|
1
|
+
from types import SimpleNamespace
|
3
2
|
from osbot_utils.testing.__ import __
|
4
3
|
|
5
4
|
def base_classes(cls):
|
@@ -96,10 +95,13 @@ def str_to_obj(target):
|
|
96
95
|
return dict_to_obj(json.loads(target))
|
97
96
|
|
98
97
|
def enum_from_value(enum_type, value):
|
99
|
-
|
100
|
-
return enum_type[value]
|
101
|
-
|
102
|
-
|
98
|
+
if value in enum_type.__members__: # Try to get by name (e.g., 'SYSTEM')
|
99
|
+
return enum_type[value]
|
100
|
+
|
101
|
+
if hasattr(enum_type, '_value2member_map_') and value in enum_type._value2member_map_: # Try to get by value (e.g., 'system') using the reverse mapping
|
102
|
+
return enum_type._value2member_map_[value]
|
103
|
+
|
104
|
+
raise ValueError(f"Value '{value}' is not a valid member of {enum_type.__name__}.") # If neither worked, raise an error
|
103
105
|
|
104
106
|
|
105
107
|
def get_field(target, field, default=None):
|
@@ -276,13 +278,18 @@ def serialize_to_dict(obj):
|
|
276
278
|
return obj.json() # use the provided .json() method, which handles the type conversions more specifically to those types (dict, list, set and tuple)
|
277
279
|
elif hasattr(obj, '__primitive_base__') and isinstance(obj, (str, int, float)):
|
278
280
|
return obj.__primitive_base__(obj)
|
281
|
+
elif isinstance(obj, Enum):
|
282
|
+
if isinstance(obj.value, (str, int, float, bool, type(None))): # Check if the enum value is directly serializable
|
283
|
+
return obj.value
|
284
|
+
elif isinstance(obj.value, (list, tuple, dict, set)): # Recursively serialize complex values
|
285
|
+
return serialize_to_dict(obj.value)
|
286
|
+
else:
|
287
|
+
return obj.name # Fallback to name for non-serializable values
|
279
288
|
elif isinstance(obj, (str, int, float, bool, bytes, Decimal)) or obj is None: # todo: add support for objects like datetime
|
280
289
|
return obj
|
281
|
-
elif isinstance(obj, Enum):
|
282
|
-
return obj.name
|
283
290
|
elif isinstance(obj, type):
|
284
291
|
return f"{obj.__module__}.{obj.__name__}" # save the full type name
|
285
|
-
elif isinstance(obj, (list, tuple, List)):
|
292
|
+
elif isinstance(obj, (list, tuple, List)): # Added tuple here
|
286
293
|
return [serialize_to_dict(item) for item in obj]
|
287
294
|
elif isinstance(obj, set):
|
288
295
|
return [serialize_to_dict(item) for item in obj]
|
@@ -296,6 +303,12 @@ def serialize_to_dict(obj):
|
|
296
303
|
serialized_dict[serialized_key] = serialize_to_dict(value) # Recursively serialize the value
|
297
304
|
return serialized_dict
|
298
305
|
#return {key: serialize_to_dict(value) for key, value in obj.items()}
|
306
|
+
elif callable(obj) and not isinstance(obj, type): # For functions/lambdas, return a string representation
|
307
|
+
if hasattr(obj, '__name__'):
|
308
|
+
return obj.__name__
|
309
|
+
if hasattr(obj, '__class__'):
|
310
|
+
return obj.__class__.__name__
|
311
|
+
return str(obj)
|
299
312
|
elif hasattr(obj, "__dict__"):
|
300
313
|
data = {} # todo: look at a more advanced version which saved the type of the object, for example with {'__type__': type(obj).__name__}
|
301
314
|
for key, value in obj.__dict__.items():
|
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v2.
|
1
|
+
v2.89.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.89.0
|
4
4
|
Summary: OWASP Security Bot - Utils
|
5
5
|
License: MIT
|
6
6
|
Author: Dinis Cruz
|
@@ -21,7 +21,7 @@ Description-Content-Type: text/markdown
|
|
21
21
|
|
22
22
|
# OSBot-Utils
|
23
23
|
|
24
|
-

|
25
25
|

|
26
26
|

|
27
27
|

|
@@ -137,7 +137,7 @@ osbot_utils/helpers/cache_requests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
|
|
137
137
|
osbot_utils/helpers/duration/Duration.py,sha256=KvHaAB6NWa40DXQl2gC9m98gM-arVP-aYqFrmAyQQzM,2306
|
138
138
|
osbot_utils/helpers/duration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
139
139
|
osbot_utils/helpers/duration/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
140
|
-
osbot_utils/helpers/duration/decorators/capture_duration.py,sha256=
|
140
|
+
osbot_utils/helpers/duration/decorators/capture_duration.py,sha256=_JGWEE8xzYFhNvPjUVmERQP9ev2N65Aqx0hBIt2iy5A,1239
|
141
141
|
osbot_utils/helpers/duration/decorators/duration.py,sha256=ucJP1fCQEN8ALCDCG9CPzPn1KqojD4ttFc3HLke-nvY,651
|
142
142
|
osbot_utils/helpers/duration/decorators/print_duration.py,sha256=w7k3OPiRkL5KqLv0S5o1NVo2y_TeOOvDOb-51YbJjAc,283
|
143
143
|
osbot_utils/helpers/duration/schemas/Schema__Duration.py,sha256=-h32wBcpiVRkEbc_sZoamnRFNGaQQM4YsxqoVzPGe38,209
|
@@ -179,7 +179,7 @@ osbot_utils/helpers/html/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
179
179
|
osbot_utils/helpers/html/schemas/Schema__Html_Document.py,sha256=tQJLc0rf2CuG1sGNB04cPyVV7KpCGXYDt0wEnFtWohg,403
|
180
180
|
osbot_utils/helpers/html/schemas/Schema__Html_Node.py,sha256=iMGClwil99_KoeLuft53DQLu9Jw-PCqRjBXpfInd7rM,794
|
181
181
|
osbot_utils/helpers/html/schemas/Schema__Html_Node__Data.py,sha256=GiAZY5mO3DNasUO_oNM4ndTvRU2VpjPxOi7kYzu2DHE,568
|
182
|
-
osbot_utils/helpers/html/schemas/Schema__Html_Node__Data__Type.py,sha256=
|
182
|
+
osbot_utils/helpers/html/schemas/Schema__Html_Node__Data__Type.py,sha256=D2imfu_SWJkSkUENqOqxM2IKQpAb7YESuPBwSHhpvbY,95
|
183
183
|
osbot_utils/helpers/html/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
184
184
|
osbot_utils/helpers/html/tags/Tag__Base.py,sha256=W6zw5Sn4i8bEM6PTUVRlZgOwDRZFRxpaOjVthpJRPn4,4483
|
185
185
|
osbot_utils/helpers/html/tags/Tag__Body.py,sha256=BK_VJHMnGl-RpV_6C_C21hThgMVq76r5XtvtKAqFf0c,114
|
@@ -207,7 +207,7 @@ osbot_utils/helpers/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
207
207
|
osbot_utils/helpers/llms/actions/LLM_Request__Execute.py,sha256=mgibU74brzKsO4lZEuQrs2AADDRik6WjZEb3KxiGUfE,2454
|
208
208
|
osbot_utils/helpers/llms/actions/Type_Safe__Schema_For__LLMs.py,sha256=SfatdVI7sbFXSiEY--6FkW9amLrYUFhZw1xvgKrE_-s,12064
|
209
209
|
osbot_utils/helpers/llms/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
210
|
-
osbot_utils/helpers/llms/builders/LLM_Request__Builder.py,sha256=
|
210
|
+
osbot_utils/helpers/llms/builders/LLM_Request__Builder.py,sha256=EaI9uGhlBHvxRlX4J89GKdA0eYZAJkL34qqblgLPRzw,4020
|
211
211
|
osbot_utils/helpers/llms/builders/LLM_Request__Builder__Open_AI.py,sha256=j9m99MS0NwJPqHj85Q4FOhhyIPKHnx2wj6RJLOOKlls,3431
|
212
212
|
osbot_utils/helpers/llms/builders/LLM_Request__Factory.py,sha256=OQW0nIfmXvc2RdT84GtMM-BlMp04iQOUsgIieU8NKcs,6291
|
213
213
|
osbot_utils/helpers/llms/builders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -221,10 +221,9 @@ osbot_utils/helpers/llms/cache/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
221
221
|
osbot_utils/helpers/llms/platforms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
222
222
|
osbot_utils/helpers/llms/platforms/open_ai/API__LLM__Open_AI.py,sha256=Yyy2ZnIS6CfxXepP9pZNsOYx02d-5EnK1IFeFf8myyk,2148
|
223
223
|
osbot_utils/helpers/llms/platforms/open_ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
224
|
-
osbot_utils/helpers/llms/schemas/Safe_Str__LLM__Model_Name.py,sha256=DzQmAe_8IEDKYjUAAbzRYx23g_wGqgd9bT5zc0FBrr8,371
|
225
224
|
osbot_utils/helpers/llms/schemas/Schema__LLM_Cache__Index.py,sha256=GNzOvihBlQ9QWWYAF_-70IkWdquGdhm5QyPXZRMWaNQ,848
|
226
225
|
osbot_utils/helpers/llms/schemas/Schema__LLM_Request.py,sha256=UUiqZQ5mj16SPdlzef7_j3myLaKKCZdAUjsWUJnK1Ag,378
|
227
|
-
osbot_utils/helpers/llms/schemas/Schema__LLM_Request__Data.py,sha256=
|
226
|
+
osbot_utils/helpers/llms/schemas/Schema__LLM_Request__Data.py,sha256=JF-anC4Hd1Jn_F1MOubDxW9WmAaHKWn1yBPzY1n5-vw,1514
|
228
227
|
osbot_utils/helpers/llms/schemas/Schema__LLM_Request__Function_Call.py,sha256=VJgWi4aK-DJmuJvfY2qZUZuLkrLlmu5lgyzxZrrp3hM,440
|
229
228
|
osbot_utils/helpers/llms/schemas/Schema__LLM_Request__Message__Content.py,sha256=nl-16yz4G_72ViACKE9CvGStrKxw2Gm_JcaU8wVcJXI,521
|
230
229
|
osbot_utils/helpers/llms/schemas/Schema__LLM_Request__Message__Role.py,sha256=T99w0cRrDPXQqPT-Nw7_14tMr4vKpUlhw74UJZL6w6w,168
|
@@ -349,7 +348,7 @@ osbot_utils/testing/performance/models/Model__Performance_Measure__Result.py,sha
|
|
349
348
|
osbot_utils/testing/performance/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
350
349
|
osbot_utils/testing/test_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
351
350
|
osbot_utils/testing/test_data/const__test__data__html.py,sha256=_DmA7OoCwvl1xxxn2aS8mfvf3Ct4bOt1KTUyTDqtwaQ,1718
|
352
|
-
osbot_utils/type_safe/Type_Safe.py,sha256=
|
351
|
+
osbot_utils/type_safe/Type_Safe.py,sha256=2rlOJuB0fNiiefKqIKUw34vs1hGWms-Ah_SaIg7tj28,6427
|
353
352
|
osbot_utils/type_safe/Type_Safe__Base.py,sha256=cui8fIzUGaPsb-fnANj8nw9cYrVikdx1XZ8in3Y_-QU,9174
|
354
353
|
osbot_utils/type_safe/Type_Safe__Primitive.py,sha256=Eufm1CSenInqW8gAgULhUAXV_lMmA4UY4A5U9v8qmnU,4135
|
355
354
|
osbot_utils/type_safe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -363,7 +362,7 @@ osbot_utils/type_safe/primitives/safe_int/Safe_Int.py,sha256=IB_ZVtuQlAfRWZH1teZ
|
|
363
362
|
osbot_utils/type_safe/primitives/safe_int/Timestamp_Now.py,sha256=OZwSwmYA1pZAnVglpx2lBL5t8Pu_HxzmYdNEJnmTqKI,536
|
364
363
|
osbot_utils/type_safe/primitives/safe_int/__init__.py,sha256=Prle-pyYi8l4hjbzGACVxX89Uc5aAhYjGRojywWysQM,323
|
365
364
|
osbot_utils/type_safe/primitives/safe_str/Enum__Safe_Str__Regex_Mode.py,sha256=15y_afYIf_LsweutaVVdIJ0qClbVITJGWNEqfRKapNI,120
|
366
|
-
osbot_utils/type_safe/primitives/safe_str/Safe_Str.py,sha256=
|
365
|
+
osbot_utils/type_safe/primitives/safe_str/Safe_Str.py,sha256=9Gb6TyXySuN1OI1wFYwEOJUASDniWrvgEE7PBYteZRs,5225
|
367
366
|
osbot_utils/type_safe/primitives/safe_str/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
368
367
|
osbot_utils/type_safe/primitives/safe_str/cryptography/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
369
368
|
osbot_utils/type_safe/primitives/safe_str/cryptography/hashes/Safe_Str__Hash.py,sha256=zmARKnR6k0d7zg2DESPSZU8Qj91nx-qrnNrXln6UcYk,1287
|
@@ -397,12 +396,30 @@ osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid.py,sha256=86xn
|
|
397
396
|
osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid_Short.py,sha256=cXye_Bo5cco24FOyXwyN0qotXHc-X4-eQ-ZgOaQrocE,496
|
398
397
|
osbot_utils/type_safe/primitives/safe_str/identifiers/Safe_Id.py,sha256=Mj66QVcEHqUKDFb0cdl7cbMOlQKxfFuRxnupmKo6UG8,696
|
399
398
|
osbot_utils/type_safe/primitives/safe_str/identifiers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
399
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Enum__LLM__Role.py,sha256=NnuPmct-FPwzfGRw507aIarOQXUNoigJE2_E0x7etTw,277
|
400
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Description.py,sha256=IuSnjJv0KFWcvTcNmEqu47QJeYgidNvXwiDamnB0cz8,662
|
401
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__Assistant.py,sha256=4SVKHE8oiY_GQtlFcoDqv3z-Y_9Xp5bc9DRNIadTD7Q,374
|
402
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__System.py,sha256=AGessh1EtfwodQYldHKsBz8hU-719SU38oIdag9omJo,393
|
403
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__Tool.py,sha256=evu0is9UG6AZSnUXUGJOq44kq5NqGoq1nqC1nreGjvo,374
|
404
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Message__User.py,sha256=ciioB8_vfK4dd9YDb8eP5VZC4fb0sm_sETjdzP3ZcWU,363
|
405
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Modality.py,sha256=87x4TXMBllICeEDWZ1c7iT80wcqRZ8xe7w-b6eHtJi8,503
|
406
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Model_ID.py,sha256=FHpISUMXJL0F2CQfSW-eP9UOcBxzcj8HJcwun-0-1iQ,622
|
407
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Model_Name.py,sha256=N-nsKiqEtg_nYzEu5vxxF6edLwpL2_19hPQk3LoAs3w,524
|
408
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Model_Slug.py,sha256=XWJdStnMeTZbds4quKjMFQYR8EqUlNKYuuJZk4GKzQw,458
|
409
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Prompt.py,sha256=YY5kXc0OrNGOyPssiUDcPagLSa0yhCUBmYOydqI5ELU,351
|
410
|
+
osbot_utils/type_safe/primitives/safe_str/llm/Safe_Str__LLM__Tokenizer.py,sha256=L34FBL49xC5RCyirlpzPBCaARWlwK6VguDM9-m9kLmA,467
|
411
|
+
osbot_utils/type_safe/primitives/safe_str/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
412
|
+
osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Code__Snippet.py,sha256=hhdAkOqgaGA8NmuOXXOOm8jWnIQmh_aTNRFecdvrDbc,350
|
400
413
|
osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Text.py,sha256=95E4ALhah2AEfL-m5JB7XpUOkyxQ0lJQM139RPQJjv4,327
|
401
414
|
osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Text__Dangerous.py,sha256=WrEvoXeHWuevzgbfUkm2xisGUMIlDS39Nte3P2_hyHg,401
|
402
415
|
osbot_utils/type_safe/primitives/safe_str/text/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
416
|
+
osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__API__Parameter.py,sha256=ZI9kw3N2JQaCXBs2SbKwBN6hF0LB8gCErlOS7wylIZE,455
|
417
|
+
osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Email.py,sha256=FXydnlrbJSaZKl_dgN32en2cchgWjG-tVTQ7HgsUcEs,560
|
403
418
|
osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Html.py,sha256=HnCnKUBPB0IfEXSoeK4XFB08qjnAaOYyd-s1smvI2pQ,675
|
404
419
|
osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__IP_Address.py,sha256=wOcEt0adsE6-CX08erlRYyGyOLoe4QRaAYdI6sKyKlM,1672
|
420
|
+
osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Password.py,sha256=cV6wyO_sGTp9pyXDttmzTaInrC8jBeBXqik4P14t82w,489
|
405
421
|
osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Url.py,sha256=9xVINemoNS2LtXshAZdhEzKHyneB7Ml4AELqFHJfWWw,562
|
422
|
+
osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Username.py,sha256=aMhYz8sCQNUtti4wM4sZRyVSRB2IwD1BVDEUeGp59hE,260
|
406
423
|
osbot_utils/type_safe/primitives/safe_str/web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
407
424
|
osbot_utils/type_safe/primitives/safe_uint/Safe_UInt.py,sha256=8cCS9wI0w1w5YuWIhrVHJKzczHiK3cw_dnXhMgnQAto,331
|
408
425
|
osbot_utils/type_safe/primitives/safe_uint/Safe_UInt__Byte.py,sha256=yRYzj42EpuLU46l-azYEeszbUBdfgnA_Pb6m_41D7Us,342
|
@@ -427,16 +444,16 @@ osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Convert.py,sha256=g2lo_11
|
|
427
444
|
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Json_Compressor.py,sha256=L5EiMPP-7vvzesW-Zs1YRPv1C544NiMTMag2saUnPrc,5522
|
428
445
|
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Json_Compressor__Type_Registry.py,sha256=wYOCg7F1nTrRn8HlnZvrs_8A8WL4gxRYRLnXZpGIiuk,1119
|
429
446
|
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Not_Cached.py,sha256=25FAl6SOLxdStco_rm9tgOYLfuKyBWheGdl7vVa56UU,800
|
430
|
-
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Raise_Exception.py,sha256=
|
447
|
+
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Raise_Exception.py,sha256=UCLEJpJPL4wnuX6f7YxawqArMtfWdLfuhFMfB7Z0yq4,1355
|
431
448
|
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Shared__Variables.py,sha256=SuZGl9LryQX6IpOE0I_lbzClT-h17UNylC__-M8ltTY,129
|
432
|
-
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Validation.py,sha256=
|
449
|
+
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Validation.py,sha256=tAH09G0b-xN3J2yNOcvHR03viM8zlMRBuuLQx3JY_yw,21249
|
433
450
|
osbot_utils/type_safe/type_safe_core/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
434
|
-
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Class_Kwargs.py,sha256=
|
451
|
+
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Class_Kwargs.py,sha256=t3hsy_Q0eS_9hYsEd1_bhVvSybwcq26DKcjK8_11P9Q,8247
|
435
452
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Default_Kwargs.py,sha256=tzKXDUc0HVP5QvCWsmcPuuZodNvQZ9FeMDNI2x00Ngw,1943
|
436
453
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Default_Value.py,sha256=mRu0yV3w7Ch1H8SOfXMRqMBp3ooY95yR_oni7JafJBc,4603
|
437
454
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__From_Json.py,sha256=QDVf-cN7aK8_xYdkHS74seSrMYyhurd_MEzgTlUyStg,15712
|
438
|
-
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Init.py,sha256=
|
439
|
-
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Set_Attr.py,sha256=
|
455
|
+
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Init.py,sha256=Dcs382ZqJ1ycuBYO_1LU2TaadQsUZ_MBihAKdM7PxDk,5230
|
456
|
+
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Set_Attr.py,sha256=OLAzZ6FUfTYk4tqIRe_JGvBR_WZqPZFqM2aD_AMKb0c,9320
|
440
457
|
osbot_utils/type_safe/type_safe_core/steps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
441
458
|
osbot_utils/type_safe/validators/Type_Safe__Validator.py,sha256=cJIPSBarjV716SZUOLvz7Mthjk-aUYKUQtRDtKUBmN4,779
|
442
459
|
osbot_utils/type_safe/validators/Validator__Max.py,sha256=pCvYF5Jb_cBgn1ArGhf6FNUB-NGCXPq3D36oYDCyAzg,1275
|
@@ -458,7 +475,7 @@ osbot_utils/utils/Json.py,sha256=TvfDoXwOkWzWH-9KMnme5C7iFsMZOleAeue92qmkH6g,883
|
|
458
475
|
osbot_utils/utils/Json_Cache.py,sha256=mLPkkDZN-3ZVJiDvV1KBJXILtKkTZ4OepzOsDoBPhWg,2006
|
459
476
|
osbot_utils/utils/Lists.py,sha256=tPz5x5s3sRO97WZ_nsxREBPC5cwaHrhgaYBhsrffTT8,5599
|
460
477
|
osbot_utils/utils/Misc.py,sha256=H_xexJgiTxB3jDeDiW8efGQbO0Zuy8MM0iQ7qXC92JI,17363
|
461
|
-
osbot_utils/utils/Objects.py,sha256=
|
478
|
+
osbot_utils/utils/Objects.py,sha256=KjRvw2ElXrmd0Y7xtQ2prFbYGCsKDnMQmEvQ1zoL2tk,15321
|
462
479
|
osbot_utils/utils/Png.py,sha256=V1juGp6wkpPigMJ8HcxrPDIP4bSwu51oNkLI8YqP76Y,1172
|
463
480
|
osbot_utils/utils/Process.py,sha256=lr3CTiEkN3EiBx3ZmzYmTKlQoPdkgZBRjPulMxG-zdo,2357
|
464
481
|
osbot_utils/utils/Python_Logger.py,sha256=M9Oi62LxfnRSlCN8GhaiwiBINvcSdGy39FCWjyDD-Xg,12792
|
@@ -470,8 +487,8 @@ osbot_utils/utils/Toml.py,sha256=grjWkVPIMVkawJ499FVIJKxQp8FJ2wcsd0Z3YIR4drM,114
|
|
470
487
|
osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
|
471
488
|
osbot_utils/utils/Zip.py,sha256=mG42lgTY0tnm14T3P1-DSAIZKkTiYoO3odZ1aOUdc1I,14394
|
472
489
|
osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
473
|
-
osbot_utils/version,sha256=
|
474
|
-
osbot_utils-2.
|
475
|
-
osbot_utils-2.
|
476
|
-
osbot_utils-2.
|
477
|
-
osbot_utils-2.
|
490
|
+
osbot_utils/version,sha256=OKa3BNcbPy8l886C7z7_sfvcKm8rLoKGNBQkfm9o2kQ,8
|
491
|
+
osbot_utils-2.89.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
492
|
+
osbot_utils-2.89.0.dist-info/METADATA,sha256=bgQC3MRSIKAxl6qSFBZc8Jco5LJBcVkxCi0tap8h0lk,7918
|
493
|
+
osbot_utils-2.89.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
494
|
+
osbot_utils-2.89.0.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import re
|
2
|
-
|
3
|
-
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
|
4
|
-
|
5
|
-
TYPE_SAFE_STR__LLM__MODEL_NAME__MAX_LENGTH = 256
|
6
|
-
TYPE_SAFE_STR__LLM__MODEL_NAME__REGEX = r'[^a-zA-Z0-9/_\-.:]'
|
7
|
-
|
8
|
-
class Safe_Str__LLM__Model_Name(Safe_Str):
|
9
|
-
regex = re.compile(TYPE_SAFE_STR__LLM__MODEL_NAME__REGEX)
|
10
|
-
max_length = TYPE_SAFE_STR__LLM__MODEL_NAME__MAX_LENGTH
|
File without changes
|
File without changes
|