osbot-utils 2.45.0__py3-none-any.whl → 2.47.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/llms/actions/LLM_Request__Execute.py +2 -1
- osbot_utils/utils/Threads.py +9 -9
- osbot_utils/version +1 -1
- {osbot_utils-2.45.0.dist-info → osbot_utils-2.47.0.dist-info}/METADATA +2 -2
- {osbot_utils-2.45.0.dist-info → osbot_utils-2.47.0.dist-info}/RECORD +7 -7
- {osbot_utils-2.45.0.dist-info → osbot_utils-2.47.0.dist-info}/LICENSE +0 -0
- {osbot_utils-2.45.0.dist-info → osbot_utils-2.47.0.dist-info}/WHEEL +0 -0
@@ -11,12 +11,13 @@ class LLM_Request__Execute(Type_Safe):
|
|
11
11
|
llm_cache : LLM_Request__Cache
|
12
12
|
llm_api : API__LLM__Open_AI
|
13
13
|
use_cache : bool = True
|
14
|
+
refresh_cache : bool = False
|
14
15
|
request_builder: LLM_Request__Builder # todo: fix the use of LLM_Request__Builder since it not good when we when overwrite it at self.request_builder.llm_request_data = llm_request.request_data
|
15
16
|
|
16
17
|
@type_safe
|
17
18
|
def execute(self, llm_request: Schema__LLM_Request) -> Schema__LLM_Response:
|
18
19
|
|
19
|
-
if self.use_cache: # Check cache if enabled
|
20
|
+
if self.use_cache is True and self.refresh_cache is False: # Check cache if enabled
|
20
21
|
cached_response = self.llm_cache.get(llm_request)
|
21
22
|
if cached_response:
|
22
23
|
return cached_response
|
osbot_utils/utils/Threads.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import asyncio
|
2
2
|
import logging
|
3
3
|
import typing
|
4
|
-
from concurrent.futures import ThreadPoolExecutor
|
5
4
|
|
6
5
|
def invoke_async_function(target: typing.Coroutine):
|
7
6
|
"""Run an asynchronous coroutine in a new event loop."""
|
@@ -43,23 +42,24 @@ def invoke_in_new_event_loop(target: typing.Coroutine): # Runs a cor
|
|
43
42
|
return result # Return the result from the coroutine
|
44
43
|
|
45
44
|
from concurrent.futures import ThreadPoolExecutor
|
46
|
-
from typing import Callable, List, TypeVar,
|
45
|
+
from typing import Callable, List, TypeVar, Tuple, Optional, Dict
|
47
46
|
|
48
47
|
T = TypeVar('T') # Type of items in the list
|
49
48
|
R = TypeVar('R') # Return type of the function
|
50
49
|
|
51
|
-
def execute_in_thread_pool(target_function
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
) -> List[R]: # List of results
|
50
|
+
def execute_in_thread_pool(target_function : Callable ,
|
51
|
+
calls : List[Tuple[Tuple, Dict]] , # List of (args, kwargs) pairs
|
52
|
+
max_workers : Optional[int] = None ,
|
53
|
+
return_exceptions : bool = False ):
|
56
54
|
"""Execute a function for each item in parallel using ThreadPoolExecutor."""
|
57
55
|
|
58
|
-
args_list = [(item,) for item in items] # Convert list of items to list of single-item tuples (so that we support one or more params)
|
59
56
|
results = []
|
60
57
|
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
61
58
|
|
62
|
-
futures = [
|
59
|
+
futures = []
|
60
|
+
for args, kwargs in calls:
|
61
|
+
future = executor.submit(target_function, *args, **kwargs)
|
62
|
+
futures.append(future) # Submit all tasks to the executor
|
63
63
|
|
64
64
|
for future in futures: # Wait for all to complete and collect results
|
65
65
|
try:
|
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v2.
|
1
|
+
v2.47.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.47.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
|
-

|
27
27
|
[](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
|
28
28
|
|
29
29
|
|
@@ -190,7 +190,7 @@ osbot_utils/helpers/html/Tag__Link.py,sha256=rQ-gZN8EkSv5x1S-smdjvFflwMQHACHQXiO
|
|
190
190
|
osbot_utils/helpers/html/Tag__Style.py,sha256=LPPlIN7GyMvfCUlbs2eXVMUr9jS0PX5M94A5Ig_jXIs,846
|
191
191
|
osbot_utils/helpers/html/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
192
192
|
osbot_utils/helpers/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
193
|
-
osbot_utils/helpers/llms/actions/LLM_Request__Execute.py,sha256=
|
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
196
|
osbot_utils/helpers/llms/builders/LLM_Request__Builder.py,sha256=c8MN66ijFn9DugbBIGmG0bm9ujS-0kvZDGqJcZsHHYc,3385
|
@@ -393,13 +393,13 @@ osbot_utils/utils/Python_Logger.py,sha256=M9Oi62LxfnRSlCN8GhaiwiBINvcSdGy39FCWjy
|
|
393
393
|
osbot_utils/utils/Regex.py,sha256=MtHhk69ax7Nwu4CQZK7y4KXHZ6VREwEpIchuioB168c,960
|
394
394
|
osbot_utils/utils/Status.py,sha256=OjqLwUhHqY-j-JeRN-hIaVZQHPRdyjR7y6i6ujsB-Yc,4287
|
395
395
|
osbot_utils/utils/Str.py,sha256=KQVfh0o3BxJKVm24yhAhgIGH5QYfzpP1G-siVv2zQws,3301
|
396
|
-
osbot_utils/utils/Threads.py,sha256=
|
396
|
+
osbot_utils/utils/Threads.py,sha256=YI1T382AtJpHVsa-BK7SycmEYhnkqHIiYyK_5HSmUtw,4329
|
397
397
|
osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,1667
|
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=
|
402
|
-
osbot_utils-2.
|
403
|
-
osbot_utils-2.
|
404
|
-
osbot_utils-2.
|
405
|
-
osbot_utils-2.
|
401
|
+
osbot_utils/version,sha256=VUVdtUFseZ7HzNCctyr2Ez359azS56ZPJKdFMjrPp-M,8
|
402
|
+
osbot_utils-2.47.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
403
|
+
osbot_utils-2.47.0.dist-info/METADATA,sha256=5KF73_BrMFh-C1kmro20TRrSxye5pMS4WUOHM9VtN7k,1329
|
404
|
+
osbot_utils-2.47.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
405
|
+
osbot_utils-2.47.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|