ontocast.cli.serve¶
OntoCast API server implementation.
This module provides a web server implementation for the OntoCast framework using Robyn. It exposes REST API endpoints for processing documents and extracting semantic triples with ontology assistance.
The server supports: - Health check endpoint (/health) - Service information endpoint (/info) - Document processing endpoint (/process) - Triple store flush endpoint (/flush) - Multiple input formats (JSON, multipart/form-data) - Streaming workflow execution - Comprehensive error handling and logging
The server integrates with the OntoCast workflow graph to process documents through the complete pipeline: chunking, ontology selection, fact extraction, and aggregation.
Example
With Fuseki backend (auto-detected from FUSEKI_URI and FUSEKI_AUTH)¶
ontocast --env-path .env
Process specific file¶
ontocast --env-path .env --input-path ./document.pdf
Process with chunk limit¶
ontocast --env-path .env --head-chunks 5
calculate_recursion_limit(head_chunks, server_config)
¶
Calculate the recursion limit based on max visits and head chunks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
head_chunks
|
int | None
|
Optional maximum number of chunks to process |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Calculated recursion limit |
Source code in ontocast/cli/serve.py
run(env_file, input_path, head_chunks)
¶
Main entry point for the OntoCast server/CLI.
Backend selection is automatically inferred from available configuration: - Fuseki: If FUSEKI_URI and FUSEKI_AUTH are provided (preferred) - Neo4j: If NEO4J_URI and NEO4J_AUTH are provided (fallback) - Filesystem Triple Store: If ONTOCAST_WORKING_DIRECTORY and ONTOCAST_ONTOLOGY_DIRECTORY are provided - Filesystem Manager: If ONTOCAST_WORKING_DIRECTORY is provided (can be combined with other backends)
No explicit backend configuration flags are needed - backends are automatically detected.
Source code in ontocast/cli/serve.py
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 | |