Agent¶
Contained within this file are experimental interfaces for working with the Synapse Python Client. Unless otherwise noted these interfaces are subject to change at any time. Use at your own risk.
API reference¶
synapseclient.models.Agent
dataclass
¶
Bases: AgentSynchronousProtocol
Represents a Synapse Agent Registration
ATTRIBUTE | DESCRIPTION |
---|---|
cloud_agent_id |
The unique ID of the agent in the cloud provider. |
cloud_alias_id |
The alias ID of the agent in the cloud provider. Defaults to 'TSTALIASID' in the Synapse API. |
registration_id |
The ID number of the agent assigned by Synapse. |
registered_on |
The date the agent was registered. |
type |
The type of agent.
TYPE:
|
sessions |
A dictionary of AgentSession objects, keyed by session ID.
TYPE:
|
current_session |
The current session. Prompts will be sent to this session by default.
TYPE:
|
Chat with the baseline Synapse Agent
You can chat with the same agent which is available in the Synapse UI at https://www.synapse.org/Chat:default. By default, this "baseline" agent is used when a registration ID is not provided. In the background, the Agent class will start a session and set that new session as the current session if one is not already set.
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
my_agent = Agent()
my_agent.prompt(
prompt="Can you tell me about the AD Knowledge Portal dataset?",
enable_trace=True,
print_response=True,
)
Register and chat with a custom agent
Only available for internal users (Sage Bionetworks employees)
Alternatively, you can register a custom agent and chat with it provided you have already created it.
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
my_agent = Agent(cloud_agent_id="foo")
my_agent.register()
my_agent.prompt(
prompt="Hello",
enable_trace=True,
print_response=True,
)
Get and chat with an existing agent
Retrieve an existing agent by providing the agent's registration ID and calling get()
.
Then, send a prompt to the agent.
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
my_agent = Agent(registration_id="foo").get()
my_agent.prompt(
prompt="Hello",
enable_trace=True,
print_response=True,
)
Start and prompt multiple sessions
Here, we connect to a custom agent and start one session with the prompt "Hello".
In the background, this first session is being set as the current session
and future prompts will be sent to this session by default. If we want to send a
prompt to a different session, we can do so by starting it and calling prompt again,
but with our new session as an argument. We now have two sessions, both stored in the
my_agent.sessions
dictionary. After the second prompt, my_second_session
is now
the current session.
syn = Synapse()
syn.login()
my_agent = Agent(registration_id="foo").get()
my_agent.prompt(
prompt="Hello",
enable_trace=True,
print_response=True,
)
my_second_session = my_agent.start_session()
my_agent.prompt(
prompt="Hello again",
enable_trace=True,
print_response=True,
session=my_second_session,
)
Source code in synapseclient/models/agent.py
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 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 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
|
Functions¶
register_async
async
¶
Registers an agent with the Synapse API. If agent already exists, it will be retrieved.
PARAMETER | DESCRIPTION |
---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
Agent
|
The registered or existing Agent object. |
Register and chat with a custom agent
Only available for internal users (Sage Bionetworks employees)
Alternatively, you can register a custom agent and chat with it provided you have already created it.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_agent = Agent(cloud_agent_id="foo")
await my_agent.register_async()
await my_agent.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
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 |
|
get_async
async
¶
Gets an existing custom agent. There is no need to use this method if you are trying to use the baseline agent.
PARAMETER | DESCRIPTION |
---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
Agent
|
The existing Agent object. |
Get and chat with an existing agent
Retrieve an existing custom agent by providing the agent's registration ID and calling get_async()
.
Then, send a prompt to the agent.
import asyncio
from synapseclient import Synapse
from synapseclient.models import Agent, AgentSessionAccessLevel
syn = Synapse()
syn.login()
async def main():
my_agent = await Agent(registration_id="foo").get_async()
await my_agent.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
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 |
|
start_session_async
async
¶
start_session_async(access_level: Optional[AgentSessionAccessLevel] = PUBLICLY_ACCESSIBLE, *, synapse_client: Optional[Synapse] = None) -> AgentSession
Starts an agent session. Adds the session to the Agent's sessions dictionary and sets it as the current session.
PARAMETER | DESCRIPTION |
---|---|
access_level
|
The access level of the agent session. Must be one of PUBLICLY_ACCESSIBLE, READ_YOUR_PRIVATE_DATA, or WRITE_YOUR_PRIVATE_DATA. Defaults to PUBLICLY_ACCESSIBLE.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
AgentSession
|
The new AgentSession object. |
Start a session and send a prompt with the baseline Synapse Agent.
The baseline Synapse Agent is the default agent used when a registration ID is not provided.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_agent = Agent()
await my_agent.start_session_async()
await my_agent.prompt_async(
prompt="Can you tell me about the AD Knowledge Portal dataset?",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Start a session and send a prompt with a custom agent.
The baseline Synapse Agent is the default agent used when a registration ID is not provided.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_agent = Agent(cloud_agent_id="foo")
await my_agent.start_session_async()
await my_agent.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
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 |
|
get_session_async
async
¶
get_session_async(session_id: str, *, synapse_client: Optional[Synapse] = None) -> AgentSession
Gets an existing agent session. Adds the session to the Agent's sessions dictionary and sets it as the current session.
PARAMETER | DESCRIPTION |
---|---|
session_id
|
The ID of the session to get.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
AgentSession
|
The existing AgentSession object. |
Get an existing session and send a prompt.
Retrieve an existing session by providing the session ID and calling get()
.
Then, send a prompt to the agent.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_session = await Agent().get_session_async(session_id="foo")
await my_session.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
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 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
|
prompt_async
async
¶
prompt_async(prompt: str, enable_trace: bool = False, print_response: bool = False, session: Optional[AgentSession] = None, newer_than: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> AgentPrompt
Sends a prompt to the agent for the current session. If no session is currently active, a new session will be started.
PARAMETER | DESCRIPTION |
---|---|
prompt
|
The prompt to send to the agent.
TYPE:
|
enable_trace
|
Whether to enable trace for the prompt.
TYPE:
|
print_response
|
Whether to print the response to the console.
TYPE:
|
session_id
|
The ID of the session to send the prompt to. If None, the current session will be used.
|
newer_than
|
The timestamp to get trace results newer than. Defaults to None (all results). |
synapse_client
|
If not passed in and caching was not disabled by
|
Prompt the baseline Synapse Agent.
The baseline Synapse Agent is equivilent to the Agent available in the Synapse UI.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_agent = Agent()
await my_agent.prompt_async(
prompt="Can you tell me about the AD Knowledge Portal dataset?",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Prompt a custom agent.
If you have already registered a custom agent, you can prompt it by providing the agent's registration ID.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_agent = Agent(registration_id="foo")
await my_agent.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Start and prompt multiple sessions
Here, we connect to a custom agent and start one session with the prompt "Hello".
In the background, this first session is being set as the current session
and future prompts will be sent to this session by default. If we want to send a
prompt to a different session, we can do so by starting it and calling prompt again,
but with our new session as an argument. We now have two sessions, both stored in the
my_agent.sessions
dictionary. After the second prompt, my_second_session
is now
the current session.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_agent = Agent(registration_id="foo").get()
await my_agent.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
my_second_session = await my_agent.start_session_async()
await my_agent.prompt_async(
prompt="Hello again",
enable_trace=True,
print_response=True,
session=my_second_session,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
|
get_chat_history
¶
get_chat_history() -> Union[List[AgentPrompt], None]
Gets the chat history for the current session.
Get the chat history for the current session.
First, send a prompt to the agent.
Then, retrieve the chat history for the current session by calling get_chat_history()
.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import Agent
syn = Synapse()
syn.login()
async def main():
my_agent = Agent()
await my_agent.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
print(my_agent.get_chat_history())
asyncio.run(main())
Source code in synapseclient/models/agent.py
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
|
synapseclient.models.AgentSession
dataclass
¶
Bases: AgentSessionSynchronousProtocol
Represents a Synapse Agent Session
ATTRIBUTE | DESCRIPTION |
---|---|
id |
The unique ID of the agent session. Can only be used by the user that created it. |
access_level |
The access level of the agent session. One of PUBLICLY_ACCESSIBLE, READ_YOUR_PRIVATE_DATA, or WRITE_YOUR_PRIVATE_DATA.
TYPE:
|
started_on |
The date the agent session was started. |
started_by |
The ID of the user who started the agent session. |
modified_on |
The date the agent session was last modified. |
agent_registration_id |
The registration ID of the agent that will be used for this session. |
etag |
The etag of the agent session. |
Note: It is recommended to use the Agent
class to conduct chat sessions,
but you are free to use AgentSession directly if you wish.
Start a session and send a prompt.
Start a session with a custom agent by providing the agent's registration ID and calling start()
.
Then, send a prompt to the agent.
from synapseclient import Synapse
from synapseclient.models.agent import AgentSession
syn = Synapse()
syn.login()
my_session = AgentSession(agent_registration_id="foo").start()
my_session.prompt(
prompt="Hello",
enable_trace=True,
print_response=True,
)
Get an existing session and send a prompt.
Retrieve an existing session by providing the session ID and calling get()
.
Then, send a prompt to the agent.
from synapseclient import Synapse
from synapseclient.models.agent import AgentSession
syn = Synapse()
syn.login()
my_session = AgentSession(id="foo").get()
my_session.prompt(
prompt="Hello",
enable_trace=True,
print_response=True,
)
Update the access level of an existing session.
Retrieve an existing session by providing the session ID and calling get()
.
Then, update the access level of the session and call update()
.
from synapseclient import Synapse
from synapseclient.models.agent import AgentSession, AgentSessionAccessLevel
syn = Synapse()
syn.login()
my_session = AgentSession(id="foo").get()
my_session.access_level = AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA
my_session.update()
Source code in synapseclient/models/agent.py
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 210 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 289 290 291 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 |
|
Functions¶
start_async
async
¶
start_async(*, synapse_client: Optional[Synapse] = None) -> AgentSession
Starts an agent session.
PARAMETER | DESCRIPTION |
---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
AgentSession
|
The new AgentSession object. |
Start a session and send a prompt.
Start a session with a custom agent by providing the agent's registration ID and calling start()
.
Then, send a prompt to the agent.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import AgentSession
syn = Synapse()
syn.login()
async def main():
my_session = await AgentSession(agent_registration_id="foo").start_async()
await my_session.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
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 289 |
|
get_async
async
¶
get_async(*, synapse_client: Optional[Synapse] = None) -> AgentSession
Gets an agent session.
PARAMETER | DESCRIPTION |
---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
AgentSession
|
The retrieved AgentSession object. |
Get an existing session and send a prompt.
Retrieve an existing session by providing the session ID and calling get()
.
Then, send a prompt to the agent.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import AgentSession
syn = Synapse()
syn.login()
async def main():
my_session = await AgentSession(id="foo").get_async()
await my_session.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
291 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 |
|
update_async
async
¶
update_async(*, synapse_client: Optional[Synapse] = None) -> AgentSession
Updates an agent session. Only updates to the access level are currently supported.
PARAMETER | DESCRIPTION |
---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
AgentSession
|
The updated AgentSession object. |
Update the access level of an existing session.
Retrieve an existing session by providing the session ID and calling get()
.
Then, update the access level of the session and call update()
.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import AgentSession, AgentSessionAccessLevel
syn = Synapse()
syn.login()
async def main():
my_session = await AgentSession(id="foo").get_async()
my_session.access_level = AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA
await my_session.update_async()
asyncio.run(main())
Source code in synapseclient/models/agent.py
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 |
|
prompt_async
async
¶
prompt_async(prompt: str, enable_trace: bool = False, print_response: bool = False, newer_than: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> AgentPrompt
Sends a prompt to the agent and adds the response to the AgentSession's chat history. A session must be started before sending a prompt.
PARAMETER | DESCRIPTION |
---|---|
prompt
|
The prompt to send to the agent.
TYPE:
|
enable_trace
|
Whether to enable trace for the prompt.
TYPE:
|
print_response
|
Whether to print the response to the console.
TYPE:
|
newer_than
|
The timestamp to get trace results newer than. Defaults to None (all results). |
synapse_client
|
If not passed in and caching was not disabled by
|
Send a prompt within an existing session.
Retrieve an existing session by providing the session ID and calling get()
.
Then, send a prompt to the agent.
import asyncio
from synapseclient import Synapse
from synapseclient.models.agent import AgentSession
syn = Synapse()
syn.login()
async def main():
my_session = await AgentSession(id="foo").get_async()
await my_session.prompt_async(
prompt="Hello",
enable_trace=True,
print_response=True,
)
asyncio.run(main())
Source code in synapseclient/models/agent.py
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 |
|
synapseclient.models.AgentPrompt
dataclass
¶
Bases: AsynchronousCommunicator
Represents a prompt, response, and metadata within an AgentSession.
ATTRIBUTE | DESCRIPTION |
---|---|
id |
The unique ID of the agent prompt. |
session_id |
The ID of the session that the prompt is associated with. |
prompt |
The prompt to send to the agent. |
response |
The response from the agent. |
enable_trace |
Whether tracing is enabled for the prompt. |
trace |
The trace of the agent session. |
Source code in synapseclient/models/agent.py
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 |
|
Functions¶
send_job_and_wait_async
async
¶
send_job_and_wait_async(post_exchange_args: Optional[Dict[str, Any]] = None, *, synapse_client: Optional[Synapse] = None) -> AsynchronousCommunicator
Send the job to the Asynchronous Job service and wait for it to complete. Intended to be called by a class inheriting from this mixin to start a job in the Synapse API and wait for it to complete. The inheriting class needs to represent an asynchronous job request and response and include all necessary attributes. This was initially implemented to be used in the AgentPrompt class which can be used as an example.
PARAMETER | DESCRIPTION |
---|---|
post_exchange_args
|
Additional arguments to pass to the request. |
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
AsynchronousCommunicator
|
An instance of this class. |
Using this function
This function was initially implemented to be used in the AgentPrompt class to send a prompt to an AI agent and wait for the response. It can also be used in any other class that needs to use an Asynchronous Job.
The inheriting class (AgentPrompt) will typically not be used directly, but rather through a higher level class (AgentSession), but this example shows how you would use this function.
from synapseclient import Synapse
from synapseclient.models.agent import AgentPrompt
syn = Synapse()
syn.login()
agent_prompt = AgentPrompt(
id=None,
session_id="123",
prompt="Hello",
response=None,
enable_trace=True,
trace=None,
)
# This will fill the id, response, and trace
# attributes with the response from the API
agent_prompt.send_job_and_wait_async()
Source code in synapseclient/models/mixins/asynchronous_job.py
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 |
|