agent
agent
¶
Classes:
| Name | Description |
|---|---|
Agent |
This class contains those basic actions that can be performed by every agent. |
Classes¶
Agent
¶
Bases: AgentBasics
This class contains those basic actions that can be performed by every agent.
Methods:
| Name | Description |
|---|---|
set_next_action |
Try to tell another agent what is the next action it should run. |
send_engagement |
Offer engagement to the agents whose identifiers are in self._found_agents. |
get_engagement |
Receive engagement from another agent whose authority is in the specified range. |
got_engagement |
Confirm an engagement. |
send_disengagement |
Ask for disengagement. |
get_disengagement |
Get a disengagement request from an agent. |
disengage_all |
Disengage all the previously engaged agents. |
disconnect_by_role |
Disconnects from all agents that match a specified role. |
disconnected |
Checks if a specific set of agents (by ID or wildcard) are no longer connected to the agent. |
received_some_asked_data |
Checks if any of the agents that were previously asked for data (e.g., via |
nop |
Do nothing. |
wait_for_actions |
Lock or unlock every action between a pair of states in the state machine of a target agent. |
ask_gen |
Asking for generation. |
do_gen |
Generate a signal. |
done_gen |
This is a way to get back the confirmation of a completed generation. |
ask_learn |
Asking for learning to generate. |
do_learn |
Learn to generate a signal. |
done_learn |
This is a way to get back the confirmation of a completed learning procedure. |
all_asked_finished |
Checks if all agents that were previously asked to perform a task (e.g., generate or learn) have sent a |
all_engagements_completed |
Checks if all engagement requests that were sent have been confirmed. It returns True if there are no agents |
agents_are_waiting |
Checks if there are any agents who have connected but have not yet been fully processed or added to the |
ask_subscribe |
Requests a remote agent or a group of agents to subscribe to or unsubscribe from a list of specified PubSub |
do_subscribe |
Executes a subscription or unsubscription request received from another agent. It processes the stream |
done_subscribe |
Handles the confirmation that a subscription or unsubscription request has been completed by another agent. |
record |
Records data from a specified stream into a new, owned |
connect_by_role |
Finds and attempts to connect with agents whose profiles match a specific role. It can be optionally |
find_agents |
Locally searches through the agent's known peers (world and public agents) to find agents with a specific |
next_pref_stream |
Moves the internal pointer to the next stream in the list of preferred streams, which is often used for |
first_pref_stream |
Resets the internal pointer to the first stream in the list of preferred streams. This is useful for |
check_pref_stream |
Checks the position of the current preferred stream within the list. It can check if it's the first, last, |
set_pref_streams |
Fills the agent's list of preferred streams (a playlist). It can repeat the playlist a specified number of |
evaluate |
Evaluates the performance of agents that have completed a generation task. It compares the generated data |
compare_eval |
Compares the results of a previous evaluation to a given threshold or finds the best result among all |
suggest_role_to_world |
Suggests a role change for one or more agents to the world master. It iterates through the involved agents, |
suggest_badges_to_world |
Suggests one or more badges to the world master for specific agents. This is typically used to reward agents |
Source code in unaiverse/agent.py
Methods:¶
set_next_action
¶
set_next_action(agent: str | None, action: str, args: dict | None = None, ref_uuid: str | None = None)
Try to tell another agent what is the next action it should run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str | None
|
The ID of the agent to send the action to or a valid wildcard like " |
required |
action
|
str
|
The name of the action to be executed by the agent. |
required |
args
|
dict | None
|
A dictionary of arguments for the action. Defaults to None. |
None
|
ref_uuid
|
str | None
|
An optional UUID for referencing the action. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the action was successfully sent to the target agent or to at least one of the |
|
|
involved agents (wildcard case). |
Source code in unaiverse/agent.py
send_engagement
¶
Offer engagement to the agents whose identifiers are in self._found_agents.
Returns:
| Type | Description |
|---|---|
|
True if engagement requests were successfully sent to at least one found agent, False otherwise. |
Source code in unaiverse/agent.py
get_engagement
¶
get_engagement(acceptable_role: str | None = None, sender_role: str | None = None, _requester: str | None = None)
Receive engagement from another agent whose authority is in the specified range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acceptable_role
|
str | None
|
The role that the sender must have for engagement to be accepted. Defaults to None. |
None
|
sender_role
|
str | None
|
The role of the agent sending the engagement request. Defaults to None. |
None
|
_requester
|
str | None
|
The ID of the agent requesting engagement (automatically set by the action calling routine) |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the engagement was successfully received and confirmed, False otherwise. |
Source code in unaiverse/agent.py
got_engagement
¶
Confirm an engagement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_requester
|
str | None
|
The ID of the agent confirming the engagement (automatically set by the action calling routine). |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the engagement was successfully confirmed, False otherwise. |
Source code in unaiverse/agent.py
send_disengagement
¶
Ask for disengagement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
send_disconnection_too
|
bool
|
Whether to send a disconnect-suggestion together with the disengagement. |
False
|
Returns:
| Type | Description |
|---|---|
|
True if disengagement requests were successfully sent to at least one engaged agent, False otherwise. |
Source code in unaiverse/agent.py
get_disengagement
¶
Get a disengagement request from an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disconnect_too
|
bool
|
Whether to disconnect the agent who sent the disengagement. |
False
|
_requester
|
str | None
|
The ID of the agent requesting disengagement. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the disengagement request was successfully processed, False otherwise. |
Source code in unaiverse/agent.py
disengage_all
¶
Disengage all the previously engaged agents.
Returns:
| Type | Description |
|---|---|
|
True if the disengagement procedure was successfully executed, False otherwise. |
Source code in unaiverse/agent.py
disconnect_by_role
¶
Disconnects from all agents that match a specified role. It finds the agents and calls the node's purge function on each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str | list[str]
|
A string or list of strings representing the role(s) of agents to disconnect from. |
required |
Returns:
| Type | Description |
|---|---|
|
Always True. |
Source code in unaiverse/agent.py
disconnected
¶
Checks if a specific set of agents (by ID or wildcard) are no longer connected to the agent. It returns False if any of the specified agents are still connected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str | None
|
The ID of the agent or a wildcard to check. |
None
|
delay
|
float
|
The time (seconds) to be spent in the current state before actually considering this action. |
-1.0
|
Returns:
| Type | Description |
|---|---|
|
True if all involved agents are disconnected, False otherwise. |
Source code in unaiverse/agent.py
received_some_asked_data
¶
Checks if any of the agents that were previously asked for data (e.g., via ask_gen) have sent a stream
sample back. Optionally, it can process the received data with a specified function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processing_fcn
|
str | None
|
The name of a function to process the received data. |
None
|
Returns:
| Type | Description |
|---|---|
|
True if at least one data sample was received, False otherwise. |
Source code in unaiverse/agent.py
nop
¶
Do nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str | None
|
An optional message to print. Defaults to None. |
None
|
delay
|
float
|
The time (seconds) to be spent in the current state before actually considering this action. |
-1.0
|
Returns:
| Type | Description |
|---|---|
|
Always True. |
Source code in unaiverse/agent.py
wait_for_actions
¶
Lock or unlock every action between a pair of states in the state machine of a target agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str
|
The ID of the agent to send the action locking request to, or a valid wildcard like " |
required |
from_state
|
str
|
The starting state of the actions to be locked/unlocked. |
required |
to_state
|
str
|
The ending state of the actions to be locked/unlocked. |
required |
wait
|
bool
|
A boolean indicating whether to wait for the actions to complete (wait == !ready). |
required |
Returns:
| Type | Description |
|---|---|
|
True if the request was successfully sent to at least one involved agent, False otherwise. |
Source code in unaiverse/agent.py
ask_gen
¶
ask_gen(agent: str | None = None, u_hashes: list[str] | None = None, samples: int = 100, time: float = -1.0, timeout: float = -1.0, ask_uuid: str | None = None, ignore_uuid: bool = False)
Asking for generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str | None
|
The ID of the agent to ask for generation, or a valid wildcard like " |
None
|
u_hashes
|
list[str] | None
|
A list of input stream hashes for generation. Defaults to None. |
None
|
samples
|
int
|
The number of samples to generate. Defaults to 100. |
100
|
time
|
float
|
The time duration for generation. Defaults to -1. |
-1.0
|
timeout
|
float
|
The timeout for the generation request. Defaults to -1. |
-1.0
|
ask_uuid
|
str | None
|
Specify the UUID of the action (if None - default -, it is randomly generated). |
None
|
ignore_uuid
|
bool
|
Force a None UUID instead of generating a random one. |
False
|
Returns:
| Type | Description |
|---|---|
|
True if the generation request was successfully sent to at least one involved agent, False otherwise. |
Source code in unaiverse/agent.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
do_gen
¶
do_gen(u_hashes: list[str] | None = None, samples: int = 100, time: float = -1.0, timeout: float = -1.0, _requester: str | list | None = None, _request_time: float = -1.0, _request_uuid: str | None = None, _completed: bool = False) -> bool
Generate a signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u_hashes
|
list[str] | None
|
A list of input stream hashes for generation. Defaults to None. |
None
|
samples
|
int
|
The number of samples to generate. Defaults to 100. |
100
|
time
|
float
|
The max time duration for whole generation process. Defaults to -1. |
-1.0
|
timeout
|
float
|
The timeout for generation attempts: if calling the generate action fails for more than "timeout" |
-1.0
|
_requester
|
str | list | None
|
The ID of the agent who requested generation (automatically set by the action calling routine). |
None
|
_request_time
|
float
|
The time the generation was requested (automatically set by the action calling routine). |
-1.0
|
_request_uuid
|
str | None
|
The UUID of the generation request (automatically set by the action calling routine). |
None
|
_completed
|
bool
|
A boolean indicating if the generation is already completed (automatically set by the action calling routine). This will tell that it is time to run a final procedure. |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the signal generation was successful, False otherwise. |
Source code in unaiverse/agent.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
done_gen
¶
This is a way to get back the confirmation of a completed generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_requester
|
str | None
|
The ID of the agent who completed the generation. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the generation confirmation was successfully handled by this agent, False is something went wrong. |
Source code in unaiverse/agent.py
ask_learn
¶
ask_learn(agent: str | None = None, u_hashes: list[str] | None = None, yhat_hashes: list[str] | None = None, samples: int = 100, time: float = -1.0, timeout: float = -1.0, ask_uuid: str | None = None, ignore_uuid: str | None = None)
Asking for learning to generate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str | None
|
The ID of the agent to ask for generation, or a valid wildcard like " |
None
|
u_hashes
|
list[str] | None
|
A list of input stream hashes for inference. Defaults to None. |
None
|
yhat_hashes
|
list[str] | None
|
A list of target stream hashes to be used for loss computation. Defaults to None. |
None
|
samples
|
int
|
The number of samples to learn from. Defaults to 100. |
100
|
time
|
float
|
The time duration for generation. Defaults to -1. |
-1.0
|
timeout
|
float
|
The timeout for the generation request. Defaults to -1. |
-1.0
|
ask_uuid
|
str | None
|
Specify the action UUID (default = None, i.e., it is automatically generated). |
None
|
ignore_uuid
|
str | None
|
If Trie, the UUID is fully ignored (i.e, forced to None). |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the learning request was successfully sent to at least one involved agent, False otherwise. |
Source code in unaiverse/agent.py
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | |
do_learn
¶
do_learn(yhat_hashes: list[str] | None = None, u_hashes: list[str] | None = None, samples: int = 100, time: float = -1.0, timeout: float = -1.0, _requester: str | None = None, _request_time: float = -1.0, _request_uuid: str | None = None, _completed: bool = False) -> bool
Learn to generate a signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yhat_hashes
|
list[str] | None
|
A list of target stream hashes to be used for loss computation. Defaults to None. |
None
|
u_hashes
|
list[str] | None
|
A list of input stream hashes for inference. Defaults to None. |
None
|
samples
|
int
|
The number of samples to learn from. Defaults to 100. |
100
|
time
|
float
|
The max time duration of the learning procedure. Defaults to -1. |
-1.0
|
timeout
|
float
|
The timeout for learning attempts: if calling the learning action fails for more than "timeout" |
-1.0
|
_requester
|
str | None
|
The ID of the agent who requested learning (automatically set by the action calling routine). |
None
|
_request_time
|
float
|
The time learning was requested (automatically set by the action calling routine). |
-1.0
|
_request_uuid
|
str | None
|
The UUID of the learning request (automatically set by the action calling routine). |
None
|
_completed
|
bool
|
A boolean indicating if the learning is already completed (automatically set by the action calling routine). This will tell that it is time to run a final procedure. |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the signal generation was successful, False otherwise. |
Source code in unaiverse/agent.py
done_learn
¶
This is a way to get back the confirmation of a completed learning procedure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_requester
|
str | None
|
The ID of the agent who completed the learning procedure. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the learning-complete confirmation was successfully handled by this agent, False otherwise. |
Source code in unaiverse/agent.py
all_asked_finished
¶
Checks if all agents that were previously asked to perform a task (e.g., generate or learn) have sent a completion confirmation. It compares the set of agents asked with the set of agents that have completed the task.
Returns:
| Type | Description |
|---|---|
|
True if all agents are done, False otherwise. |
Source code in unaiverse/agent.py
all_engagements_completed
¶
Checks if all engagement requests that were sent have been confirmed. It returns True if there are no agents
remaining in the _found_agents list, implying all have been engaged with or discarded.
Returns:
| Type | Description |
|---|---|
|
True if all engagements are complete, False otherwise. |
Source code in unaiverse/agent.py
agents_are_waiting
¶
Checks if there are any agents who have connected but have not yet been fully processed or added to the agent's known lists. This indicates that new agents are waiting to be managed.
Returns:
| Type | Description |
|---|---|
|
True if there are waiting agents, False otherwise. |
Source code in unaiverse/agent.py
ask_subscribe
¶
ask_subscribe(agent: str | None = None, stream_hashes: list[str] | None = None, unsubscribe: bool = False)
Requests a remote agent or a group of agents to subscribe to or unsubscribe from a list of specified PubSub streams. It normalizes the stream hashes and sends an action request containing the stream properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str | None
|
The target agent's ID or a wildcard. |
None
|
stream_hashes
|
list[str] | None
|
A list of streams to subscribe to or unsubscribe from. |
None
|
unsubscribe
|
bool
|
A boolean to indicate if it's an unsubscription request. |
False
|
Returns:
| Type | Description |
|---|---|
|
True if the request was sent to at least one agent, False otherwise. |
Source code in unaiverse/agent.py
do_subscribe
¶
do_subscribe(stream_owners: list[str] | None = None, stream_props: list[str] | None = None, unsubscribe: bool = False, _requester: str | list | None = None, _request_time: float = -1.0)
Executes a subscription or unsubscription request received from another agent. It processes the stream properties, adds or removes the streams from the agent's known streams, and handles the underlying PubSub topic subscriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream_owners
|
list[str] | None
|
A list of peer IDs who own the streams. |
None
|
stream_props
|
list[str] | None
|
A list of JSON-serialized stream properties. |
None
|
unsubscribe
|
bool
|
A boolean to indicate unsubscription. |
False
|
_requester
|
str | list | None
|
The ID of the requesting agent. |
None
|
_request_time
|
float
|
The time the request was made. |
-1.0
|
Returns:
| Type | Description |
|---|---|
|
True if the action is successful, False otherwise. |
Source code in unaiverse/agent.py
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 | |
done_subscribe
¶
Handles the confirmation that a subscription or unsubscription request has been completed by another agent. It adds the requester to the set of agents that have completed their asked tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unsubscribe
|
bool
|
A boolean indicating if it was an unsubscription. |
False
|
_requester
|
str | None
|
The ID of the agent who completed the task. |
None
|
Returns:
| Type | Description |
|---|---|
|
Always True. |
Source code in unaiverse/agent.py
record
¶
Records data from a specified stream into a new, owned BufferedDataStream. This is a multistep action
that captures a sequence of samples over time and then adds the new recorded stream to the agent's profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net_hash
|
str
|
The hash of the stream to record. |
required |
samples
|
int
|
The number of samples to record. |
100
|
time
|
float
|
The time duration for recording. |
-1.0
|
timeout
|
float
|
The timeout for each recording attempt. |
-1.0
|
Returns:
| Type | Description |
|---|---|
|
True if a sample was successfully recorded, False otherwise. |
Source code in unaiverse/agent.py
1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 | |
connect_by_role
¶
connect_by_role(role: str | list[str], filter_fcn: str | None = None, time: float = -1.0, timeout: float = -1.0)
Finds and attempts to connect with agents whose profiles match a specific role. It can be optionally filtered by a custom function. It returns True if at least one valid agent is found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str | list[str]
|
The role or list of roles to search for. |
required |
filter_fcn
|
str | None
|
The name of an optional filter function. |
None
|
time
|
float
|
The time duration for the action. |
-1.0
|
timeout
|
float
|
The action timeout. |
-1.0
|
Returns:
| Type | Description |
|---|---|
|
True if at least one agent is found and a connection request is made, False otherwise. |
Source code in unaiverse/agent.py
find_agents
¶
Locally searches through the agent's known peers (world and public agents) to find agents with a specific
role. It populates the _found_agents set with the peer IDs of matching agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str | list[str]
|
The role or list of roles to search for. |
required |
engage
|
bool
|
If you want to force the found agents to be the ones that you are engaged with. |
False
|
Returns:
| Type | Description |
|---|---|
|
True if at least one agent is found, False otherwise. |
Source code in unaiverse/agent.py
next_pref_stream
¶
Moves the internal pointer to the next stream in the list of preferred streams, which is often used for playlist-like operations. It wraps around to the beginning if it reaches the end.
Returns:
| Type | Description |
|---|---|
|
True if the move is successful, False if the list is empty. |
Source code in unaiverse/agent.py
first_pref_stream
¶
Resets the internal pointer to the first stream in the list of preferred streams. This is useful for restarting a playback or processing loop.
Returns:
| Type | Description |
|---|---|
|
True if the move is successful, False if the list is empty. |
Source code in unaiverse/agent.py
check_pref_stream
¶
Checks the position of the current preferred stream within the list. It can check if it's the first, last, or if it has completed a full round, among other checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
what
|
str
|
A string specifying the type of check to perform (e.g., 'first', 'last', 'last_round'). |
'last'
|
Returns:
| Type | Description |
|---|---|
|
True if the condition is met, False otherwise. |
Source code in unaiverse/agent.py
set_pref_streams
¶
Fills the agent's list of preferred streams (a playlist). It can repeat the playlist a specified number of times and resolves user-provided stream hashes to their full network hashes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net_hashes
|
list[str]
|
A list of stream hashes to add to the playlist. |
required |
repeat
|
int
|
The number of times to repeat the playlist. |
1
|
Returns:
| Type | Description |
|---|---|
|
Always True. |
Source code in unaiverse/agent.py
evaluate
¶
Evaluates the performance of agents that have completed a generation task. It compares the generated data from each agent with a local stream (which can be a ground truth or reference stream) using a specified comparison method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream_hash
|
str
|
The hash of the local stream to use for comparison. |
required |
how
|
str
|
The name of the comparison method to use. |
required |
steps
|
int
|
The number of steps to perform the evaluation. |
100
|
re_offset
|
bool
|
A boolean to indicate whether to re-offset the streams. |
False
|
Returns:
| Type | Description |
|---|---|
|
True if the evaluation is successful, False otherwise. |
Source code in unaiverse/agent.py
compare_eval
¶
Compares the results of a previous evaluation to a given threshold or finds the best result among all agents. It can check for minimum, maximum, or simple threshold-based comparisons, and it populates a list of 'valid' agents that passed the comparison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmp
|
str
|
The comparison operator (e.g., '<', '>', 'min'). |
required |
thres
|
float
|
The threshold value for comparison. |
required |
good_if_true
|
bool
|
A boolean to invert the pass/fail logic. |
True
|
Returns:
| Type | Description |
|---|---|
|
True if at least one agent passed the comparison, False otherwise. |
Source code in unaiverse/agent.py
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 | |
suggest_role_to_world
¶
Suggests a role change for one or more agents to the world master. It iterates through the involved agents, checks if their current role differs from the suggested one, and sends a role suggestion message to the world master.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str | None
|
The ID of the agent or a wildcard to suggest the role for. |
required |
role
|
str
|
The new role to suggest (as a string). |
required |
Returns:
| Type | Description |
|---|---|
|
True if the suggestion was sent successfully, False otherwise. |
Source code in unaiverse/agent.py
suggest_badges_to_world
¶
suggest_badges_to_world(agent: str | None = None, score: float = -1.0, badge_type: str = 'completed', badge_description: str | None = None)
Suggests one or more badges to the world master for specific agents. This is typically used to reward agents for completing tasks, such as for a competition. It sends a message with the badge details, including the score and type, to the world master.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
str | None
|
The ID of the agent or a wildcard for which to suggest the badge. |
None
|
score
|
float
|
The score associated with the badge. |
-1.0
|
badge_type
|
str
|
The type of badge (e.g., 'completed'). |
'completed'
|
badge_description
|
str | None
|
An optional description for the badge. |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the badge suggestion was sent successfully, False otherwise. |