AbstractIntegratedModule 0.2.2__tar.gz → 0.2.3__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.
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/AbstractIntegratedModule.egg-info/PKG-INFO +29 -19
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/AbstractIntegratedModule.py +136 -90
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/PKG-INFO +29 -19
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/README.md +28 -18
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/setup.py +1 -1
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/pyproject.toml +0 -0
- {abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AbstractIntegratedModule
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Framework forAdvanced Integrated Non-LLM AI Module library - Backend Framework for Non-LLM AI Agent Framework
|
|
5
5
|
Author: Micro-Novelty
|
|
6
6
|
Author-email: hernikpuspita5@gmail.com
|
|
@@ -40,11 +40,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
40
40
|
#### Note: The README here you are reading is a direct copy from my README Repository, to download the necessary files, you can visit my Repository with the provided link above.
|
|
41
41
|
|
|
42
42
|
### Library Short Description:
|
|
43
|
-
- Development Stage: Beta, 0.2.
|
|
43
|
+
- Development Stage: Beta, 0.2.3.
|
|
44
44
|
- Maintainer: Micro-Novelty.
|
|
45
45
|
- library Source-Code is Open-sourced on github.
|
|
46
46
|
- Purpose: Specifically Designed for providing Non-LLM AI Agent Framework for edge Devices, Optimized for ARM64 architecture.
|
|
47
|
-
|
|
47
|
+
- Proven Capabilities: Works on ARM64 Environment, Training and Prediction works efficient on Docker ARM64 environment with QEMU, good parallelizing behavior is guaranteed.
|
|
48
48
|
|
|
49
49
|
<img width="1280" height="600" alt="WhatsApp Image 2026-05-27 at 07 16 32" src="https://github.com/user-attachments/assets/4b58a556-45a3-419b-96fd-9c1b76cac574" />
|
|
50
50
|
|
|
@@ -482,8 +482,16 @@ B. [=] Advanced Prediction without Transformer, Only Specialized MLP using AWE.
|
|
|
482
482
|
import numpy as np
|
|
483
483
|
|
|
484
484
|
memory_name = 'agent_memory'
|
|
485
|
-
main_model = IntegratedPipeline(
|
|
486
|
-
|
|
485
|
+
main_model = IntegratedPipeline(
|
|
486
|
+
memory_name=memory_name, use_async=True,
|
|
487
|
+
agent_port=5001, # this port is used to set AgentDistributedInference server.
|
|
488
|
+
singleton_permitted=False, # set IntegratedPipeline to singleton if you don't use it for P2P, False if you use P2P.
|
|
489
|
+
ssl_cert_file=cert_file, ssl_key_file=key_file) # provide your cert_file path or key_file path (optional)
|
|
490
|
+
|
|
491
|
+
main_prediction = PipelinePredictionManager(
|
|
492
|
+
main_model, label_csv='example_manual_training.txt',
|
|
493
|
+
target_title='window_title', label='label')
|
|
494
|
+
|
|
487
495
|
# example_manual_training is a .txt file that contain csv format like above example.
|
|
488
496
|
|
|
489
497
|
|
|
@@ -616,6 +624,7 @@ predicted_output = async_manager.advanced_batch_prediction(test_titles, label_ma
|
|
|
616
624
|
- To Make the Agent cooperate with other peers, consider using this setup:
|
|
617
625
|
- [=] for ensemble prediction from multiple peers, exchanging predicted label with each other, consider using this setup:
|
|
618
626
|
```python
|
|
627
|
+
|
|
619
628
|
# step 3
|
|
620
629
|
from AbstractIntegratedModule import CohesiveAgentDeployment
|
|
621
630
|
from AbstractIntegratedModule import PipelinePredictionManager
|
|
@@ -634,23 +643,25 @@ main_model.distribution.enable_ssl = False # set to false if you dont have SSL k
|
|
|
634
643
|
|
|
635
644
|
# Agent 1 - Primary (Port 5555)
|
|
636
645
|
agent1 = CohesiveAgentDeployment(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
646
|
+
pipeline=main_model, # main_model is your initialized integrated pipeline
|
|
647
|
+
memory_name="agent_primary", # any name you want for the agent.
|
|
648
|
+
filename=<filename>, # name of your .txt file that contains the CSV format and training labels
|
|
649
|
+
target_title=<title_name>,
|
|
640
650
|
label_name=<label_name>,
|
|
641
|
-
security_level="PRODUCTION",
|
|
642
|
-
enable_peers=True,
|
|
651
|
+
security_level="PRODUCTION", # production level security
|
|
652
|
+
enable_peers=True, # allow peer discovery
|
|
643
653
|
trusted_networks=['127.0.0.1/32', '192.168.1.0/24'], # for trusted networks, you need to provide the list of IPs of your peers.
|
|
644
654
|
peer_discovery_port=5555, # peer port to start P2P
|
|
645
|
-
secret_key=secret_key,
|
|
655
|
+
secret_key=secret_key, # your secret key
|
|
646
656
|
shared_auth_token=secret_key, # your previous initialized secret_key
|
|
647
|
-
predict_manager=prediction_manager,
|
|
657
|
+
predict_manager=prediction_manager, # your prediction manager
|
|
648
658
|
peer_config = <'your_peer_ip_lists.json'> # you need to create .json file that contains your peer IP and Port lists
|
|
649
659
|
consecutive_peer_config = <'your_second_fallback_peer_ip_lists.json'> # same for this one too, but for fallback.
|
|
650
|
-
|
|
660
|
+
)
|
|
651
661
|
|
|
652
662
|
# Agent 2 - Secondary (Port 5556)
|
|
653
663
|
agent2 = CohesiveAgentDeployment(
|
|
664
|
+
pipeline=main_model,
|
|
654
665
|
memory_name="agent_secondary",
|
|
655
666
|
filename=<filename>,
|
|
656
667
|
target_title=<title_name>,
|
|
@@ -664,21 +675,20 @@ agent2 = CohesiveAgentDeployment(
|
|
|
664
675
|
predict_manager=prediction_manager,
|
|
665
676
|
peer_config = <'your_peer_ip_lists.json'> # you need to create .json file that contains your peer IP and Port lists
|
|
666
677
|
consecutive_peer_config = <'your_second_fallback_peer_ip_lists.json'> # same for this one too, but for fallback.
|
|
667
|
-
|
|
678
|
+
)
|
|
668
679
|
|
|
669
680
|
# Note: CohesiveAgentDeployment contains ConsecutivePeerAgent that can start a server once ensemble prediction from peer is started
|
|
670
681
|
# be advised to stop the server too before shutdown-ing CohesiveAgentDeployment cluster
|
|
671
682
|
|
|
672
683
|
# example peer_Ip_lists_config.json (de-comment to use)
|
|
673
684
|
# {
|
|
674
|
-
#
|
|
685
|
+
# you must put "known_peers" in the config so python can identify the list of IPs and Ports
|
|
686
|
+
# "known_peers": [
|
|
675
687
|
# ["127.0.0.1", 5555], can be modified using real IP or local IP.
|
|
676
688
|
# ["127.0.0.1", 5556]
|
|
677
689
|
# ]
|
|
678
690
|
# }
|
|
679
691
|
|
|
680
|
-
agent1.pipeline = main_model # overrides agent1 baseline pipeline with your original initialized pipelinej
|
|
681
|
-
agent2.pipeline = main_model
|
|
682
692
|
|
|
683
693
|
try:
|
|
684
694
|
# Start both agents
|
|
@@ -699,8 +709,8 @@ try:
|
|
|
699
709
|
|
|
700
710
|
texts = {"test_titles": test_titles, "label_map": label_map, "rules": rules, "use_transformer": True, "agent_id": agent_id}
|
|
701
711
|
|
|
702
|
-
# texts
|
|
703
|
-
# agent ID can be strings, int, or floats,
|
|
712
|
+
# texts dictionary must contain test_titles, label_map, and rules that you can assign,
|
|
713
|
+
# agent ID can be strings, int, or floats, recommendded to make it long for better security.
|
|
704
714
|
|
|
705
715
|
# Make prediction with peer ensemble
|
|
706
716
|
# Connection will be guaranteed successfull during discovery.
|
{abstractintegratedmodule-0.2.2 → abstractintegratedmodule-0.2.3}/AbstractIntegratedModule.py
RENAMED
|
@@ -2290,18 +2290,25 @@ class ExplainabilityModule:
|
|
|
2290
2290
|
if isinstance(mlp_conf, np.ndarray):
|
|
2291
2291
|
mlp_conf = np.clip(np.mean(mlp_conf), 0, 1)
|
|
2292
2292
|
if isinstance(trans_conf, np.ndarray):
|
|
2293
|
-
|
|
2293
|
+
trans_conf = np.clip(np.mean(trans_conf), 0, 1)
|
|
2294
2294
|
|
|
2295
2295
|
if mlp_pred == trans_pred:
|
|
2296
2296
|
final_pred = mlp_pred
|
|
2297
2297
|
final_conf = max(mlp_conf, trans_conf)
|
|
2298
2298
|
else:
|
|
2299
|
-
|
|
2300
|
-
|
|
2299
|
+
sliced_attention_weight = attn_weights[0]
|
|
2300
|
+
if isinstance(sliced_attention_weight, np.ndarray):
|
|
2301
|
+
sliced_attention_weight = sliced_attention_weight[:, 0]
|
|
2302
|
+
sliced_attention_weight = sliced_attention_weight[0]
|
|
2303
|
+
|
|
2304
|
+
sliced_anisotropy = self.pipeline.anisotropy_measurement(sliced_attention_weight)
|
|
2305
|
+
sigmoid_growth = 1.0 / (1.0 + np.exp(-sliced_attention_weight))
|
|
2301
2306
|
attn_quality = self._compute_attention_quality(attn_weights)
|
|
2302
2307
|
|
|
2303
|
-
#
|
|
2304
|
-
AAT =
|
|
2308
|
+
# Abstract attention transformation
|
|
2309
|
+
AAT = sigmoid_growth * (1.0 - sliced_anisotropy) + eps
|
|
2310
|
+
# lower AAT means transformer is less reliable because abstraction is underserved/nonoptimal in this env.
|
|
2311
|
+
# Higher AAT means transformer is more focused and reliable and is near optimal.
|
|
2305
2312
|
|
|
2306
2313
|
if mlp_conf > trans_conf:
|
|
2307
2314
|
final_pred = mlp_pred
|
|
@@ -2310,6 +2317,15 @@ class ExplainabilityModule:
|
|
|
2310
2317
|
final_pred = trans_pred
|
|
2311
2318
|
final_conf = trans_conf * (1.0 - mlp_conf) * AAT + eps
|
|
2312
2319
|
|
|
2320
|
+
print(f'[= ABSTRACTION =] Consistency of abstraction transformation: {np.std(AAT)}')
|
|
2321
|
+
if isinstance(final_conf, np.ndarray):
|
|
2322
|
+
final_conf = 1.0 / (1.0 + np.std(final_conf))
|
|
2323
|
+
# growth deviation of arrayed final confidence helped to distinguish noise from unnecessary distribution,
|
|
2324
|
+
# with real covariance of distribution from the data.
|
|
2325
|
+
|
|
2326
|
+
if np.isnan(final_conf).any() or np.isinf(final_conf).any():
|
|
2327
|
+
final_conf = self.pipeline.confidence_threshold
|
|
2328
|
+
|
|
2313
2329
|
return final_pred, final_conf
|
|
2314
2330
|
|
|
2315
2331
|
def _get_attention_focus(self, attn_weights, text):
|
|
@@ -3875,26 +3891,6 @@ class ThreadedMessageQueue:
|
|
|
3875
3891
|
# while also providing security features like authentication, rate limiting, and message validation.
|
|
3876
3892
|
class AgentDistributedInference:
|
|
3877
3893
|
def __init__(self, pipeline, storage, memory_name, port=5555, use_async=False, secret_key=None, ssl_cert_file=None, ssl_key_file=None, shared_auth_token=None, predict_manager=None):
|
|
3878
|
-
super().__init__()
|
|
3879
|
-
|
|
3880
|
-
# Only initialized once
|
|
3881
|
-
if hasattr(self, '_singleton_initialized'):
|
|
3882
|
-
print(f"[===] AgentDistributedInference already initialized, reusing...")
|
|
3883
|
-
return
|
|
3884
|
-
|
|
3885
|
-
self._singleton_initialized = True
|
|
3886
|
-
|
|
3887
|
-
# Stored initialization params for debugging later
|
|
3888
|
-
self._init_params = {
|
|
3889
|
-
'memory_name': memory_name,
|
|
3890
|
-
'port': port,
|
|
3891
|
-
'use_async': use_async,
|
|
3892
|
-
'secret_key': secret_key,
|
|
3893
|
-
'ssl_cert_file': ssl_cert_file,
|
|
3894
|
-
'ssl_key_file': ssl_key_file,
|
|
3895
|
-
'shared_auth_token': shared_auth_token
|
|
3896
|
-
}
|
|
3897
|
-
|
|
3898
3894
|
self.pipeline = pipeline
|
|
3899
3895
|
self.memory_name = memory_name
|
|
3900
3896
|
self.port = port
|
|
@@ -5240,7 +5236,9 @@ class AgentDistributedInference:
|
|
|
5240
5236
|
|
|
5241
5237
|
|
|
5242
5238
|
def _calibrate_peer_probs(self, probs, target_preds, self_attn_weights, attn_weights, input_ids, AEL):
|
|
5239
|
+
eps = 1e-5
|
|
5243
5240
|
calibrated = probs.copy()
|
|
5241
|
+
|
|
5244
5242
|
try:
|
|
5245
5243
|
n_classes = probs.shape[1]
|
|
5246
5244
|
except:
|
|
@@ -5248,11 +5246,25 @@ class AgentDistributedInference:
|
|
|
5248
5246
|
|
|
5249
5247
|
batch_size = len(target_preds)
|
|
5250
5248
|
anisotropy = self.pipeline.anisotropy_measurement(attn_weights)
|
|
5251
|
-
|
|
5252
|
-
|
|
5249
|
+
|
|
5250
|
+
if isinstance(attn_weights, (str, np.str_)):
|
|
5251
|
+
clean_str = str(attn_weights).replace('[', '').replace(']', '')
|
|
5252
|
+
attn_weights = np.fromstring(clean_str, sep=' ')
|
|
5253
|
+
elif isinstance(attn_weights, np.ndarray) and np.issubdtype(attn_weights.dtype, np.character):
|
|
5254
|
+
# catches arrays filled with string text
|
|
5255
|
+
clean_str = ' '.join(attn_weights.astype(str).flatten()).replace('[', '').replace(']', '')
|
|
5256
|
+
attn_weights = np.fromstring(clean_str, sep=' ')
|
|
5257
|
+
else:
|
|
5258
|
+
# Ensure standard float array if it was integers or objects
|
|
5259
|
+
attn_weights = np.asarray(attn_weights, dtype=float)
|
|
5260
|
+
|
|
5261
|
+
target_preds = np.asarray(target_preds, dtype=np.float32)
|
|
5262
|
+
|
|
5253
5263
|
for i in range(batch_size):
|
|
5254
|
-
|
|
5255
|
-
|
|
5264
|
+
|
|
5265
|
+
mlp_target = target_preds[i] if target_preds.ndim > 1 and target_preds.shape[0] > i else target_preds
|
|
5266
|
+
attn_target = attn_weights[i] if attn_weights.ndim > 1 and attn_weights.shape[0] > i else attn_weights
|
|
5267
|
+
|
|
5256
5268
|
if self_attn_weights is not None and i < len(attn_weights):
|
|
5257
5269
|
attn = self_attn_weights[i]
|
|
5258
5270
|
|
|
@@ -5299,7 +5311,21 @@ class AgentDistributedInference:
|
|
|
5299
5311
|
def handle_peer_uncertainty(self, probs, target_preds, self_attn_weights, attn_weights, input_ids):
|
|
5300
5312
|
try:
|
|
5301
5313
|
if self_attn_weights is None:
|
|
5302
|
-
_, _, self_attn_weights = self.pipeline.model2.predict(input_ids)
|
|
5314
|
+
_, _, self_attn_weights = self.pipeline.model2.predict(input_ids)
|
|
5315
|
+
|
|
5316
|
+
|
|
5317
|
+
if isinstance(attn_weights, tuple):
|
|
5318
|
+
attn_weights = attn_weights[0]
|
|
5319
|
+
if isinstance(self_attn_weights, tuple):
|
|
5320
|
+
self_attn_weights = self_attn_weights[0]
|
|
5321
|
+
|
|
5322
|
+
if isinstance(self_attn_weights, str):
|
|
5323
|
+
self_attn_weights = np.array(self_attn_weights)
|
|
5324
|
+
self_attn_weights = self_attn_weights[0]
|
|
5325
|
+
|
|
5326
|
+
if isinstance(attn_weights, str):
|
|
5327
|
+
attn_weights = np.array(attn_weights)
|
|
5328
|
+
|
|
5303
5329
|
batch_similarity = self.pipeline.cosine_similarity(attn_weights, self_attn_weights)
|
|
5304
5330
|
|
|
5305
5331
|
anisotropy = self.pipeline.anisotropy_measurement(attn_weights)
|
|
@@ -5317,7 +5343,8 @@ class AgentDistributedInference:
|
|
|
5317
5343
|
return calibrated
|
|
5318
5344
|
|
|
5319
5345
|
except Exception as e:
|
|
5320
|
-
print(f"[
|
|
5346
|
+
print(f"[= =] Error in uncertainty handling: {e}")
|
|
5347
|
+
traceback.print_exc()
|
|
5321
5348
|
return probs
|
|
5322
5349
|
|
|
5323
5350
|
|
|
@@ -5969,24 +5996,33 @@ class AutoBatcherAutomation:
|
|
|
5969
5996
|
# The IntegratedPipeline class serves as the central component that integrates all the different modules and functionalities of the system.
|
|
5970
5997
|
# It manages the overall workflow, including data processing, model training, prediction, memory management, and interactions with other agents.
|
|
5971
5998
|
class IntegratedPipeline:
|
|
5972
|
-
def __init__(self, memory_name, use_async, agent_port=None, ssl_cert_file=None, ssl_key_file=None, secret_key=None, shared_auth_token=None, predict_manager=None):
|
|
5973
|
-
|
|
5999
|
+
def __init__(self, memory_name='agent_memory', use_async=False, agent_port=None, singleton_permitted=False, ssl_cert_file=None, ssl_key_file=None, secret_key=None, shared_auth_token=None, predict_manager=None):
|
|
6000
|
+
# Only initialized once and when allowed
|
|
6001
|
+
|
|
6002
|
+
print('[= MEMORY =] Initializing IntegratedPipeline with memory name:', memory_name)
|
|
5974
6003
|
|
|
5975
6004
|
if hasattr(self, '_singleton_initialized'):
|
|
5976
|
-
print(
|
|
6005
|
+
print("[=] IntegratedPipeline instance already initialized, skipping __init__")
|
|
5977
6006
|
return
|
|
5978
|
-
|
|
5979
|
-
self.
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
6007
|
+
|
|
6008
|
+
self.singleton_permitted = singleton_permitted
|
|
6009
|
+
|
|
6010
|
+
if self.singleton_permitted:
|
|
6011
|
+
super().__init__()
|
|
6012
|
+
|
|
6013
|
+
print("[= SINGLETON =] IntegratedPipeline singleton instance created")
|
|
6014
|
+
self._singleton_initialized = True
|
|
6015
|
+
|
|
6016
|
+
# Stored initialization params for debugging later
|
|
6017
|
+
self._init_params = {
|
|
6018
|
+
'memory_name': memory_name,
|
|
6019
|
+
'port': agent_port,
|
|
6020
|
+
'use_async': use_async,
|
|
6021
|
+
'secret_key': secret_key,
|
|
6022
|
+
'ssl_cert_file': ssl_cert_file,
|
|
6023
|
+
'ssl_key_file': ssl_key_file,
|
|
6024
|
+
'shared_auth_token': shared_auth_token
|
|
6025
|
+
}
|
|
5990
6026
|
|
|
5991
6027
|
self.ssl_cert_file = ssl_cert_file
|
|
5992
6028
|
self.ssl_key_file = ssl_key_file
|
|
@@ -6004,10 +6040,12 @@ class IntegratedPipeline:
|
|
|
6004
6040
|
self.batcher = AutoBatcherAutomation(self)
|
|
6005
6041
|
self.query_node = QueryNode(self, memory_name, self.storage)
|
|
6006
6042
|
|
|
6007
|
-
self._agent_mode =
|
|
6008
|
-
self._agent_port = int(
|
|
6009
|
-
self._use_async =
|
|
6010
|
-
|
|
6043
|
+
self._agent_mode = 'single'
|
|
6044
|
+
self._agent_port = int(agent_port) if int(agent_port) is not None else 5000
|
|
6045
|
+
self._use_async = use_async
|
|
6046
|
+
|
|
6047
|
+
print(f'[= PORT =] IntegratedPipeline initialized on port {self._agent_port}')
|
|
6048
|
+
|
|
6011
6049
|
# Queue for managing async operations
|
|
6012
6050
|
self._async_tasks = set()
|
|
6013
6051
|
self._loop = None
|
|
@@ -6519,6 +6557,27 @@ class IntegratedPipeline:
|
|
|
6519
6557
|
eps = 1e-5
|
|
6520
6558
|
b = b[0]
|
|
6521
6559
|
|
|
6560
|
+
if isinstance(a, (str, np.str_)):
|
|
6561
|
+
clean_str = str(a).replace('[', '').replace(']', '')
|
|
6562
|
+
a = np.fromstring(clean_str, sep=' ')
|
|
6563
|
+
elif isinstance(a, np.ndarray) and np.issubdtype(a.dtype, np.character):
|
|
6564
|
+
# catches arrays filled with string text
|
|
6565
|
+
clean_str = ' '.join(a.astype(str).flatten()).replace('[', '').replace(']', '')
|
|
6566
|
+
a = np.fromstring(clean_str, sep=' ')
|
|
6567
|
+
else:
|
|
6568
|
+
# Ensure standard float array if it was integers or objects
|
|
6569
|
+
a = np.asarray(a, dtype=float)
|
|
6570
|
+
|
|
6571
|
+
# Handle variable b
|
|
6572
|
+
if isinstance(b, (str, np.str_)):
|
|
6573
|
+
clean_str = str(b).replace('[', '').replace(']', '')
|
|
6574
|
+
b = np.fromstring(clean_str, sep=' ')
|
|
6575
|
+
elif isinstance(b, np.ndarray) and np.issubdtype(b.dtype, np.character):
|
|
6576
|
+
clean_str = ' '.join(b.astype(str).flatten()).replace('[', '').replace(']', '')
|
|
6577
|
+
b = np.fromstring(clean_str, sep=' ')
|
|
6578
|
+
else:
|
|
6579
|
+
b = np.asarray(b, dtype=float)
|
|
6580
|
+
|
|
6522
6581
|
norm_a = np.linalg.norm(a)
|
|
6523
6582
|
norm_b = np.linalg.norm(b)
|
|
6524
6583
|
|
|
@@ -6543,7 +6602,6 @@ class IntegratedPipeline:
|
|
|
6543
6602
|
print('[-] No similarity due to inhomogenous shapes and failed attempts to find subsets, returning low similarity score.')
|
|
6544
6603
|
return 0.1
|
|
6545
6604
|
|
|
6546
|
-
|
|
6547
6605
|
else:
|
|
6548
6606
|
subset_a = a[:a.shape[0]]
|
|
6549
6607
|
subset_b = b[:subset_a.shape[0]]
|
|
@@ -7843,7 +7901,15 @@ class IntegratedPipeline:
|
|
|
7843
7901
|
def AME_Encoder(self, x):
|
|
7844
7902
|
X = np.asarray(x)
|
|
7845
7903
|
|
|
7846
|
-
|
|
7904
|
+
if isinstance(X, (str, np.str_)):
|
|
7905
|
+
clean_str = str(X).replace('[', '').replace(']', '')
|
|
7906
|
+
X = np.fromstring(clean_str, sep=' ')
|
|
7907
|
+
if isinstance(X, np.ndarray) and np.issubdtype(X.dtype, np.character):
|
|
7908
|
+
# catches arrays filled with string text
|
|
7909
|
+
clean_str = ' '.join(X.astype(str).flatten()).replace('[', '').replace(']', '')
|
|
7910
|
+
X = np.fromstring(clean_str, sep=' ')
|
|
7911
|
+
|
|
7912
|
+
gradient = np.gradient(X, axis=-1)
|
|
7847
7913
|
grad_energy = np.mean(np.linalg.norm(gradient, axis=-1))
|
|
7848
7914
|
X_mag = np.mean(np.linalg.norm(X, axis=-1))
|
|
7849
7915
|
|
|
@@ -7852,6 +7918,7 @@ class IntegratedPipeline:
|
|
|
7852
7918
|
if AME == 0.0:
|
|
7853
7919
|
eps = 1e-5
|
|
7854
7920
|
AME = AME + eps
|
|
7921
|
+
|
|
7855
7922
|
return AME
|
|
7856
7923
|
|
|
7857
7924
|
def feature_generation(self, rules, dataset):
|
|
@@ -9945,6 +10012,7 @@ class PipelineAsyncManager:
|
|
|
9945
10012
|
class PipelinePredictionManager:
|
|
9946
10013
|
def __init__(self, pipeline, label_csv='labels.csv', target_title='title', label='label'):
|
|
9947
10014
|
self.pipeline = pipeline
|
|
10015
|
+
|
|
9948
10016
|
try:
|
|
9949
10017
|
print("📖 Loading labels from text file...")
|
|
9950
10018
|
self.titles, self.y_raw, self.label_map = self.load_labels_from_csv(label_csv, target_title, label)
|
|
@@ -10740,7 +10808,7 @@ class PipelinePredictionManager:
|
|
|
10740
10808
|
elif results and not results[0].get('models_agree', True) or not self.pipeline.agreement:
|
|
10741
10809
|
need_peer_condition = not results[0].get('models_agree', True) and self.pipeline.peer_assistance_threshold > 0.3
|
|
10742
10810
|
print("\n[⚠️] Disagreement detected between MLP and Transformer predictions. Using calibrated probabilities for final decision.")
|
|
10743
|
-
if need_peer_condition:
|
|
10811
|
+
if not self.pipeline.autonomous and need_peer_condition:
|
|
10744
10812
|
print('|| Uncertain advanced prediction, requesting peer assistance if allowed...')
|
|
10745
10813
|
final_probs = self.pipeline._handle_distributed_connections(final_probs, attn_weights, input_ids, agreement)
|
|
10746
10814
|
|
|
@@ -11350,7 +11418,8 @@ class CohesiveAgentDeployment:
|
|
|
11350
11418
|
Handles graceful shutdown, error recovery, and peer connections.
|
|
11351
11419
|
"""
|
|
11352
11420
|
|
|
11353
|
-
def __init__(self,
|
|
11421
|
+
def __init__(self,
|
|
11422
|
+
pipeline: IntegratedPipeline = None,
|
|
11354
11423
|
memory_name: str,
|
|
11355
11424
|
filename: str,
|
|
11356
11425
|
target_title: str,
|
|
@@ -11365,33 +11434,8 @@ class CohesiveAgentDeployment:
|
|
|
11365
11434
|
peer_config: Any='peer_config.json',
|
|
11366
11435
|
consecutive_peer_config: Any=None
|
|
11367
11436
|
):
|
|
11368
|
-
super().__init__()
|
|
11369
11437
|
|
|
11370
|
-
|
|
11371
|
-
print(f"[===] CohesiveAgentDeployment already initialized, reusing...")
|
|
11372
|
-
return
|
|
11373
|
-
|
|
11374
|
-
self._singleton_initialized = True
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
self._init_params = {
|
|
11378
|
-
'memory_name': memory_name,
|
|
11379
|
-
'port': peer_discovery_port,
|
|
11380
|
-
'secret_key': secret_key,
|
|
11381
|
-
'trusted_networks':trusted_networks,
|
|
11382
|
-
'shared_auth_token': shared_auth_token
|
|
11383
|
-
}
|
|
11384
|
-
|
|
11385
|
-
self.pipeline = IntegratedPipeline(
|
|
11386
|
-
memory_name=memory_name,
|
|
11387
|
-
use_async=True,
|
|
11388
|
-
agent_port=peer_discovery_port,
|
|
11389
|
-
ssl_cert_file=None,
|
|
11390
|
-
ssl_key_file=None,
|
|
11391
|
-
secret_key=secret_key,
|
|
11392
|
-
shared_auth_token=shared_auth_token,
|
|
11393
|
-
predict_manager=predict_manager
|
|
11394
|
-
)
|
|
11438
|
+
self.pipeline = pipeline
|
|
11395
11439
|
|
|
11396
11440
|
# Initialize prediction manager
|
|
11397
11441
|
self.manager = PipelinePredictionManager(
|
|
@@ -12576,8 +12620,7 @@ class CohesiveAgentDeployment:
|
|
|
12576
12620
|
|
|
12577
12621
|
# ============ EXAMPLE: SECURE PEER-TO-PEER CLUSTER ============
|
|
12578
12622
|
|
|
12579
|
-
|
|
12580
|
-
async def run_secure_agent_cluster(test_titles, label_map, rules, agent_id, filename, title_name, label_name, manager):
|
|
12623
|
+
async def run_secure_agent_cluster(pipeline,test_titles, label_map, rules, agent_id, filename, title_name, label_name, manager):
|
|
12581
12624
|
"""
|
|
12582
12625
|
Run multiple agents that securely communicate.
|
|
12583
12626
|
Stops retrying once connected successfully.
|
|
@@ -12591,6 +12634,7 @@ async def run_secure_agent_cluster(test_titles, label_map, rules, agent_id, file
|
|
|
12591
12634
|
|
|
12592
12635
|
# Agent 1 - Primary (Port 5555)
|
|
12593
12636
|
agent1 = CohesiveAgentDeployment(
|
|
12637
|
+
pipeline=pipeline,
|
|
12594
12638
|
memory_name="agent_primary",
|
|
12595
12639
|
filename=filename,
|
|
12596
12640
|
target_title=title_name,
|
|
@@ -12606,6 +12650,7 @@ async def run_secure_agent_cluster(test_titles, label_map, rules, agent_id, file
|
|
|
12606
12650
|
|
|
12607
12651
|
# Agent 2 - Secondary (Port 5556)
|
|
12608
12652
|
agent2 = CohesiveAgentDeployment(
|
|
12653
|
+
pipeline=pipeline,
|
|
12609
12654
|
memory_name="agent_secondary",
|
|
12610
12655
|
filename=filename,
|
|
12611
12656
|
target_title=title_name,
|
|
@@ -12679,7 +12724,7 @@ async def run_secure_agent_cluster(test_titles, label_map, rules, agent_id, file
|
|
|
12679
12724
|
|
|
12680
12725
|
|
|
12681
12726
|
|
|
12682
|
-
async def example_async_with_result_queue(test_titles, label_map, rules, agent_id, filename, title_name, label_name):
|
|
12727
|
+
async def example_async_with_result_queue(pipeline, test_titles, label_map, rules, agent_id, filename, title_name, label_name):
|
|
12683
12728
|
# Example using the proper result queue
|
|
12684
12729
|
|
|
12685
12730
|
agent = CohesiveAgentDeployment(
|
|
@@ -12744,15 +12789,15 @@ async def example_async_with_result_queue(test_titles, label_map, rules, agent_i
|
|
|
12744
12789
|
|
|
12745
12790
|
|
|
12746
12791
|
|
|
12747
|
-
def initiate_cohesive_agent_deployment_test(test_titles, label_map, rules, agent_id, filename, title_name, label_name, manager):
|
|
12792
|
+
def initiate_cohesive_agent_deployment_test(pipeline, test_titles, label_map, rules, agent_id, filename, title_name, label_name, manager):
|
|
12748
12793
|
print("\n" + "="*60)
|
|
12749
12794
|
print("🔮 = TESTING COHESIVE AGENT DEPLOYMENT WITH ASYNC MANAGER = ")
|
|
12750
12795
|
|
|
12751
12796
|
print('Test 1 of Multi agent cluster')
|
|
12752
|
-
asyncio.run(run_secure_agent_cluster(test_titles=test_titles, label_map=label_map, rules=rules, agent_id=agent_id, filename=filename, title_name=title_name, label_name=label_name, manager=manager))
|
|
12797
|
+
asyncio.run(run_secure_agent_cluster(pipeline=pipeline, test_titles=test_titles, label_map=label_map, rules=rules, agent_id=agent_id, filename=filename, title_name=title_name, label_name=label_name, manager=manager))
|
|
12753
12798
|
|
|
12754
12799
|
print("\n1. Basic async with result queue")
|
|
12755
|
-
asyncio.run(example_async_with_result_queue(test_titles=test_titles, label_map=label_map, rules=rules, agent_id=agent_id, filename=filename, title_name=title_name, label_name=label_name))
|
|
12800
|
+
asyncio.run(example_async_with_result_queue(pipeline=pipeline, test_titles=test_titles, label_map=label_map, rules=rules, agent_id=agent_id, filename=filename, title_name=title_name, label_name=label_name))
|
|
12756
12801
|
|
|
12757
12802
|
|
|
12758
12803
|
# async manager setup examples
|
|
@@ -12879,10 +12924,10 @@ def PermissiveTest():
|
|
|
12879
12924
|
key_file = None
|
|
12880
12925
|
|
|
12881
12926
|
if file:
|
|
12882
|
-
pipeline = IntegratedPipeline(file, use_async=True, agent_port=5001, ssl_cert_file=cert_file, ssl_key_file=key_file)
|
|
12927
|
+
pipeline = IntegratedPipeline(file, use_async=True, agent_port=5001, singleton_permitted=False,ssl_cert_file=cert_file, ssl_key_file=key_file)
|
|
12883
12928
|
else:
|
|
12884
12929
|
print('|| Using original csv_file.pkl file as fallback...')
|
|
12885
|
-
pipeline = IntegratedPipeline('csv_file.pkl', use_async=True, agent_port=5001, ssl_cert_file=cert_file, ssl_key_file=key_file)
|
|
12930
|
+
pipeline = IntegratedPipeline('csv_file.pkl', use_async=True, agent_port=5001, singleton_permitted=False, ssl_cert_file=cert_file, ssl_key_file=key_file)
|
|
12886
12931
|
|
|
12887
12932
|
manager = PipelinePredictionManager(pipeline, label_csv='ManualsTraining.txt', target_title='window_title', label='label')
|
|
12888
12933
|
|
|
@@ -13026,9 +13071,9 @@ def PermissiveTest():
|
|
|
13026
13071
|
if cohesive_permission == 'Y' or cohesive_permission == 'y':
|
|
13027
13072
|
if not (filename and title and label and filename != 'N'):
|
|
13028
13073
|
print('[=] Searching fallback filename: ManualsTraining.txt, window_title, label')
|
|
13029
|
-
initiate_cohesive_agent_deployment_test(test_titles, label_map, rules, agent_id, 'ManualsTraining.txt', 'window_title', 'label', manager)
|
|
13074
|
+
initiate_cohesive_agent_deployment_test(pipeline,test_titles, label_map, rules, agent_id, 'ManualsTraining.txt', 'window_title', 'label', manager)
|
|
13030
13075
|
else:
|
|
13031
|
-
initiate_cohesive_agent_deployment_test(test_titles, label_map, rules, agent_id, filename, title, label, manager)
|
|
13076
|
+
initiate_cohesive_agent_deployment_test(pipeline, test_titles, label_map, rules, agent_id, filename, title, label, manager)
|
|
13032
13077
|
print('== Cohesive Agent Deployment Successfully tested! ==')
|
|
13033
13078
|
|
|
13034
13079
|
else:
|
|
@@ -13045,3 +13090,4 @@ if __name__ == "__main__":
|
|
|
13045
13090
|
traceback.print_exc()
|
|
13046
13091
|
pass
|
|
13047
13092
|
|
|
13093
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AbstractIntegratedModule
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Framework forAdvanced Integrated Non-LLM AI Module library - Backend Framework for Non-LLM AI Agent Framework
|
|
5
5
|
Author: Micro-Novelty
|
|
6
6
|
Author-email: hernikpuspita5@gmail.com
|
|
@@ -40,11 +40,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
40
40
|
#### Note: The README here you are reading is a direct copy from my README Repository, to download the necessary files, you can visit my Repository with the provided link above.
|
|
41
41
|
|
|
42
42
|
### Library Short Description:
|
|
43
|
-
- Development Stage: Beta, 0.2.
|
|
43
|
+
- Development Stage: Beta, 0.2.3.
|
|
44
44
|
- Maintainer: Micro-Novelty.
|
|
45
45
|
- library Source-Code is Open-sourced on github.
|
|
46
46
|
- Purpose: Specifically Designed for providing Non-LLM AI Agent Framework for edge Devices, Optimized for ARM64 architecture.
|
|
47
|
-
|
|
47
|
+
- Proven Capabilities: Works on ARM64 Environment, Training and Prediction works efficient on Docker ARM64 environment with QEMU, good parallelizing behavior is guaranteed.
|
|
48
48
|
|
|
49
49
|
<img width="1280" height="600" alt="WhatsApp Image 2026-05-27 at 07 16 32" src="https://github.com/user-attachments/assets/4b58a556-45a3-419b-96fd-9c1b76cac574" />
|
|
50
50
|
|
|
@@ -482,8 +482,16 @@ B. [=] Advanced Prediction without Transformer, Only Specialized MLP using AWE.
|
|
|
482
482
|
import numpy as np
|
|
483
483
|
|
|
484
484
|
memory_name = 'agent_memory'
|
|
485
|
-
main_model = IntegratedPipeline(
|
|
486
|
-
|
|
485
|
+
main_model = IntegratedPipeline(
|
|
486
|
+
memory_name=memory_name, use_async=True,
|
|
487
|
+
agent_port=5001, # this port is used to set AgentDistributedInference server.
|
|
488
|
+
singleton_permitted=False, # set IntegratedPipeline to singleton if you don't use it for P2P, False if you use P2P.
|
|
489
|
+
ssl_cert_file=cert_file, ssl_key_file=key_file) # provide your cert_file path or key_file path (optional)
|
|
490
|
+
|
|
491
|
+
main_prediction = PipelinePredictionManager(
|
|
492
|
+
main_model, label_csv='example_manual_training.txt',
|
|
493
|
+
target_title='window_title', label='label')
|
|
494
|
+
|
|
487
495
|
# example_manual_training is a .txt file that contain csv format like above example.
|
|
488
496
|
|
|
489
497
|
|
|
@@ -616,6 +624,7 @@ predicted_output = async_manager.advanced_batch_prediction(test_titles, label_ma
|
|
|
616
624
|
- To Make the Agent cooperate with other peers, consider using this setup:
|
|
617
625
|
- [=] for ensemble prediction from multiple peers, exchanging predicted label with each other, consider using this setup:
|
|
618
626
|
```python
|
|
627
|
+
|
|
619
628
|
# step 3
|
|
620
629
|
from AbstractIntegratedModule import CohesiveAgentDeployment
|
|
621
630
|
from AbstractIntegratedModule import PipelinePredictionManager
|
|
@@ -634,23 +643,25 @@ main_model.distribution.enable_ssl = False # set to false if you dont have SSL k
|
|
|
634
643
|
|
|
635
644
|
# Agent 1 - Primary (Port 5555)
|
|
636
645
|
agent1 = CohesiveAgentDeployment(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
646
|
+
pipeline=main_model, # main_model is your initialized integrated pipeline
|
|
647
|
+
memory_name="agent_primary", # any name you want for the agent.
|
|
648
|
+
filename=<filename>, # name of your .txt file that contains the CSV format and training labels
|
|
649
|
+
target_title=<title_name>,
|
|
640
650
|
label_name=<label_name>,
|
|
641
|
-
security_level="PRODUCTION",
|
|
642
|
-
enable_peers=True,
|
|
651
|
+
security_level="PRODUCTION", # production level security
|
|
652
|
+
enable_peers=True, # allow peer discovery
|
|
643
653
|
trusted_networks=['127.0.0.1/32', '192.168.1.0/24'], # for trusted networks, you need to provide the list of IPs of your peers.
|
|
644
654
|
peer_discovery_port=5555, # peer port to start P2P
|
|
645
|
-
secret_key=secret_key,
|
|
655
|
+
secret_key=secret_key, # your secret key
|
|
646
656
|
shared_auth_token=secret_key, # your previous initialized secret_key
|
|
647
|
-
predict_manager=prediction_manager,
|
|
657
|
+
predict_manager=prediction_manager, # your prediction manager
|
|
648
658
|
peer_config = <'your_peer_ip_lists.json'> # you need to create .json file that contains your peer IP and Port lists
|
|
649
659
|
consecutive_peer_config = <'your_second_fallback_peer_ip_lists.json'> # same for this one too, but for fallback.
|
|
650
|
-
|
|
660
|
+
)
|
|
651
661
|
|
|
652
662
|
# Agent 2 - Secondary (Port 5556)
|
|
653
663
|
agent2 = CohesiveAgentDeployment(
|
|
664
|
+
pipeline=main_model,
|
|
654
665
|
memory_name="agent_secondary",
|
|
655
666
|
filename=<filename>,
|
|
656
667
|
target_title=<title_name>,
|
|
@@ -664,21 +675,20 @@ agent2 = CohesiveAgentDeployment(
|
|
|
664
675
|
predict_manager=prediction_manager,
|
|
665
676
|
peer_config = <'your_peer_ip_lists.json'> # you need to create .json file that contains your peer IP and Port lists
|
|
666
677
|
consecutive_peer_config = <'your_second_fallback_peer_ip_lists.json'> # same for this one too, but for fallback.
|
|
667
|
-
|
|
678
|
+
)
|
|
668
679
|
|
|
669
680
|
# Note: CohesiveAgentDeployment contains ConsecutivePeerAgent that can start a server once ensemble prediction from peer is started
|
|
670
681
|
# be advised to stop the server too before shutdown-ing CohesiveAgentDeployment cluster
|
|
671
682
|
|
|
672
683
|
# example peer_Ip_lists_config.json (de-comment to use)
|
|
673
684
|
# {
|
|
674
|
-
#
|
|
685
|
+
# you must put "known_peers" in the config so python can identify the list of IPs and Ports
|
|
686
|
+
# "known_peers": [
|
|
675
687
|
# ["127.0.0.1", 5555], can be modified using real IP or local IP.
|
|
676
688
|
# ["127.0.0.1", 5556]
|
|
677
689
|
# ]
|
|
678
690
|
# }
|
|
679
691
|
|
|
680
|
-
agent1.pipeline = main_model # overrides agent1 baseline pipeline with your original initialized pipelinej
|
|
681
|
-
agent2.pipeline = main_model
|
|
682
692
|
|
|
683
693
|
try:
|
|
684
694
|
# Start both agents
|
|
@@ -699,8 +709,8 @@ try:
|
|
|
699
709
|
|
|
700
710
|
texts = {"test_titles": test_titles, "label_map": label_map, "rules": rules, "use_transformer": True, "agent_id": agent_id}
|
|
701
711
|
|
|
702
|
-
# texts
|
|
703
|
-
# agent ID can be strings, int, or floats,
|
|
712
|
+
# texts dictionary must contain test_titles, label_map, and rules that you can assign,
|
|
713
|
+
# agent ID can be strings, int, or floats, recommendded to make it long for better security.
|
|
704
714
|
|
|
705
715
|
# Make prediction with peer ensemble
|
|
706
716
|
# Connection will be guaranteed successfull during discovery.
|
|
@@ -8,11 +8,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
8
8
|
#### Note: The README here you are reading is a direct copy from my README Repository, to download the necessary files, you can visit my Repository with the provided link above.
|
|
9
9
|
|
|
10
10
|
### Library Short Description:
|
|
11
|
-
- Development Stage: Beta, 0.2.
|
|
11
|
+
- Development Stage: Beta, 0.2.3.
|
|
12
12
|
- Maintainer: Micro-Novelty.
|
|
13
13
|
- library Source-Code is Open-sourced on github.
|
|
14
14
|
- Purpose: Specifically Designed for providing Non-LLM AI Agent Framework for edge Devices, Optimized for ARM64 architecture.
|
|
15
|
-
|
|
15
|
+
- Proven Capabilities: Works on ARM64 Environment, Training and Prediction works efficient on Docker ARM64 environment with QEMU, good parallelizing behavior is guaranteed.
|
|
16
16
|
|
|
17
17
|
<img width="1280" height="600" alt="WhatsApp Image 2026-05-27 at 07 16 32" src="https://github.com/user-attachments/assets/4b58a556-45a3-419b-96fd-9c1b76cac574" />
|
|
18
18
|
|
|
@@ -450,8 +450,16 @@ B. [=] Advanced Prediction without Transformer, Only Specialized MLP using AWE.
|
|
|
450
450
|
import numpy as np
|
|
451
451
|
|
|
452
452
|
memory_name = 'agent_memory'
|
|
453
|
-
main_model = IntegratedPipeline(
|
|
454
|
-
|
|
453
|
+
main_model = IntegratedPipeline(
|
|
454
|
+
memory_name=memory_name, use_async=True,
|
|
455
|
+
agent_port=5001, # this port is used to set AgentDistributedInference server.
|
|
456
|
+
singleton_permitted=False, # set IntegratedPipeline to singleton if you don't use it for P2P, False if you use P2P.
|
|
457
|
+
ssl_cert_file=cert_file, ssl_key_file=key_file) # provide your cert_file path or key_file path (optional)
|
|
458
|
+
|
|
459
|
+
main_prediction = PipelinePredictionManager(
|
|
460
|
+
main_model, label_csv='example_manual_training.txt',
|
|
461
|
+
target_title='window_title', label='label')
|
|
462
|
+
|
|
455
463
|
# example_manual_training is a .txt file that contain csv format like above example.
|
|
456
464
|
|
|
457
465
|
|
|
@@ -584,6 +592,7 @@ predicted_output = async_manager.advanced_batch_prediction(test_titles, label_ma
|
|
|
584
592
|
- To Make the Agent cooperate with other peers, consider using this setup:
|
|
585
593
|
- [=] for ensemble prediction from multiple peers, exchanging predicted label with each other, consider using this setup:
|
|
586
594
|
```python
|
|
595
|
+
|
|
587
596
|
# step 3
|
|
588
597
|
from AbstractIntegratedModule import CohesiveAgentDeployment
|
|
589
598
|
from AbstractIntegratedModule import PipelinePredictionManager
|
|
@@ -602,23 +611,25 @@ main_model.distribution.enable_ssl = False # set to false if you dont have SSL k
|
|
|
602
611
|
|
|
603
612
|
# Agent 1 - Primary (Port 5555)
|
|
604
613
|
agent1 = CohesiveAgentDeployment(
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
614
|
+
pipeline=main_model, # main_model is your initialized integrated pipeline
|
|
615
|
+
memory_name="agent_primary", # any name you want for the agent.
|
|
616
|
+
filename=<filename>, # name of your .txt file that contains the CSV format and training labels
|
|
617
|
+
target_title=<title_name>,
|
|
608
618
|
label_name=<label_name>,
|
|
609
|
-
security_level="PRODUCTION",
|
|
610
|
-
enable_peers=True,
|
|
619
|
+
security_level="PRODUCTION", # production level security
|
|
620
|
+
enable_peers=True, # allow peer discovery
|
|
611
621
|
trusted_networks=['127.0.0.1/32', '192.168.1.0/24'], # for trusted networks, you need to provide the list of IPs of your peers.
|
|
612
622
|
peer_discovery_port=5555, # peer port to start P2P
|
|
613
|
-
secret_key=secret_key,
|
|
623
|
+
secret_key=secret_key, # your secret key
|
|
614
624
|
shared_auth_token=secret_key, # your previous initialized secret_key
|
|
615
|
-
predict_manager=prediction_manager,
|
|
625
|
+
predict_manager=prediction_manager, # your prediction manager
|
|
616
626
|
peer_config = <'your_peer_ip_lists.json'> # you need to create .json file that contains your peer IP and Port lists
|
|
617
627
|
consecutive_peer_config = <'your_second_fallback_peer_ip_lists.json'> # same for this one too, but for fallback.
|
|
618
|
-
|
|
628
|
+
)
|
|
619
629
|
|
|
620
630
|
# Agent 2 - Secondary (Port 5556)
|
|
621
631
|
agent2 = CohesiveAgentDeployment(
|
|
632
|
+
pipeline=main_model,
|
|
622
633
|
memory_name="agent_secondary",
|
|
623
634
|
filename=<filename>,
|
|
624
635
|
target_title=<title_name>,
|
|
@@ -632,21 +643,20 @@ agent2 = CohesiveAgentDeployment(
|
|
|
632
643
|
predict_manager=prediction_manager,
|
|
633
644
|
peer_config = <'your_peer_ip_lists.json'> # you need to create .json file that contains your peer IP and Port lists
|
|
634
645
|
consecutive_peer_config = <'your_second_fallback_peer_ip_lists.json'> # same for this one too, but for fallback.
|
|
635
|
-
|
|
646
|
+
)
|
|
636
647
|
|
|
637
648
|
# Note: CohesiveAgentDeployment contains ConsecutivePeerAgent that can start a server once ensemble prediction from peer is started
|
|
638
649
|
# be advised to stop the server too before shutdown-ing CohesiveAgentDeployment cluster
|
|
639
650
|
|
|
640
651
|
# example peer_Ip_lists_config.json (de-comment to use)
|
|
641
652
|
# {
|
|
642
|
-
#
|
|
653
|
+
# you must put "known_peers" in the config so python can identify the list of IPs and Ports
|
|
654
|
+
# "known_peers": [
|
|
643
655
|
# ["127.0.0.1", 5555], can be modified using real IP or local IP.
|
|
644
656
|
# ["127.0.0.1", 5556]
|
|
645
657
|
# ]
|
|
646
658
|
# }
|
|
647
659
|
|
|
648
|
-
agent1.pipeline = main_model # overrides agent1 baseline pipeline with your original initialized pipelinej
|
|
649
|
-
agent2.pipeline = main_model
|
|
650
660
|
|
|
651
661
|
try:
|
|
652
662
|
# Start both agents
|
|
@@ -667,8 +677,8 @@ try:
|
|
|
667
677
|
|
|
668
678
|
texts = {"test_titles": test_titles, "label_map": label_map, "rules": rules, "use_transformer": True, "agent_id": agent_id}
|
|
669
679
|
|
|
670
|
-
# texts
|
|
671
|
-
# agent ID can be strings, int, or floats,
|
|
680
|
+
# texts dictionary must contain test_titles, label_map, and rules that you can assign,
|
|
681
|
+
# agent ID can be strings, int, or floats, recommendded to make it long for better security.
|
|
672
682
|
|
|
673
683
|
# Make prediction with peer ensemble
|
|
674
684
|
# Connection will be guaranteed successfull during discovery.
|
|
@@ -3,7 +3,7 @@ from setuptools import setup
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
5
|
name="AbstractIntegratedModule",
|
|
6
|
-
version="0.2.
|
|
6
|
+
version="0.2.3",
|
|
7
7
|
description="Framework forAdvanced Integrated Non-LLM AI Module library - Backend Framework for Non-LLM AI Agent Framework",
|
|
8
8
|
long_description=open("README.md", encoding="utf-8").read(),
|
|
9
9
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|