WiseAgent
Bases: YAMLObject
A WiseAgent is an abstract class that represents an agent that can send and receive messages to and from other agents.
Source code in wiseagents/wise_agent.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
collection_name: str
property
Get the vector DB collection name associated with the agent.
description: str
property
Get a description of what the agent does.
graph_db: Optional[WiseAgentGraphDB]
property
Get the graph DB associated with the agent.
llm: Optional[WiseAgentLLM]
property
Get the LLM associated with the agent.
name: str
property
Get the name of the agent.
system_message: Optional[str]
property
Get the system message associated with the agent.
transport: WiseAgentTransport
property
Get the transport associated with the agent.
vector_db: Optional[WiseAgentVectorDB]
property
Get the vector DB associated with the agent.
__init__(name, description, transport, llm=None, vector_db=None, collection_name='wise-agent-collection', graph_db=None, system_message=None)
Initialize the agent with the given name, description, transport, LLM, vector DB, collection name, and graph DB.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
__new__(*args, **kwargs)
Create a new instance of the class, setting default values for the instance variables.
Source code in wiseagents/wise_agent.py
23 24 25 26 27 28 29 30 31 |
|
__repr__()
Return a string representation of the agent.
Source code in wiseagents/wise_agent.py
71 72 73 74 75 |
|
get_recipient_agent_name(message)
abstractmethod
Get the name of the agent to send the given message to.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
process_error(error)
abstractmethod
Callback method to process the given error.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
process_event(event)
abstractmethod
Callback method to process the given event.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
process_request(message)
abstractmethod
Callback method to process the given request for this agent.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
process_response(message)
abstractmethod
Callback method to process the response received from another agent which processed a request from this agent.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
send_request(message, dest_agent_name)
Send a request message to the destination agent with the given name.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
117 118 119 120 121 122 123 124 125 126 127 |
|
send_response(message, dest_agent_name)
Send a response message to the destination agent with the given name.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
129 130 131 132 133 134 135 136 137 138 139 |
|
startAgent()
Start the agent by setting the call backs and starting the transport.
Source code in wiseagents/wise_agent.py
61 62 63 64 65 |
|
stopAgent()
Stop the agent by stopping the transport and removing the agent from the registry.
Source code in wiseagents/wise_agent.py
66 67 68 69 |
|
WiseAgentContext
Source code in wiseagents/wise_agent.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 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 486 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 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 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 |
|
llm_available_tools_in_chat: Dict[str, List[ChatCompletionToolParam]]
property
Get the LLM available tools in chat of the context.
llm_chat_completion: Dict[str, List[ChatCompletionMessageParam]]
property
Get the LLM chat completion of the context.
llm_required_tool_call: Dict[str, List[str]]
property
Get the LLM required tool call of the context. return Dict[str, List[str]]
message_trace: List[WiseAgentMessage]
property
Get the message trace of the context.
name: str
property
Get the name of the context.
participants: List[WiseAgent]
property
Get the participants of the context.
__init__(name)
Initialize the context with the given name.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
332 333 334 335 336 337 338 |
|
add_participant(agent)
Add a participant to the context.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
359 360 361 362 363 364 365 366 |
|
add_query(chat_uuid, query)
Add the current query for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
634 635 636 637 638 639 640 641 642 643 644 |
|
append_available_tool_in_chat(chat_uuid, tools)
Append available tool in chat to the context.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
422 423 424 425 426 427 428 429 430 |
|
append_chat_completion(chat_uuid, messages)
Append chat completion to the context.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
368 369 370 371 372 373 374 375 376 377 |
|
append_required_tool_call(chat_uuid, tool_name)
Append required tool call to the context.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
385 386 387 388 389 390 391 392 393 |
|
get_agent_phase_assignments(chat_uuid)
Get the agents to be executed in each phase for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
get_agents_for_next_phase(chat_uuid)
Get the list of agents to be executed for the next phase for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
|
get_agents_sequence(chat_uuid)
Get the sequence of agents for the given chat uuid for this context. This is used by a sequential coordinator to execute its agents in a specific order, passing the output from one agent in the sequence to the next agent in the sequence.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
|
get_available_tools_in_chat(chat_uuid)
Get available tools in chat from the context.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
432 433 434 435 436 437 438 439 440 441 |
|
get_current_phase(chat_uuid)
Get the current phase for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
547 548 549 550 551 552 553 554 555 556 557 |
|
get_current_query(chat_uuid)
Get the current query for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
|
get_next_agent_in_sequence(chat_uuid, current_agent)
Get the name of the next agent in the sequence of agents for the given chat uuid for this context. This is used by a sequential coordinator to determine the name of the next agent to execute.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
|
get_queries(chat_uuid)
Get the queries attempted for the given chat uuid for this context. This is used by a phased coordinator.
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
646 647 648 649 650 651 652 653 654 655 656 |
|
get_required_agents_for_current_phase(chat_uuid)
Get the list of agents that still need to be executed for the current phase for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
|
get_required_tool_calls(chat_uuid)
Get required tool calls from the context.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
406 407 408 409 410 411 412 413 414 415 |
|
get_route_response_to(chat_uuid)
Get the name of the agent where the final response should be routed to for the given chat uuid for this context. This is used by a sequential coordinator and a phased coordinator.
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
471 472 473 474 475 476 477 478 479 480 481 482 |
|
remove_required_agent_for_current_phase(chat_uuid, agent_name)
Remove the given agent from the list of required agents for the current phase for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
605 606 607 608 609 610 611 612 613 614 615 |
|
remove_required_tool_call(chat_uuid, tool_name)
Remove required tool call from the context.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
395 396 397 398 399 400 401 402 403 404 |
|
set_agent_phase_assignments(chat_uuid, agent_phase_assignments)
Set the agents to be executed in each phase for the given chat uuid for this context. This is used by a phased coordinator.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
534 535 536 537 538 539 540 541 542 543 544 545 |
|
set_agents_sequence(chat_uuid, agents_sequence)
Set the sequence of agents for the given chat uuid for this context. This is used by a sequential coordinator to execute its agents in a specific order, passing the output from one agent in the sequence to the next agent in the sequence.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
459 460 461 462 463 464 465 466 467 468 469 |
|
set_current_phase(chat_uuid, phase)
Set the current phase for the given chat uuid for this context. This method also sets the required agents for the current phase. This is used by a phased coordinator.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
559 560 561 562 563 564 565 566 567 568 569 |
|
set_route_response_to(chat_uuid, agent)
Set the name of the agent where the final response should be routed to for the given chat uuid for this context. This is used by a sequential coordinator and a phased coordinator.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
484 485 486 487 488 489 490 491 492 493 |
|
WiseAgentEvent
TODO
Source code in wiseagents/wise_agent_messaging.py
18 19 20 21 |
|
WiseAgentMessage
Bases: YAMLObject
A message that can be sent between agents.
Source code in wiseagents/wise_agent_messaging.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
chat_id: str
property
Get the id of the message.
context_name: str
property
Get the context name of the message.
message: str
property
Get the message contents (a natural language string).
message_type: WiseAgentMessageType
property
Get the type of the message (or None if the type was not specified).
route_response_to: str
property
Get the id of the tool.
sender: str
property
writable
Get the sender of the message (or None if the sender was not specified).
tool_id: str
property
Get the id of the tool.
__init__(message, sender=None, message_type=None, chat_id=None, tool_id=None, context_name=None, route_response_to=None)
Initialize the message.
Parameters: |
|
---|
Source code in wiseagents/wise_agent_messaging.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
WiseAgentRegistry
A Registry to get available agents and running contexts
Source code in wiseagents/wise_agent.py
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 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 |
|
clear_agents()
classmethod
Clear all agents from the registry
Source code in wiseagents/wise_agent.py
734 735 736 737 738 739 |
|
clear_contexts()
classmethod
Clear all contexts from the registry
Source code in wiseagents/wise_agent.py
741 742 743 744 745 746 |
|
does_context_exist(context_name)
classmethod
Get the context with the given name
Source code in wiseagents/wise_agent.py
710 711 712 713 714 715 716 717 718 |
|
get_agent(agent_name)
classmethod
Get the agent with the given name
Source code in wiseagents/wise_agent.py
694 695 696 697 698 699 |
|
get_agent_names_and_descriptions()
classmethod
Get the list of agent names and descriptions.
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
769 770 771 772 773 774 775 776 777 778 779 780 781 |
|
get_agents()
classmethod
Get the list of agents
Source code in wiseagents/wise_agent.py
680 681 682 683 684 685 |
|
get_contexts()
classmethod
Get the list of contexts
Source code in wiseagents/wise_agent.py
687 688 689 690 691 692 |
|
get_or_create_context(context_name)
classmethod
Get the context with the given name
Source code in wiseagents/wise_agent.py
701 702 703 704 705 706 707 708 |
|
get_tool(tool_name)
classmethod
Get the tool with the given name
Source code in wiseagents/wise_agent.py
762 763 764 765 766 767 |
|
get_tools()
classmethod
Get the list of tools
Source code in wiseagents/wise_agent.py
755 756 757 758 759 760 |
|
register_agent(agent)
classmethod
Register an agent with the registry
Source code in wiseagents/wise_agent.py
668 669 670 671 672 673 |
|
register_context(context)
classmethod
Register a context with the registry
Source code in wiseagents/wise_agent.py
674 675 676 677 678 679 |
|
register_tool(tool)
classmethod
Register a tool with the registry
Source code in wiseagents/wise_agent.py
748 749 750 751 752 753 |
|
remove_agent(agent_name)
classmethod
Remove the agent from the registry
Source code in wiseagents/wise_agent.py
720 721 722 723 724 725 |
|
remove_context(context_name)
classmethod
Remove the context from the registry
Source code in wiseagents/wise_agent.py
727 728 729 730 731 732 |
|
WiseAgentTool
Bases: YAMLObject
A WiseAgentTool is an abstract class that represents a tool that can be used by an agent to perform a specific task.
Source code in wiseagents/wise_agent.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
call_back: Callable[..., str]
property
Get the callback function of the tool.
description: str
property
Get the description of the tool.
is_agent_tool: bool
property
Get the agent tool of the tool.
json_schema: dict
property
Get the json schema of the tool.
name: str
property
Get the name of the tool.
__init__(name, description, agent_tool, parameters_json_schema={}, call_back=None)
Initialize the tool with the given name, description, agent tool, parameters json schema, and call back.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
default_call_back(**kwargs)
The tool should be able to execute the function with the given parameters
Source code in wiseagents/wise_agent.py
280 281 282 |
|
exec(**kwargs)
The tool should be able to execute the function with the given parameters
Source code in wiseagents/wise_agent.py
284 285 286 287 288 |
|
from_yaml(loader, node)
classmethod
Load the tool from a YAML node.
Parameters: |
|
---|
Source code in wiseagents/wise_agent.py
231 232 233 234 235 236 237 238 239 240 241 |
|
get_tool_OpenAI_format()
The tool should be able to return itself in the form of a ChatCompletionToolParam
Returns: |
|
---|
Source code in wiseagents/wise_agent.py
267 268 269 270 271 272 273 274 275 276 277 278 |
|
WiseAgentTransport
Bases: YAMLObject
A transport for sending messages between agents.
Source code in wiseagents/wise_agent_messaging.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
error_receiver: Optional[Callable[[], WiseAgentMessage]]
property
Get the error receiver callback.
event_receiver: Optional[Callable[[], WiseAgentEvent]]
property
Get the event receiver callback.
request_receiver: Optional[Callable[[], WiseAgentMessage]]
property
Get the message receiver callback.
response_receiver: Optional[Callable[[], WiseAgentMessage]]
property
Get the response receiver callback.
send_request(message, dest_agent_name)
Send a request message to an agent.
Parameters: |
|
---|
Source code in wiseagents/wise_agent_messaging.py
123 124 125 126 127 128 129 130 131 132 |
|
send_response(message, dest_agent_name)
Send a request message to an agent.
Parameters: |
|
---|
Source code in wiseagents/wise_agent_messaging.py
134 135 136 137 138 139 140 141 142 143 |
|
set_call_backs(request_receiver=None, event_receiver=None, error_receiver=None, response_receiver=None)
Set the call back functions for the transport.
Parameters: |
|
---|
Source code in wiseagents/wise_agent_messaging.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
start()
Start the transport.
Source code in wiseagents/wise_agent_messaging.py
116 117 118 119 120 121 |
|
stop()
Stop the transport.
Source code in wiseagents/wise_agent_messaging.py
145 146 147 148 149 150 |
|