Preprocessor
delete_preprocessed_collection(collection_name, client_manager=None)
Delete a preprocessed collection. This function allows you to delete the preprocessing done for a particular collection. It does so by deleting the object in the ELYSIA_METADATA__ collection with the name of the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to delete. |
required |
client_manager
|
ClientManager
|
The client manager to use. |
None
|
Source code in elysia/preprocess/collection.py
delete_preprocessed_collection_async(collection_name, client_manager=None)
async
Delete the preprocessed collection from the Weaviate cluster. This function simply deletes the cached preprocessed metadata from the Weaviate cluster. It does so by deleting the object in the collection ELYSIA_METADATA__ with the name of the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to delete the preprocessed metadata for. |
required |
client_manager
|
ClientManager
|
The client manager to use. If not provided, a new ClientManager will be created using the environment variables/configured settings. |
None
|
Source code in elysia/preprocess/collection.py
edit_preprocessed_collection(collection_name, client_manager=None, named_vectors=None, summary=None, mappings=None, fields=None)
Edit a preprocessed collection.
This function allows you to edit the named vectors, summary, mappings, and fields of a preprocessed collection.
It does so by updating the ELYSIA_METADATA__ collection.
Find available mappings in the elysia.util.return_types
module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to edit. |
required |
client_manager
|
ClientManager
|
The client manager to use. If not provided, a new ClientManager will be created using the environment variables/configured settings. |
None
|
named_vectors
|
list[dict]
|
The named vectors to update. This has fields "name", "enabled", and "description". The "name" is used to identify the named vector to change (the name will not change). Set "enabled" to True/False to enable/disable the named vector. Set "description" to describe the named vector. The description of named vectors is not automatically generated by the LLM. Any named vectors that are not provided will not be updated. If None or not provided, the named vectors will not be updated. |
None
|
summary
|
str
|
The summary to update. The summary is a short description of the collection, generated by the LLM. This will replace the existing summary of the collection. If None or not provided, the summary will not be updated. |
None
|
mappings
|
dict
|
The mappings to update. The mappings are what the frontend will use to display the collection, and the associated fields. I.e., which fields correspond to which output fields on the frontend. The keys of the outer level of the dictionary are the mapping names, the values are dictionaries with the mappings. The inner dictionary has the keys as the collection fields, and the values as the frontend fields. If None or not provided, the mappings will not be updated. |
None
|
fields
|
list[dict]
|
The fields to update. Each element in the list is a dictionary with the following fields: - "name": The name of the field. (This is used to identify the field to change, the name will not change). - "description": The description of the field to update. Any fields that are not provided will not be updated. If None or not provided, the fields will not be updated. |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
None
|
The updated preprocessed collection. |
Source code in elysia/preprocess/collection.py
edit_preprocessed_collection_async(collection_name, client_manager=None, named_vectors=None, summary=None, mappings=None, fields=None)
async
Async version of edit_preprocessed_collection
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to edit. |
required |
client_manager
|
ClientManager
|
The client manager to use. If not provided, a new ClientManager will be created using the environment variables/configured settings. |
None
|
named_vectors
|
list[dict]
|
The named vectors to update. This has fields "name", "enabled", and "description". The "name" is used to identify the named vector to change (the name will not change). Set "enabled" to True/False to enable/disable the named vector. Set "description" to describe the named vector. The description of named vectors is not automatically generated by the LLM. Any named vectors that are not provided will not be updated. If None or not provided, the named vectors will not be updated. |
None
|
summary
|
str
|
The summary to update. The summary is a short description of the collection, generated by the LLM. This will replace the existing summary of the collection. If None or not provided, the summary will not be updated. |
None
|
mappings
|
dict
|
The mappings to update. The mappings are what the frontend will use to display the collection, and the associated fields. I.e., which fields correspond to which output fields on the frontend. The keys of the outer level of the dictionary are the mapping names, the values are dictionaries with the mappings. The inner dictionary has the keys as the collection fields, and the values as the frontend fields. If None or not provided, the mappings will not be updated. |
None
|
fields
|
list[dict]
|
The fields to update. Each element in the list is a dictionary with the following fields: - "name": The name of the field. (This is used to identify the field to change, the name will not change). - "description": The description of the field to update. Any fields that are not provided will not be updated. If None or not provided, the fields will not be updated. |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The updated preprocessed collection. |
Source code in elysia/preprocess/collection.py
1066 1067 1068 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 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
|
preprocess(collection_names, client_manager=None, min_sample_size=5, max_sample_size=100, num_sample_tokens=30000, settings=environment_settings, force=False)
Preprocess a collection, obtain a LLM-generated summary of the collection, a set of statistics for each field (such as unique categories), and a set of mappings from the fields to the frontend-specific fields in Elysia.
In order: 1. Evaluate all the data fields and groups/statistics of the data fields as a whole 2. Write a summary of the collection via an LLM 3. Evaluate what return types are available for this collection 4. For each data field in the collection, evaluate what corresponding entry goes to what field in the return type (mapping) 5. Save as a ELYSIA_METADATA__ collection
Depending on the size of objects in the collection, you can choose the minimum and maximum sample size, which will be used to create a sample of objects for the LLM to create a collection summary. If your objects are particularly large, you can set the sample size to be smaller, to use less tokens and speed up the LLM processing. If your objects are small, you can set the sample size to be larger, to get a more accurate summary. This is a trade-off between speed/compute and accuracy.
But note that the pre-processing step only needs to be done once for each collection. The output of this function is cached, so that if you run it again, it will not re-process the collection (unless the force flag is set to True).
This function saves the output into a collection called ELYSIA_METADATA__, which is automatically called by Elysia.
This is saved to whatever Weaviate cluster URL/API key you have configured, or in your environment variables.
You can change this by setting the wcd_url
and wcd_api_key
in the settings, and pass this Settings object to this function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_names
|
list[str]
|
The names of the collections to preprocess. |
required |
client_manager
|
ClientManager
|
The client manager to use. If not provided, a new ClientManager will be created using the environment variables/configured settings. |
None
|
min_sample_size
|
int
|
The minimum number of objects to sample from the collection to evaluate the statistics/summary. Optional, defaults to 10. |
5
|
max_sample_size
|
int
|
The maximum number of objects to sample from the collection to evaluate the statistics/summary. Optional, defaults to 20. |
100
|
num_sample_tokens
|
int
|
The maximum number of tokens in the sample objects used to evaluate the summary. Optional, defaults to 30000. |
30000
|
settings
|
Settings
|
The settings to use. Optional, defaults to the environment variables/configured settings. |
settings
|
force
|
bool
|
Whether to force the preprocessor to run even if the collection already exists. Optional, defaults to False. |
False
|
Source code in elysia/preprocess/collection.py
preprocess_async(collection_name, client_manager=None, min_sample_size=10, max_sample_size=20, num_sample_tokens=30000, force=False, percentage_correct_threshold=0.3, settings=environment_settings)
async
Preprocess a collection, obtain a LLM-generated summary of the collection, a set of statistics for each field (such as unique categories), and a set of mappings from the fields to the frontend-specific fields in Elysia.
In order:
- Evaluate all the data fields and groups/statistics of the data fields as a whole
- Write a summary of the collection via an LLM
- Evaluate what return types are available for this collection
- For each data field in the collection, evaluate what corresponding entry goes to what field in the return type (mapping)
- Save as a ELYSIA_METADATA__ collection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to preprocess. |
required |
client_manager
|
ClientManager
|
The client manager to use. |
None
|
min_sample_size
|
int
|
The minimum number of objects to sample from the collection to evaluate the statistics/summary. Optional, defaults to 10. |
10
|
max_sample_size
|
int
|
The maximum number of objects to sample from the collection to evaluate the statistics/summary. Optional, defaults to 20. |
20
|
num_sample_tokens
|
int
|
The number of tokens to approximately sample from the collection to evaluate the summary.
The preprocessor will aim to use this many tokens in the sample objects to evaluate the summary.
But will not exceed the maximum number of objects specified by |
30000
|
force
|
bool
|
Whether to force the preprocessor to run even if the collection already exists. Optional, defaults to False. |
False
|
threshold_for_missing_fields
|
float
|
The threshold for the number of missing fields in the data mapping. Optional, defaults to 0.1. |
required |
settings
|
Settings
|
The settings to use. Optional, defaults to the environment variables/configured settings. |
settings
|
Returns:
Type | Description |
---|---|
AsyncGenerator[dict, None]
|
AsyncGenerator[dict, None]: A generator that yields dictionaries with the status updates and progress of the preprocessor. |
Source code in elysia/preprocess/collection.py
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 |
|
preprocessed_collection_exists(collection_name, client_manager=None)
Check if the preprocessed collection exists in the Weaviate cluster. This function simply checks if the cached preprocessed metadata exists in the Weaviate cluster. It does so by checking if the collection name exists in the ELYSIA_METADATA__ collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to check. |
required |
client_manager
|
ClientManager
|
The client manager to use. |
None
|
Source code in elysia/preprocess/collection.py
preprocessed_collection_exists_async(collection_name, client_manager=None)
async
Async version of preprocessed_collection_exists
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to check. |
required |
client_manager
|
ClientManager
|
The client manager to use. If not provided, a new ClientManager will be created using the environment variables/configured settings. |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the collection exists, False otherwise. |
Source code in elysia/preprocess/collection.py
view_preprocessed_collection(collection_name, client_manager=None)
View a preprocessed collection. This function allows you to view the preprocessed collection generated by the preprocess function. It does so by querying the ELYSIA_METADATA__ collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to view. |
required |
client_manager
|
ClientManager
|
The client manager to use. If not provided, a new ClientManager will be created using the environment variables/configured settings. |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The preprocessed collection. |
Source code in elysia/preprocess/collection.py
view_preprocessed_collection_async(collection_name, client_manager=None)
async
Async version of view_preprocessed_collection
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_name
|
str
|
The name of the collection to view. |
required |
client_manager
|
ClientManager
|
The client manager to use. If not provided, a new ClientManager will be created using the environment variables/configured settings. |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The preprocessed collection. |