Assistants Module
The assistants module provides functionality for creating, managing, and interacting with Forra assistants.
AssistantsAPI
Source code in forrasdk/api/assistants.py
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 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 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 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 | |
add_skill(assistant_id, skill_id)
Add a GLOBAL skill to a specific assistant.
The skill must be GLOBAL-scoped and already exist. Only the assistant owner or collaborators can add skills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
skill_id
|
str
|
The ID of the GLOBAL skill to add. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantSkillResponse |
AssistantSkillResponse
|
The response from the API after adding the skill. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the skill doesn't exist, is not GLOBAL-scoped, or the user doesn't have permission. |
Source code in forrasdk/api/assistants.py
automations(assistant_id)
Get automations API for a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AutomationsForAssistantAPI |
list[AutomationResponse]
|
An API client configured for the specific assistant's automations. |
Source code in forrasdk/api/assistants.py
create(name, description, instructions, use_system_prompt=True, prompt_starters=None, visibility_type='private', avatar_url=None, allowed_functions=None, variables=None, secrets=None, allowed_external_services=None, ui_url=None, type=None, delegations=None)
Create a new assistant in the Scout API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the assistant. |
required |
description
|
str
|
A brief description of the assistant. |
required |
instructions
|
str
|
Instructions or system prompt for the assistant. |
required |
use_system_prompt
|
bool
|
Whether to use the system prompt of the scout instance. |
True
|
prompt_starters
|
Optional[list[str]]
|
List of prompt starters for the assistant. Defaults to None. |
None
|
visibility_type
|
str
|
Visibility type for the assistant (e.g., "private", "public"). Defaults to "private". |
'private'
|
avatar_url
|
Optional[str]
|
URL to the assistant's avatar image. Defaults to None. |
None
|
allowed_functions
|
Optional[list[str]]
|
List of allowed function names. None = Use all available tools, Empty list = No tools. |
None
|
variables
|
Optional[dict[str, str]]
|
Variables to include with the assistant. Defaults to None. |
None
|
secrets
|
Optional[dict[str, str]]
|
Secrets to include with the assistant. Defaults to None. |
None
|
allowed_external_services
|
Optional[list[str]]
|
List of allowed external services. None = Use all available tools, Empty list = No tools. |
None
|
ui_url
|
Optional[str]
|
URL for the assistant's UI. Defaults to None. |
None
|
type
|
Optional[str]
|
The type of assistant (e.g., "ASSISTANT", "MICRO_APP"). Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AssistantResponse |
AssistantInfoResponse
|
The response from the Scout API after creating the assistant. |
Source code in forrasdk/api/assistants.py
create_data(assistant_id, data)
Create new data entries for a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to which the data will be added. |
required |
data
|
AssistantData | AssistantDataList
|
A single AssistantData instance or an AssistantDataList containing multiple entries. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CreateAssistantDataResponse |
CreateAssistantDataResponse
|
Response containing created item IDs. |
Source code in forrasdk/api/assistants.py
delete(assistant_id)
Delete an assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantDeleteResponse |
AssistantDeleteResponse
|
The response from the Scout API after deleting the assistant. |
Source code in forrasdk/api/assistants.py
delete_data(assistant_id, id=None, where=None)
Delete assistant data by ID or matching criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
id
|
Optional[str]
|
The ID of the data entry to delete. Defaults to None. |
None
|
where
|
Optional[dict]
|
Criteria to match data entries for deletion. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither 'id' nor 'where' is provided. |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantDataMessageResponse |
DeleteAssistantDataResponse
|
The response from the API after deleting the data. |
Source code in forrasdk/api/assistants.py
delete_file(assistant_id, file_uid)
Delete a file associated with a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
file_uid
|
str
|
The unique identifier of the file to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantResponse |
AssistantResponse
|
The response object after deleting the assistant's file. |
Source code in forrasdk/api/assistants.py
edit_file(assistant_id, file_uid, filename='Default', description=None)
Edit the metadata of a file associated with a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
file_uid
|
str
|
The unique identifier of the file to edit. |
required |
filename
|
str
|
The new name for the file. Defaults to "Default". |
'Default'
|
description
|
Optional[str]
|
The new description for the file. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AssistantFileEditResponse |
AssistantFileEditResponse
|
The response from the Scout API after updating the file information. |
Source code in forrasdk/api/assistants.py
execute_function(assistant_id, function_name, payload, response_model=None, conversation_id=None, delay_in_seconds=None)
Execute a specific function for an assistant and return the response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
function_name
|
str
|
The name of the function to execute. |
required |
payload
|
dict
|
The payload (paramet ers) to send to the function. |
required |
response_model
|
Optional[Type[ExecuteFunctionResponseType]]
|
The expected response model type for validation. Defaults to None. |
None
|
conversation_id
|
Optional[str]
|
The ID of the conversation to execute the function in. Defaults to None. |
None
|
delay_in_seconds
|
Optional[int]
|
The delay in seconds to wait before running the function. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
ExecuteFunctionResponseType | dict[str, Any] | str
|
ResponseType | dict[str, Any]: The response from the API. If response_model is provided, returns the validated model instance. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the response is not valid according to the response_model. |
Examples:
Direct response with model validation and type checking:
result: MyModel = api.execute_function("assistant_id", "function_name", {}, MyModel)
Raw response without model validation:
raw_data: dict[str, Any] = api.execute_function("assistant_id", "function_name", {})
Source code in forrasdk/api/assistants.py
get(assistant_id)
Retrieve a specific assistant by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantInfoResponse |
AssistantInfoResponse
|
The assistant object retrieved from the API. |
Source code in forrasdk/api/assistants.py
get_functions(assistant_id)
Retrieve custom functions for a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant whose functions are to be retrieved. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantCustomFunctionsResponse |
AssistantCustomFunctionsResponse
|
The custom functions for the assistant. |
Source code in forrasdk/api/assistants.py
get_public(assistant_id)
Retrieve a public assistant by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantPublicResponse |
AssistantPublicResponse
|
The public assistant object retrieved from the API. |
Source code in forrasdk/api/assistants.py
list_all()
Retrieve a list of all assistants the token has access to.
Returns:
| Type | Description |
|---|---|
List[AssistantPublicResponse]
|
List[AssistantPublicResponse]: A list of assistant objects retrieved from the API. |
Source code in forrasdk/api/assistants.py
list_files(assistant_id)
Retrieve a list of files associated with a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant whose files are to be listed. |
required |
Returns:
| Type | Description |
|---|---|
list[AssistantFile]
|
list[AssistantFile]: A list of AssistantFile objects representing the files associated with the assistant. |
Source code in forrasdk/api/assistants.py
list_skills(assistant_id)
Retrieve all skills associated with a specific assistant.
This includes both ASSISTANT-scoped skills (owned by the assistant) and GLOBAL-scoped skills (shared across assistants).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant whose skills are to be listed. |
required |
Returns:
| Type | Description |
|---|---|
list[SkillResponse]
|
list[SkillResponse]: A list of skills associated with the assistant. |
Source code in forrasdk/api/assistants.py
permanently_delete(assistant_id)
Permanently delete an assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to permanently delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantDeleteResponse |
AssistantDeleteResponse
|
The response from the Scout API after permanently deleting the assistant. |
Source code in forrasdk/api/assistants.py
query_data(assistant_id, where)
Query assistant data matching specific criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant whose data will be queried. |
required |
where
|
dict
|
Dictionary specifying query filters. Ex: {"field": "search_value"} |
required |
Returns:
| Type | Description |
|---|---|
List[AssistantDataResponseItem]
|
List[AssistantDataQueryItem]: A list of data entries matching the query. |
Source code in forrasdk/api/assistants.py
remove_skill(assistant_id, skill_id)
Remove a skill from a specific assistant.
The behavior depends on the skill's scope: - GLOBAL skills: Only the association is removed (skill remains available for other assistants) - ASSISTANT skills: The skill is deleted entirely (it's owned by this assistant)
Only the assistant owner or collaborators can remove skills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
skill_id
|
str
|
The ID of the skill to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantSkillResponse |
AssistantSkillResponse
|
The response from the API after removing the skill. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the skill doesn't exist or the user doesn't have permission. |
Source code in forrasdk/api/assistants.py
search_data(assistant_id, query, strategy=None, where=None, exact_match=False)
Search the assistant's data with a given query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant whose data is to be searched. |
required |
query
|
str
|
The search query string. |
required |
strategy
|
Optional[dict]
|
The search strategy to use. Defaults to None. |
None
|
where
|
Optional[dict]
|
Additional filtering criteria. Defaults to None. Ex: {"field": "value"} |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[AssistantSearchDataResponse]
|
A list of search results from the assistant's data. |
Source code in forrasdk/api/assistants.py
set_catalog_metadata(assistant_id, catalog_package_id, catalog_package_version)
Set catalog metadata for an assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to update. |
required |
catalog_package_id
|
str
|
The catalog package identifier (e.g. "org/package-name"). |
required |
catalog_package_version
|
str
|
The catalog package version string. |
required |
Returns:
| Type | Description |
|---|---|
AssistantInfoResponse
|
The updated AssistantInfoResponse. |
Source code in forrasdk/api/assistants.py
update_data(assistant_id, data_id, metadata, content, embedding=None)
Update an existing data entry for a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
data_id
|
str
|
The ID of the data entry to update. |
required |
metadata
|
dict
|
Updated metadata for the data entry. |
required |
content
|
str
|
Updated content for the data entry. |
required |
embedding
|
Optional[list]
|
Updated embedding for the data entry. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AssistantDataMessageResponse |
AssistantDataUpdateResponse
|
The response from the API after updating the data. |
Source code in forrasdk/api/assistants.py
update_datas(assistant_id, metadata, where)
Bulk Update all assistant metadata matching condition
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant. |
required |
metadata
|
dict
|
Metadata to add/modify or remove (when value is null) for all matching entity. |
required |
where
|
dict
|
Criteria to match data entries |
required |
Returns: AssistantDataMessageResponse: The response from the API after updating the data.
Source code in forrasdk/api/assistants.py
upload_avatar(assistant_id, file_path)
Upload an avatar image for a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to upload the avatar for. |
required |
file_path
|
str
|
The local file path to the avatar image. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AssistantUploadImageResponse |
AssistantUploadImageResponse
|
The response object containing information about the uploaded avatar. |
Raises:
| Type | Description |
|---|---|
Exception
|
If there is an error during the file upload process. |
Source code in forrasdk/api/assistants.py
upload_file(assistant_id, file_path, file_type=None)
Upload a file to a specific assistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assistant_id
|
str
|
The ID of the assistant to upload the file for. |
required |
file_path
|
str
|
The local file path to the file to upload. |
required |
file_type
|
Optional[FileType]
|
The type of file to upload. Defaults to FileType.KNOWLEDGE. Valid values: FileType.KNOWLEDGE, FileType.CUSTOM_FUNCTIONS, FileType.ASSISTANT_TEMPLATES, FileType.SHARED_CUSTOM_FUNCTIONS, FileType.ASSET |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AssistantFileUploadResponse |
AssistantFileUploadResponse
|
The response object containing information about the uploaded file. |
Raises:
| Type | Description |
|---|---|
Exception
|
If there is an error during the file upload process. |