ontocast.tool¶
Tool package for OntoCast.
AtomicToolBox
¶
Small tool surface used by atomic render/critic paths.
Source code in ontocast/tool/atomic.py
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 | |
get_llm_tool(budget_tracker)
async
¶
search(query, max_results=None)
async
¶
Run optional web search and return normalized hits.
Source code in ontocast/tool/atomic.py
web_grounding_enabled_for_node(node)
¶
Return whether web grounding is enabled for a workflow node.
Source code in ontocast/tool/atomic.py
ChunkerTool
¶
Bases: Tool
Tool for semantic chunking of documents.
Falls back to naive chunking if sentence-transformers is not available. Includes caching to avoid re-chunking the same text with the same parameters.
Source code in ontocast/tool/chunk/chunker.py
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 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 | |
__call__(doc)
¶
Chunk the document using either semantic or naive chunking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
str
|
The document text to chunk. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of text chunks. |
Source code in ontocast/tool/chunk/chunker.py
__init__(chunk_config=None, cache=None, **kwargs)
¶
Initialize the ChunkerTool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk_config
|
ChunkConfig | None
|
Chunking configuration. If None, uses default ChunkConfig. |
None
|
cache
|
Cacher | None
|
Optional shared Cacher instance. If None, creates a new one. |
None
|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Source code in ontocast/tool/chunk/chunker.py
naive_split(doc)
¶
Split text by paragraph/sentence boundaries up to max_size.
Unlike :meth:_naive_chunk, does not enforce min_size filtering.
Source code in ontocast/tool/chunk/chunker.py
size_text(doc)
¶
Split doc to respect min_size / max_size using naive boundaries.
ConverterTool
¶
Bases: Tool
Tool for converting documents to native DoclingDocument format.
This class provides functionality for converting various document formats into DoclingDocument objects that can be processed by the OntoCast system. It includes caching to avoid re-converting the same documents.
Attributes:
| Name | Type | Description |
|---|---|---|
supported_extensions |
set[str]
|
Set of supported file extensions. |
cache |
Any
|
Cacher instance for caching conversion results. |
Source code in ontocast/tool/converter.py
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 | |
__call__(file_input)
¶
Convert a document to a DoclingDocument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_input
|
Union[bytes, str, Path]
|
The input file as either bytes, string, or pathlib.Path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DoclingDocument |
DoclingDocument
|
The converted document. |
Source code in ontocast/tool/converter.py
__init__(cache=None, **kwargs)
¶
Initialize the converter tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache
|
Cacher | None
|
Optional shared Cacher instance. If None, creates a new one. |
None
|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Source code in ontocast/tool/converter.py
EmbeddingBasedAggregator
¶
Main aggregator using embedding-based entity disambiguation.
Pipeline stages: 1. Entity normalisation (with semantic context) 2. Parallel embedding 3. Similarity-based clustering 4. Representative selection (prefer ontology, then simplicity) 5. URI normalisation (PascalCase/camelCase under DEFAULT_IRI) 6. Graph rewriting
ContentUnit types are handled as follows:
- facts: entities under base_iri are normalised.
- ontology: all other entities are considered ontology entities and preserved.
Source code in ontocast/tool/agg/aggregate.py
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 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 | |
__init__(embedding_model='paraphrase-multilingual-MiniLM-L12-v2', similarity_threshold=0.8, candidate_similarity_threshold=0.7, add_sameas_links=True, base_iri=DEFAULT_IRI)
¶
Initialise the embedding-based aggregator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
embedding_model
|
str
|
Name of sentence transformer model. |
'paraphrase-multilingual-MiniLM-L12-v2'
|
similarity_threshold
|
float
|
Cosine similarity threshold for clustering (0-1). |
0.8
|
candidate_similarity_threshold
|
float
|
Lower cosine threshold used to generate permissive merge candidates before symbolic validation. |
0.7
|
add_sameas_links
|
bool
|
Whether to add owl:sameAs for merged entities. |
True
|
base_iri
|
str
|
Base IRI for fact entity URIs (default: DEFAULT_IRI). Entities under this namespace are facts; everything else is treated as an ontology entity and left unchanged. |
DEFAULT_IRI
|
Source code in ontocast/tool/agg/aggregate.py
aggregate_graphs(units, ontology_graph)
¶
Aggregate multiple content unit graphs with embedding-based disambiguation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
units
|
list[ContentUnit]
|
List of ContentUnits to aggregate. |
required |
ontology_graph
|
RDFGraph
|
Selected ontology graph used to distinguish known ontology entities from tentative ontology-like aliases. |
required |
Returns:
| Type | Description |
|---|---|
RDFGraph
|
Merged RDF graph with provenance annotations. |
Source code in ontocast/tool/agg/aggregate.py
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 | |
postprocess_facts_units(units, ontology_graph)
¶
Sanitize facts units, then run aggregation/normalization.
This method is intentionally safe for both single-unit and multi-unit inputs so unit-pipeline and graph-pipeline paths share the same post-processing behavior.
Source code in ontocast/tool/agg/aggregate.py
EmbeddingTool
¶
Bases: Tool
Base embedding tool with provider-specific implementations.
Source code in ontocast/tool/vector_store/embedding.py
create(config)
classmethod
¶
Factory for provider-specific embedding tools.
Source code in ontocast/tool/vector_store/embedding.py
embed(texts)
abstractmethod
¶
embed_one(text)
¶
Return a vector for one text.
FusekiTripleStoreManager
¶
Bases: TripleStoreManagerWithAuth
Fuseki-based triple store manager.
This class provides a concrete implementation of triple store management using Apache Fuseki. It stores ontologies as named graphs using their URIs as graph names, and supports dataset creation and cleanup.
URI shape: uri must be the Fuseki HTTP server root (e.g.
http://localhost:3032), not a dataset path or UI URL. Dataset names are
dataset / ontologies_dataset; the client calls
{uri}/{dataset_name}/sparql and similar. The UI route
/#/dataset/dataset_name is only for the browser; paste the origin (and
optional non-dataset path prefix) into FUSEKI_URI, and set
FUSEKI_DATASET to dataset_name.
The manager uses Fuseki's REST API for all operations, including: - Dataset creation and management - Named graph operations for ontologies - SPARQL queries for ontology discovery - Graph-level data operations
Attributes:
| Name | Type | Description |
|---|---|---|
dataset |
str | None
|
Facts dataset name (first path segment in Fuseki HTTP API). |
ontologies_dataset |
str
|
Ontologies dataset name. |
Source code in ontocast/tool/triple_manager/fuseki.py
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 | |
__init__(uri=None, auth=None, dataset=None, ontologies_dataset=None, **kwargs)
¶
Initialize the Fuseki triple store manager.
This method sets up the connection to Fuseki and creates the dataset if it doesn't exist. The dataset is NOT cleaned on initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
Fuseki HTTP service root (e.g. |
None
|
|
auth
|
Authentication tuple (username, password) or string in "user/password" format. |
None
|
|
dataset
|
Facts dataset name (Fuseki API path segment). |
None
|
|
ontologies_dataset
|
Ontologies dataset name (separate Fuseki dataset). |
None
|
|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Example
manager = FusekiTripleStoreManager( ... uri="http://localhost:3030", ... dataset="acme--demo--facts", ... ontologies_dataset="acme--demo--ontologies", ... ) await manager.clean()
Source code in ontocast/tool/triple_manager/fuseki.py
afetch_ontologies()
async
¶
Async version of fetch_ontologies.
This is the preferred method when running in an async context.
aserialize(o, **kwargs)
async
¶
Async version of serialize.
This is the preferred method when running in an async context.
aserialize_graph(graph, **kwargs)
async
¶
Async version of serialize_graph.
This is the preferred method when running in an async context.
Source code in ontocast/tool/triple_manager/fuseki.py
async_init()
async
¶
Initialize configured Fuseki datasets explicitly.
Constructors stay side-effect free so callers can resolve tenancy first and then create datasets for the final dataset names.
Source code in ontocast/tool/triple_manager/fuseki.py
clean()
async
¶
Clear the configured facts dataset and ontologies dataset (when distinct).
Source code in ontocast/tool/triple_manager/fuseki.py
clean_tenancy(tenant, project, *, sep=TENANCY_SEP)
async
¶
Flush facts and ontologies datasets for tenant / project (by derived names).
Source code in ontocast/tool/triple_manager/fuseki.py
close()
async
¶
drop_all_ontology_graphs_for_iri(ontology_iri)
async
¶
Remove named graphs for ontology_iri (base and iri#... versioned).
Source code in ontocast/tool/triple_manager/fuseki.py
drop_named_graph(graph_uri, *, use_ontologies_dataset=True)
async
¶
Drop a single named graph in the ontologies or main dataset.
Source code in ontocast/tool/triple_manager/fuseki.py
fetch_ontologies()
¶
Synchronous wrapper for fetch_ontologies.
For async usage, use afetch_ontologies() instead.
Source code in ontocast/tool/triple_manager/fuseki.py
init_dataset(dataset_name)
async
¶
Initialize a Fuseki dataset.
This method creates a new dataset in Fuseki if it doesn't already exist. It uses Fuseki's admin API to create the dataset with TDB2 storage.
Uses a temporary client to avoid event loop cleanup issues when called from different async contexts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
Name of the dataset to create. |
required |
Note
This method will not fail if the dataset already exists.
Source code in ontocast/tool/triple_manager/fuseki.py
serialize(o, **kwargs)
¶
Synchronous wrapper for serialize.
For async usage, use aserialize() instead.
serialize_graph(graph, **kwargs)
¶
Synchronous wrapper for serialize_graph.
For async usage, use aserialize_graph() instead.
Source code in ontocast/tool/triple_manager/fuseki.py
update_tenancy(tenant, project, *, sep=TENANCY_SEP)
async
¶
Switch facts and ontologies Fuseki datasets for tenant / project.
Source code in ontocast/tool/triple_manager/fuseki.py
InMemoryTripleStoreManager
¶
Bases: TripleStoreManager
pyoxigraph-backed in-memory triple store with tenant/project partitions.
Source code in ontocast/tool/triple_manager/in_memory.py
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 | |
LLMTool
¶
Bases: Tool
Tool for interacting with language models.
This class provides a unified interface for working with different language model providers (OpenAI, Ollama, Anthropic, Google) through LangChain. It supports both synchronous and asynchronous operations.
Attributes:
| Name | Type | Description |
|---|---|---|
config |
LLMConfig
|
LLMConfig object containing all LLM settings. |
cache |
Any
|
Cacher instance for caching LLM responses. |
Source code in ontocast/tool/llm.py
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 | |
llm
property
¶
Get the underlying language model instance.
Returns:
| Name | Type | Description |
|---|---|---|
BaseChatModel |
BaseChatModel
|
The configured language model. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the LLM has not been properly initialized. |
__call__(*args, **kwds)
async
¶
__init__(cache=None, budget_tracker=None, **kwargs)
¶
Initialize the LLM tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache
|
Cacher | None
|
Optional shared Cacher instance. If None, creates a new one. |
None
|
budget_tracker
|
Any
|
Optional budget tracker instance for usage statistics. |
None
|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Source code in ontocast/tool/llm.py
acall(*args, **kwds)
async
¶
acreate(config, cache=None, budget_tracker=None, **kwargs)
async
classmethod
¶
Create a new LLM tool instance asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LLMConfig
|
LLMConfig object containing LLM settings. |
required |
cache
|
Cacher | None
|
Optional shared Cacher instance. |
None
|
budget_tracker
|
Any
|
Optional budget tracker instance for usage statistics. |
None
|
**kwargs
|
Additional keyword arguments for initialization. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
LLMTool |
A new instance of the LLM tool. |
Source code in ontocast/tool/llm.py
complete(prompt, **kwargs)
async
¶
Generate a completion for the given prompt.
Source code in ontocast/tool/llm.py
create(config, cache=None, budget_tracker=None, **kwargs)
classmethod
¶
Create a new LLM tool instance synchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LLMConfig
|
LLMConfig object containing LLM settings. |
required |
cache
|
Cacher | None
|
Optional shared Cacher instance. |
None
|
budget_tracker
|
Any
|
Optional budget tracker instance for usage statistics. |
None
|
**kwargs
|
Additional keyword arguments for initialization. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
LLMTool |
A new instance of the LLM tool. |
Source code in ontocast/tool/llm.py
extract(prompt, output_schema, **kwargs)
async
¶
Extract structured data from the prompt according to a schema.
Source code in ontocast/tool/llm.py
get_cache_stats()
¶
Return in-memory hit/miss counters and on-disk cache file stats.
Source code in ontocast/tool/llm.py
setup()
async
¶
Set up the language model based on the configured provider.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provider is not supported. |
Source code in ontocast/tool/llm.py
LanceDBVectorStoreManager
¶
Bases: VectorStoreManager
Stores ontology atoms in a single embedded LanceDB database directory.
Source code in ontocast/tool/vector_store/lancedb.py
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 | |
apply_tenancy(tenant, project, *, sep=TENANCY_SEP)
¶
Switch active Lance tables for tenant / project.
Same naming as Qdrant collections; all tables live in one embedded DB.
Call :meth:initialize after.
Source code in ontocast/tool/vector_store/lancedb.py
clean_tenancy(tenant, project, *, sep=TENANCY_SEP)
async
¶
Drop Lance tables (and embedding metadata) for tenant / project.
Source code in ontocast/tool/vector_store/lancedb.py
OntologyManager
¶
Bases: Tool
Manager for handling multiple ontologies with version tracking.
This class provides functionality for managing a collection of ontologies, tracking version lineage using hash-based identifiers. For each IRI, it maintains a tree/graph of all versions identified by their hashes.
Attributes:
| Name | Type | Description |
|---|---|---|
ontology_versions |
dict[str, list[Ontology]]
|
Dictionary mapping IRI to list of all ontology versions (identified by hash). Each IRI can have multiple versions forming a lineage tree. |
Source code in ontocast/tool/ontology_manager.py
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 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 | |
has_ontologies
property
¶
Check if there are any ontologies available.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if there are any ontologies, False otherwise. |
ontologies
property
¶
Get freshest terminal ontology for each IRI.
This property provides backward compatibility with code that expects a list of ontologies. Returns the freshest (most recently created) terminal version for each IRI.
The result is cached per IRI (as hashes) and updated incrementally when ontologies are added.
Returns:
| Type | Description |
|---|---|
list[Ontology]
|
list[Ontology]: List of freshest terminal ontologies, one per IRI. |
__contains__(item)
¶
Check if an item (IRI or ontology_id) is in the ontology manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
The IRI or ontology_id to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the item exists in any version of any ontology. |
Source code in ontocast/tool/ontology_manager.py
__init__(**kwargs)
¶
Initialize the ontology manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Source code in ontocast/tool/ontology_manager.py
add_ontology(ontology, *, skip_vector_index=False)
¶
Add an ontology to the version tree for its IRI.
If an ontology with the same hash already exists, it is not added again. The ontology is added to the version tree for its IRI. Ensures that created_at is set if not already present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ontology
|
Ontology
|
The ontology to add. |
required |
skip_vector_index
|
bool
|
If True, do not call the vector store (caller already materialized embeddings, e.g. during ToolBox.initialize). |
False
|
Source code in ontocast/tool/ontology_manager.py
aget_patch_context(query, top_k=None, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
async
¶
Async variant of :meth:get_patch_context.
Source code in ontocast/tool/ontology_manager.py
aget_patch_context_with_sources(query, top_k=None, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
async
¶
Async variant of :meth:get_patch_context_with_sources.
Source code in ontocast/tool/ontology_manager.py
aget_patch_contexts_with_sources(queries, top_k=None, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
async
¶
Async patch retrieval (vector + induced subgraph) for many queries.
With a patch retriever, returns a one-element list: a single induced graph for
the union of hits over queries, plus contributing ontology IRIs.
Source code in ontocast/tool/ontology_manager.py
get_freshest_terminal_ontology(ontology_id=None)
¶
Get the freshest terminal ontology by ontology_id (backward compatibility wrapper).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ontology_id
|
str | None
|
Optional ontology_id to filter by. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Ontology |
Ontology | None
|
The freshest terminal ontology, or None if no terminal ontologies exist. |
Source code in ontocast/tool/ontology_manager.py
get_freshest_terminal_ontology_by_iri(iri=None)
¶
Get the freshest terminal ontology based on created_at timestamp.
Returns the terminal ontology with the most recent created_at timestamp.
If multiple terminal ontologies exist, returns the one that was most recently
created. If no created_at is set, falls back to the first terminal ontology.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iri
|
str | None
|
Optional IRI to filter by. If None, searches across all ontologies. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Ontology |
Ontology | None
|
The freshest terminal ontology, or None if no terminal ontologies exist. |
Source code in ontocast/tool/ontology_manager.py
get_lineage_graph(ontology_id)
¶
Get the lineage graph for a specific ontology_id (backward compatibility wrapper).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ontology_id
|
str
|
The ontology_id to get the lineage graph for. |
required |
Returns:
| Type | Description |
|---|---|
|
networkx.DiGraph: The lineage graph for the ontology, or None if not found. |
Source code in ontocast/tool/ontology_manager.py
get_lineage_graph_by_iri(iri)
¶
Get the lineage graph for a specific IRI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iri
|
str
|
The IRI to get the lineage graph for. |
required |
Returns:
| Type | Description |
|---|---|
|
networkx.DiGraph: The lineage graph for the ontology, or None if not found. |
Source code in ontocast/tool/ontology_manager.py
get_ontology(ontology_id=None, ontology_iri=None, hash=None)
¶
Get an ontology by its IRI, ontology_id, or hash.
If hash is provided, returns the specific version. Otherwise, returns a terminal (most recent) version if multiple versions exist. IRI is preferred over ontology_id for lookup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ontology_id
|
str | None
|
The short name of the ontology to retrieve (optional, for backward compatibility). |
None
|
ontology_iri
|
str | None
|
The IRI of the ontology to retrieve (preferred). |
None
|
hash
|
str | None
|
The hash of a specific version to retrieve (optional). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Ontology |
Ontology
|
The matching ontology if found, NULL_ONTOLOGY otherwise. |
Source code in ontocast/tool/ontology_manager.py
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 | |
get_ontology_iris()
¶
Get a list of all ontology IRIs.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of ontology IRIs. |
get_ontology_names()
¶
Get a list of all ontology short names (backward compatibility wrapper).
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of unique ontology short names. |
Source code in ontocast/tool/ontology_manager.py
get_ontology_versions(ontology_id)
¶
Get all versions of an ontology by ontology_id (backward compatibility wrapper).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ontology_id
|
str
|
The ontology_id to retrieve versions for. |
required |
Returns:
| Type | Description |
|---|---|
list[Ontology]
|
list[Ontology]: List of all versions of the ontology. |
Source code in ontocast/tool/ontology_manager.py
get_ontology_versions_by_iri(iri)
¶
Get all versions of an ontology by IRI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iri
|
str
|
The IRI to retrieve versions for. |
required |
Returns:
| Type | Description |
|---|---|
list[Ontology]
|
list[Ontology]: List of all versions of the ontology. |
Source code in ontocast/tool/ontology_manager.py
get_patch_context(query, top_k=None, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
¶
Retrieve multi-ontology patch context for a query.
Falls back to the freshest available ontology graph if vector retrieval is not configured or yields no atoms.
Source code in ontocast/tool/ontology_manager.py
get_patch_context_with_sources(query, top_k=None, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
¶
Retrieve patch context and contributing ontology IRIs.
Source code in ontocast/tool/ontology_manager.py
get_patch_contexts_with_sources(queries, top_k=None, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
¶
Retrieve patch contexts for many queries in a batched pass.
With a patch retriever, the list has length 1 (ensemble graph + sources).
Without it, length matches queries (fallback ontology per query).
Source code in ontocast/tool/ontology_manager.py
get_terminal_ontologies(ontology_id=None)
¶
Get terminal (leaf) ontologies by ontology_id (backward compatibility wrapper).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ontology_id
|
str | None
|
Optional ontology_id to filter by. |
None
|
Returns:
| Type | Description |
|---|---|
list[Ontology]
|
list[Ontology]: List of terminal ontologies. |
Source code in ontocast/tool/ontology_manager.py
get_terminal_ontologies_by_iri(iri=None)
¶
Get terminal (leaf) ontologies in the version graph.
Terminal ontologies are those that are not parents of any other ontology in the version tree. If iri is provided, returns terminals for that ontology only; otherwise returns terminals for all ontologies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iri
|
str | None
|
Optional IRI to filter by. |
None
|
Returns:
| Type | Description |
|---|---|
list[Ontology]
|
list[Ontology]: List of terminal ontologies. |
Source code in ontocast/tool/ontology_manager.py
register_vector_store(retriever)
¶
remove_ontology_by_iri(iri)
¶
Drop all tracked versions for an ontology IRI and clear caches.
Source code in ontocast/tool/ontology_manager.py
update_ontology(ontology_id, ontology_addendum)
¶
Update an existing ontology with additional triples.
Note: This method is deprecated. Use add_ontology() with a new version that has the current hash in parent_hashes instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ontology_id
|
str
|
The short name of the ontology to update. |
required |
ontology_addendum
|
RDFGraph
|
The RDF graph containing additional triples to add. |
required |
Source code in ontocast/tool/ontology_manager.py
validate_identity_uniqueness(ontology)
¶
Validate ontology IRI<->identity bijection across the manager.
Source code in ontocast/tool/ontology_manager.py
OntologyPatchRetriever
¶
Bases: Tool
Combines vector retrieval into one composite ontology graph.
Source code in ontocast/tool/vector_store/patch_retriever.py
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 | |
aretrieve(query, top_k=None, expand_sparql=True, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
async
¶
Async single-query variant of :meth:aretrieve_ensemble.
Source code in ontocast/tool/vector_store/patch_retriever.py
aretrieve_ensemble(queries, top_k=None, expand_sparql=True, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
async
¶
Vector search over all queries once, score-filter, dedupe, single subgraph expansion.
Source code in ontocast/tool/vector_store/patch_retriever.py
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 | |
retrieve(query, top_k=None, expand_sparql=True, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
¶
Retrieve top-k hits for one query and optional induced subgraph; returns source ontology IRIs.
Source code in ontocast/tool/vector_store/patch_retriever.py
retrieve_ensemble(queries, top_k=None, expand_sparql=True, subgraph_depth=1, max_total_triples=300, estimated_triples_per_query=24)
¶
Source code in ontocast/tool/vector_store/patch_retriever.py
QdrantVectorStoreManager
¶
Bases: VectorStoreManager
Stores ontology atoms in Qdrant and supports similarity lookup.
Source code in ontocast/tool/vector_store/qdrant.py
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 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 | |
apply_tenancy(tenant, project, *, sep=TENANCY_SEP)
¶
Point config at collections for tenant / project.
Call :meth:initialize after.
Source code in ontocast/tool/vector_store/qdrant.py
asearch_patch_hits_many(queries, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
async
¶
Async variant: one batched embed, then parallel split-channel searches.
Source code in ontocast/tool/vector_store/qdrant.py
clean_tenancy(tenant, project, *, sep=TENANCY_SEP)
async
¶
Delete Qdrant collections named for tenant / project.
Source code in ontocast/tool/vector_store/qdrant.py
count_points_by_ontology_iri(*, batch_size=512)
¶
Count indexed atoms grouped by ontology_iri payload (diagnostics).
Source code in ontocast/tool/vector_store/qdrant.py
delete_duplicate_iri_points(*, batch_size=512)
¶
Delete duplicate points sharing the same configured identity key.
Source code in ontocast/tool/vector_store/qdrant.py
delete_ontology(iri, version=None, ontology_hash=None)
¶
Delete atoms associated with one ontology IRI and optional version/hash.
Source code in ontocast/tool/vector_store/qdrant.py
fetch_vectors(atom_ids)
¶
Batch-fetch dense core/neighborhood vectors for MMR (BM25 not used).
Source code in ontocast/tool/vector_store/qdrant.py
index_ontology(ontology)
¶
Atomize + embed + upsert ontology neighborhoods.
Source code in ontocast/tool/vector_store/qdrant.py
initialize()
async
¶
Create ontology/facts collections and payload indexes if missing.
Source code in ontocast/tool/vector_store/qdrant.py
search_by_vector(core_vector, neighborhood_vector, bm25_query_vector=None, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
¶
Search ontology atoms with rank fusion over named vectors.
Source code in ontocast/tool/vector_store/qdrant.py
search_hits_by_vector(core_vector, neighborhood_vector, bm25_query_vector=None, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
¶
Search ontology atoms and return channel-separated scored hit objects.
Source code in ontocast/tool/vector_store/qdrant.py
search_patch_hits(query, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
¶
Search ontology atoms and return rank-fused scored hit objects.
Source code in ontocast/tool/vector_store/qdrant.py
search_patch_hits_many(queries, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
¶
Search ontology atoms for many queries with split-channel outputs.
Source code in ontocast/tool/vector_store/qdrant.py
search_patches(query, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
¶
Search ontology atoms by text query using weighted multi-vector fusion.
Source code in ontocast/tool/vector_store/qdrant.py
SearchHit
¶
Tool
¶
Bases: BasePydanticModel
Base class for all OntoCast tools.
This class serves as the foundation for all tools in the OntoCast system. It provides common functionality and interface that all tools must implement. Tools should inherit from this class and implement their specific functionality.
Source code in ontocast/tool/onto.py
__init__(**kwargs)
¶
Initialize the tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Keyword arguments passed to the parent class. |
{}
|
TripleStoreManager
¶
Bases: Tool
Source code in ontocast/tool/triple_manager/core.py
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 | |
__init__(**kwargs)
¶
Initialize the triple store manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
afetch_ontologies()
async
¶
aserialize(o, **kwargs)
async
¶
Async serialize helper for backends without native async I/O.
aserialize_graph(graph, **kwargs)
async
¶
Async serialize helper for backends without native async I/O.
async_init()
async
¶
clean()
abstractmethod
async
¶
Clean/flush data managed by this store (backend-specific scope).
Warning: This operation is irreversible and will delete data.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the triple store doesn't support cleaning. |
Source code in ontocast/tool/triple_manager/core.py
clean_tenancy(tenant, project)
async
¶
Remove all triples for datasets derived from tenant / project.
Backends without per-tenant partitions raise :class:NotImplementedError.
Source code in ontocast/tool/triple_manager/core.py
drop_all_ontology_graphs_for_iri(ontology_iri)
async
¶
Remove named graphs for ontology_iri (base and versioned).
Source code in ontocast/tool/triple_manager/core.py
drop_named_graph(graph_uri, *, use_ontologies_dataset=True)
async
¶
Drop a single named graph.
Source code in ontocast/tool/triple_manager/core.py
fetch_ontologies()
abstractmethod
¶
Fetch all available ontologies from the triple store.
This method should retrieve all ontologies stored in the triple store and return them as Ontology objects with their associated RDF graphs.
Returns:
| Type | Description |
|---|---|
list[Ontology]
|
list[Ontology]: List of available ontologies with their graphs. |
Source code in ontocast/tool/triple_manager/core.py
serialize(o, **kwargs)
abstractmethod
¶
serialize_graph(graph, **kwargs)
abstractmethod
¶
strip_provenance(graph)
classmethod
¶
Return a graph without reification/provenance scaffolding triples.
Source code in ontocast/tool/triple_manager/core.py
supports_tenancy_partition()
¶
update_tenancy(tenant, project, *, sep=TENANCY_SEP)
async
¶
Switch the active tenant/project partition when supported.
Source code in ontocast/tool/triple_manager/core.py
VectorStoreManager
¶
Bases: Tool
Abstract interface for vector store implementations.
Source code in ontocast/tool/vector_store/core.py
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 | |
afetch_vectors(atom_ids)
async
¶
Async wrapper around :meth:fetch_vectors.
apply_tenancy(tenant, project, *, sep=TENANCY_SEP)
¶
Switch the active tenant/project partition when supported.
Source code in ontocast/tool/vector_store/core.py
asearch_patch_hits_many(queries, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
abstractmethod
async
¶
Async variant of :meth:search_patch_hits_many.
Source code in ontocast/tool/vector_store/core.py
clean_tenancy(tenant, project)
async
¶
Drop or empty vector collections derived from tenant / project.
Source code in ontocast/tool/vector_store/core.py
delete_ontology(iri, version=None, ontology_hash=None)
abstractmethod
¶
Delete all indexed atoms for a specific ontology IRI.
fetch_vectors(atom_ids)
abstractmethod
¶
index_ontology(ontology)
abstractmethod
¶
initialize()
abstractmethod
async
¶
reindex_ontology(ontology)
¶
Replace all atoms for a given ontology and return indexed count.
search_patch_hits(query, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
abstractmethod
¶
Search ontology atoms and return rank-fused scored hit objects.
Source code in ontocast/tool/vector_store/core.py
search_patch_hits_many(queries, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
abstractmethod
¶
Search ontology atoms for many queries with split-channel outputs.
Source code in ontocast/tool/vector_store/core.py
search_patches(query, top_k=None, filter_iri=None, filter_version=None, filter_hash=None)
abstractmethod
¶
Search ontology patches by query text (top_k None → store default).