### Example Neo4j .env.example File Source: https://growgraph.github.io/ontocast/user_guide/triple_stores An example .env.example file for Neo4j Docker setup, including image version, ports, plugins, and authentication details. ```bash IMAGE_VERSION=neo4j:5.20 SPEC=test CONTAINER_NAME="${SPEC}.sem.neo4j" NEO4J_PORT=7476 NEO4J_BOLT_PORT=7689 STORE_FOLDER="$HOME/tmp/${CONTAINER_NAME}" NEO4J_PLUGINS='["apoc", "graph-data-science", "n10s"]' NEO4J_AUTH="neo4j/test!passfortesting" ``` -------------------------------- ### Example Fuseki .env.example File Source: https://growgraph.github.io/ontocast/user_guide/triple_stores This is an example of the .env.example file for Fuseki Docker setup. It defines image version, container name, ports, and credentials. ```bash IMAGE_VERSION=secoresearch/fuseki:5.1.0 SPEC=test CONTAINER_NAME="${SPEC}.fuseki" STORE_FOLDER="$HOME/tmp/${CONTAINER_NAME}" TS_PORT=3032 TS_PASSWORD="abc123-qwe" TS_USERNAME="admin" UID=1000 GID=1000 ``` -------------------------------- ### Prepare Fuseki Environment File Source: https://growgraph.github.io/ontocast/user_guide/triple_stores Copy the example environment file and edit it with your specific Fuseki configuration values. This is part of the Docker setup for Fuseki. ```bash cd docker/fuseki cp .env.example .env # Edit with your values ``` -------------------------------- ### Install OntoCast Source: https://growgraph.github.io/ontocast Use uv or pip to install the OntoCast package. ```bash uv add ontocast # or pip install ontocast ``` -------------------------------- ### Start Ontocast Server Source: https://growgraph.github.io/ontocast/reference/cli/serve Starts the Ontocast server on the configured port. Ensure the logger and app are imported and configured. ```python logger.info(f"Starting Ontocast server on port {config.server.port}") app.start(port=config.server.port) ``` -------------------------------- ### Prepare Neo4j Environment File Source: https://growgraph.github.io/ontocast/user_guide/triple_stores Copy the example environment file for Neo4j and edit it with your specific configuration. This prepares the .env file for the Neo4j Docker setup. ```bash cd docker/neo4j cp .env.example .env # Edit with your values ``` -------------------------------- ### Start OntoCast Server with Fuseki Backend Source: https://growgraph.github.io/ontocast/reference/cli/serve Starts the OntoCast API server. Assumes Fuseki backend is configured and auto-detected via FUSEKI_URI and FUSEKI_AUTH environment variables. ```bash ontocast --env-path .env ``` -------------------------------- ### Install OntoCast with pip Source: https://growgraph.github.io/ontocast/getting_started/installation Use this command to install OntoCast using the standard pip package installer. ```bash pip install ontocast ``` -------------------------------- ### Install Development Dependencies Source: https://growgraph.github.io/ontocast/contributing Use this command to install all development dependencies, including those for documentation processing. ```bash uv sync --all-groups --extra doc-processing ``` -------------------------------- ### Install OntoCast with uv Source: https://growgraph.github.io/ontocast/getting_started/installation Use this command to add OntoCast to your project dependencies using the uv package installer. ```bash uv add ontocast ``` -------------------------------- ### Install Pre-commit Hooks Source: https://growgraph.github.io/ontocast/contributing Install pre-commit hooks to ensure code quality and consistency before committing changes. ```bash pre-commit install ``` -------------------------------- ### setup() Source: https://growgraph.github.io/ontocast/reference/tool/llm Sets up the language model based on the configured provider. This method initializes the LLM client, potentially configuring specific parameters based on the provider and model. ```APIDOC ## setup() ### Description Set up the language model based on the configured provider. ### Raises - **ValueError** - If the provider is not supported. ``` -------------------------------- ### Configure OntoCast Environment Source: https://growgraph.github.io/ontocast Copy the example environment file and edit it with your specific configuration values for LLM, server, and triple store settings. ```bash cp .env.example .env # Edit with your values ``` -------------------------------- ### LLMTool.setup Source: https://growgraph.github.io/ontocast/reference/tool/__init__ Asynchronously sets up the language model based on the configured provider. ```APIDOC ## LLMTool.setup ### Description Set up the language model based on the configured provider. ### Method Signature `setup()` ### Returns `None` ``` -------------------------------- ### Initialize FilesystemTripleStoreManager Source: https://growgraph.github.io/ontocast/reference/tool/triple_manager/filesystem_manager Sets up the filesystem manager with working and ontology directories. Additional keyword arguments are passed to the parent class. ```python def __init__(self, **kwargs): """Initialize the filesystem triple store manager. This method sets up the filesystem manager with the specified working and ontology directories. Args: **kwargs: Additional keyword arguments passed to the parent class. working_directory: Path to the working directory for storing data. ontology_path: Path to the ontology directory for loading ontologies. Example: >>> manager = FilesystemTripleStoreManager( ... working_directory="/path/to/work", ... ontology_path="/path/to/ontologies" ... ) """ super().__init__(**kwargs) ``` -------------------------------- ### Ontology Extraction User Instruction Example Source: https://growgraph.github.io/ontocast/user_guide/user_instructions Use this instruction to guide the AI in extracting specific entities like geographical locations and organizations, and their relationships, with a focus on business events. ```text Focus on extracting geographical locations, organizations, and their relationships. Pay special attention to company mergers, acquisitions, and partnerships. ``` -------------------------------- ### Facts Extraction User Instruction Example Source: https://growgraph.github.io/ontocast/user_guide/user_instructions Use this instruction to guide the AI in extracting specific data points such as financial figures, dates, and numerical values, including currency information. ```text Extract financial data, dates, and numerical values. Focus on revenue, profit, and growth metrics. Include all monetary amounts with proper currency information. ``` -------------------------------- ### __init__ Source: https://growgraph.github.io/ontocast/reference/tool/triple_manager/filesystem_manager Initializes the filesystem triple store manager, setting up paths for data storage and ontology loading. ```APIDOC ## __init__ ### Description Initialize the filesystem triple store manager. This method sets up the filesystem manager with the specified working and ontology directories. ### Parameters #### Keyword Arguments - **working_directory** (Path) - Path to the working directory for storing data. - **ontology_path** (Path) - Path to the ontology directory for loading ontologies. ### Request Example ```python manager = FilesystemTripleStoreManager( working_directory="/path/to/work", ontology_path="/path/to/ontologies" ) ``` ``` -------------------------------- ### Get Cache Statistics Source: https://growgraph.github.io/ontocast/reference/tool/cache Retrieves cache statistics. Call with no arguments to get overall stats, or provide a subdirectory name to get stats for a specific tool. ```python def get_cache_stats( self, subdirectory: str | None = None ) -> dict[str, int | dict[str, int]]: """Get cache statistics. Args: subdirectory: If provided, get stats for this subdirectory only. If None, get stats for all. Returns: Dict[str, Any]: Dictionary with cache statistics. """ if subdirectory is None: # Get stats for all subdirectories if not self.cache_dir.exists(): return {"total_files": 0, "total_size_bytes": 0, "subdirectories": {}} cache_files = list(self.cache_dir.glob("**/*.json")) total_size = sum(f.stat().st_size for f in cache_files) # Group by subdirectory subdir_stats = {} for cache_file in cache_files: subdir = cache_file.parent.name if subdir not in subdir_stats: subdir_stats[subdir] = {"files": 0, "size_bytes": 0} subdir_stats[subdir]["files"] += 1 subdir_stats[subdir]["size_bytes"] += cache_file.stat().st_size return { "total_files": len(cache_files), "total_size_bytes": total_size, "subdirectories": subdir_stats, } else: # Get stats for specific subdirectory tool_cache_dir = self._get_tool_cache_dir(subdirectory) if not tool_cache_dir.exists(): return {"total_files": 0, "total_size_bytes": 0} cache_files = list(tool_cache_dir.glob("*.json")) total_size = sum(f.stat().st_size for f in cache_files) return { "total_files": len(cache_files), "total_size_bytes": total_size, } ``` -------------------------------- ### Setup Language Model Configuration Source: https://growgraph.github.io/ontocast/reference/tool/llm Asynchronously sets up the language model based on the provided configuration. This method should be called after instance creation. ```python async def setup(self): """Set up the language model based on the configured provider. ``` -------------------------------- ### Get known prefixes Source: https://growgraph.github.io/ontocast/reference/onto/rdfgraph Get currently known prefixes from the context. ```APIDOC ## RDFGraph.get_known_prefixes ### Description Get currently known prefixes from context. ### Method Signature `@classmethod RDFGraph.get_known_prefixes() -> dict[str, str] | None` ### Returns * **dict[str, str] | None** - Dictionary mapping prefix names to namespace URIs, or None. ``` -------------------------------- ### `__init__` method Source: https://growgraph.github.io/ontocast/reference/tool/llm Initializes the LLM tool, setting up caching and optionally a budget tracker. ```APIDOC ## `__init__(cache=None, budget_tracker=None, **kwargs)` ### Description Initialize the LLM tool. ### Parameters - **`cache`** (`Cacher | None`): Optional shared Cacher instance. If None, creates a new one. Default: `None` - **`budget_tracker`** (`Any`): Optional budget tracker instance for usage statistics. Default: `None` - **`**kwargs`** (`Any`): Additional keyword arguments passed to the parent class. Default: `{}` ``` -------------------------------- ### Run OntoCast Server Source: https://growgraph.github.io/ontocast/getting_started/quickstart Start the OntoCast server using the CLI. Configuration is automatically detected from the .env file. You can specify input paths or chunk limits for testing. ```bash # Backend automatically detected from .env configuration ontocast --env-path .env ``` ```bash # Process specific file ontocast --env-path .env --input-path ./document.pdf ``` ```bash # Process with chunk limit (for testing) ontocast --env-path .env --head-chunks 5 ``` -------------------------------- ### Loading and Accessing OntoCast Configuration Source: https://growgraph.github.io/ontocast/user_guide/configuration Demonstrates how to import the Config class, instantiate it, and access various configuration settings including server and tool-specific parameters. ```python from ontocast.config import Config config = Config() tool_config = config.get_tool_config() print(config.server.port) print(config.server.max_visits_per_node) print(tool_config.llm_config.provider) print(tool_config.path_config.cache_dir) ``` -------------------------------- ### JSON Document Example Source: https://growgraph.github.io/ontocast Example of a JSON document structure required for processing. It must include a 'text' field. ```json { "text": "abc" } ``` -------------------------------- ### Setup LLM Provider Source: https://growgraph.github.io/ontocast/reference/tool/llm Asynchronously sets up the language model based on the configured provider (e.g., OpenAI, Ollama). Raises ValueError for unsupported providers. ```python async def setup(self): """Set up the language model based on the configured provider. Raises: ValueError: If the provider is not supported. """ if self.config.provider == LLMProvider.OPENAI: if self.config.model_name.startswith("gpt-5"): self.config.temperature = 1.0 logger.warning( f"Setting temperature to {self.config.temperature} for gpt-5 class " f"model {self.config.model_name}" ) self._llm = ChatOpenAI( model=self.config.model_name, # type: ignore temperature=self.config.temperature, base_url=self.config.base_url, # type: ignore api_key=( SecretStr(self.config.api_key) if self.config.api_key else None ), # type: ignore ) elif self.config.provider == LLMProvider.OLLAMA: self._llm = ChatOllama( model=self.config.model_name, base_url=self.config.base_url, temperature=self.config.temperature, ) else: raise ValueError(f"Unsupported provider: {self.config.provider}") ``` -------------------------------- ### Get All Chunk IDs Source: https://growgraph.github.io/ontocast/reference/tool/graph_version_manager Retrieves a list of all unique chunk identifiers currently managed. Use this to get an overview of available fact data. ```python def get_all_chunk_ids(self) -> list[str]: """Get all chunk identifiers. Returns: list[str]: All chunk identifiers. """ return list(self.facts_versions.keys()) ``` -------------------------------- ### Initialize Toolbox - Python Source: https://growgraph.github.io/ontocast/reference/toolbox Asynchronously initializes the toolbox by synchronizing ontologies, adding them to the manager, and updating their properties using the LLM tool. This is a crucial setup step. ```python async def initialize(self) -> None: """Initialize the toolbox with ontologies and their properties. This method synchronizes ontologies between filesystem and triple store, then fetches ontologies from the triple store and updates their properties using the LLM tool. """ # Synchronize ontologies and add them to ontology manager synchronized_ontologies = await self._synchronize_ontologies() for ontology in synchronized_ontologies: self.ontology_manager.add_ontology(ontology) await update_ontology_manager(om=self.ontology_manager, llm_tool=self.llm) ``` -------------------------------- ### Start and Stop Neo4j Docker Container Source: https://growgraph.github.io/ontocast/user_guide/triple_stores Commands to start Neo4j in detached mode and stop it using Docker Compose. Ensure you are in the correct directory. ```bash # Start cd docker/neo4j docker compose --env-file .env neo4j up -d # Stop docker compose stop neo4j ``` -------------------------------- ### Initialize FilesystemTripleStoreManager Source: https://growgraph.github.io/ontocast/reference/tool/triple_manager/filesystem_manager Initializes the filesystem manager with working and ontology directories. Pass working_directory and ontology_path as keyword arguments. ```python manager = FilesystemTripleStoreManager( working_directory="/path/to/work", ontology_path="/path/to/ontologies" ) ``` -------------------------------- ### Get Latest Ontology Version Source: https://growgraph.github.io/ontocast/reference/tool/graph_version_manager Retrieves the most recent version of an ontology for a given ontology ID. Returns None if no versions are found. Use this to get the current ontology definition. ```python def get_latest_ontology_version(self, ontology_id: str) -> GraphVersion | None: """Get the latest version of an ontology. Args: ontology_id: The ontology identifier. Returns: GraphVersion: The latest version, or None if not found. """ versions = self.ontology_versions.get(ontology_id, []) return versions[-1] if versions else None ``` -------------------------------- ### Initialize Toolbox Source: https://growgraph.github.io/ontocast/reference/toolbox Initializes the toolbox by synchronizing ontologies between the filesystem and triple store, then fetching and updating ontology properties using the LLM tool. ```python async def initialize(self) -> None: """Initialize the toolbox with ontologies and their properties. This method synchronizes ontologies between filesystem and triple store, then fetches ontologies from the triple store and updates their properties using the LLM tool. """ # Synchronize ontologies and add them to ontology manager synchronized_ontologies = await self._synchronize_ontologies() for ontology in synchronized_ontologies: self.ontology_manager.add_ontology(ontology) await update_ontology_manager(om=self.ontology_manager, llm_tool=self.llm) ``` -------------------------------- ### Start and Stop Fuseki Docker Container Source: https://growgraph.github.io/ontocast/user_guide/triple_stores Commands to start Fuseki in detached mode and stop it using Docker Compose. Ensure you are in the correct directory and use the container name from your .env file. ```bash # Start cd docker/fuseki docker compose --env-file .env fuseki up -d # Stop # (use the container name from your .env, e.g. test.fuseki) docker compose stop test.fuseki ``` -------------------------------- ### Start OntoCast Server with Caching Source: https://growgraph.github.io/ontocast/user_guide/llm_caching Initiate the OntoCast server, enabling automatic caching for all LLM operations. Specify environment path and working directory. ```bash # Start server with automatic caching ontocast --env-path .env --working-directory /data/working ``` -------------------------------- ### Initialize ToolBox with Configuration Source: https://growgraph.github.io/ontocast/reference/toolbox Initializes the ToolBox with a configuration object. It sets up LLM tools, web search providers, and manages different triple store backends (Fuseki, Neo4j, filesystem) based on the provided configuration. Ensure at least one backend is configured. ```python class ToolBox: """A container class for all tools used in the ontology processing workflow. This class initializes and manages various tools needed for document processing, ontology management, and LLM interactions. Args: config: Configuration object containing all necessary settings. """ def __init__(self, config: Config): # Store the config for later use self.config = config # Get tool configuration tool_config = config.get_tool_config() # Extract configuration values working_directory = tool_config.path_config.working_directory ontology_directory = tool_config.path_config.ontology_directory # Create shared cache instance with config self.shared_cache = Cacher(config=config) # LLM configuration - pass the entire LLM config to the tool self.llm_provider = tool_config.llm_config.provider self.llm: LLMTool = LLMTool.create( config=tool_config.llm_config, cache=self.shared_cache ) self.search_provider = None if tool_config.web_search.enabled: if tool_config.web_search.provider == WebSearchProvider.DUCKDUCKGO: self.search_provider = DuckDuckGoSearchProvider( timeout_seconds=tool_config.web_search.timeout_seconds, region=tool_config.web_search.region, safesearch=tool_config.web_search.safesearch, ) else: raise ValueError( f"Unsupported web-search provider: {tool_config.web_search.provider}" ) self.atomic_tools = AtomicToolBox( llm_provider=self, search_provider=self.search_provider, web_search_config=tool_config.web_search, ) # Initialize managers based on backend configuration self.filesystem_manager: FilesystemTripleStoreManager | None = None self.triple_store_manager: TripleStoreManager | None = None # Automatically determine which backends to use based on available configuration use_fuseki = tool_config.fuseki.uri and tool_config.fuseki.auth use_neo4j = ( tool_config.neo4j.uri is not None and tool_config.neo4j.auth is not None ) use_filesystem_triple_store = working_directory is not None use_filesystem_manager = working_directory is not None # Validate that we have at least one backend configured if not any([use_fuseki, use_neo4j, use_filesystem_triple_store]): raise ValueError( "No backend configured. Please provide Fuseki/Neo4j credentials or working directory and ontology directory." ) # Create main triple store manager (only one can be active) # Note: Dataset/database is NOT cleaned on initialization # Use the clean() method or /flush endpoint to explicitly clean the store if use_fuseki and tool_config.fuseki.uri and tool_config.fuseki.auth: self.triple_store_manager = FusekiTripleStoreManager( uri=tool_config.fuseki.uri, auth=tool_config.fuseki.auth, dataset=tool_config.fuseki.dataset, ontologies_dataset=tool_config.fuseki.ontologies_dataset, ) elif use_neo4j and tool_config.neo4j.uri and tool_config.neo4j.auth: self.triple_store_manager = Neo4jTripleStoreManager( ``` -------------------------------- ### prefix property Source: https://growgraph.github.io/ontocast/reference/onto/ontology Get the namespace prefix for this ontology. ```APIDOC ## prefix property ### Description Get the namespace prefix for this ontology. ### Returns - **str | None**: The namespace prefix if found, None otherwise. ``` -------------------------------- ### Initialize LLMTool with Cache and Budget Tracker Source: https://growgraph.github.io/ontocast/reference/tool/llm Initializes the LLM tool, setting up the cache and budget tracker. If no cache is provided, a new one is created. ```python def __init__( self, cache: Cacher | None = None, budget_tracker: Any = None, **kwargs, ): """Initialize the LLM tool. Args: cache: Optional shared Cacher instance. If None, creates a new one. budget_tracker: Optional budget tracker instance for usage statistics. **kwargs: Additional keyword arguments passed to the parent class. """ super().__init__(**kwargs) self._llm = None self.budget_tracker = budget_tracker # Initialize cache - use shared cacher or create new one if cache is not None: self.cache = ToolCacher(cache, "llm") else: # Fallback for backward compatibility shared_cache = Cacher() self.cache = ToolCacher(shared_cache, "llm") ``` -------------------------------- ### GraphVersion.get_namespaces() Source: https://growgraph.github.io/ontocast/reference/tool/graph_version_manager Get the namespaces bound in this version of the graph. ```APIDOC ## GraphVersion.get_namespaces() ### Description Get the namespaces bound in this version. ### Method `get_namespaces` ### Parameters None ### Returns - `dict[str, str]`: A dictionary mapping namespace prefixes to their URIs. ``` -------------------------------- ### GraphVersion.get_size() Source: https://growgraph.github.io/ontocast/reference/tool/graph_version_manager Get the number of triples in this version of the graph. ```APIDOC ## GraphVersion.get_size() ### Description Get the number of triples in this version. ### Method `get_size` ### Parameters None ### Returns - `int`: The number of triples in the graph. ``` -------------------------------- ### OntoCast CLI Serve Command Source: https://growgraph.github.io/ontocast/reference/cli/serve This is the main entry point for the OntoCast server/CLI. It automatically infers backend selection from available configuration (Fuseki, Neo4j, Filesystem Triple Store, Filesystem Manager). No explicit backend flags are needed as backends are auto-detected. It can process input files or start a server. ```python @click.command() @click.option( "--env-file", type=click.Path(path_type=pathlib.Path), required=True, default=".env", help="Path to .env file containing backend and configuration settings", ) @click.option("--input-path", type=click.Path(path_type=pathlib.Path), default=None) @click.option("--head-chunks", type=int, default=None) def run( env_file: pathlib.Path, input_path: pathlib.Path | None, head_chunks: int | None, ): """ 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. """ _ = load_dotenv(dotenv_path=env_file.expanduser()) # Global configuration instance config = Config() # Validate LLM configuration config.validate_llm_config() if config.logging_level is not None: try: logger_conf = f"logging.{config.logging_level}.conf" logging.config.fileConfig(logger_conf, disable_existing_loggers=False) logger.debug("debug is on") except Exception as e: logger.error(f"could set logging level correctly {e}") if config.tool_config.path_config.working_directory is not None: config.tool_config.path_config.working_directory = pathlib.Path( config.tool_config.path_config.working_directory ).expanduser() config.tool_config.path_config.working_directory.mkdir( parents=True, exist_ok=True ) else: raise ValueError( "Working directory must be provided via CLI argument or WORKING_DIRECTORY config" ) if config.tool_config.path_config.ontology_directory is not None: config.tool_config.path_config.ontology_directory = pathlib.Path( config.tool_config.path_config.ontology_directory ).expanduser() # Create ToolBox with config tools: ToolBox = ToolBox(config) asyncio.run(tools.initialize()) workflow: CompiledStateGraph = create_agent_graph(tools) if input_path: input_path = input_path.expanduser() files = sorted( crawl_directories( input_path, suffixes=tuple([".json"] + list(tools.converter.supported_extensions))) ) recursion_limit = calculate_recursion_limit( head_chunks, config.server, ) async def process_files(): for file_path in files: try: state = AgentState( files={file_path.as_posix(): file_path.read_bytes()}, max_visits=config.server.max_visits_per_node, max_chunks=head_chunks, render_mode=config.server.render_mode, dataset=config.tool_config.fuseki.dataset, ) async for _ in workflow.astream( state, stream_mode="values", config=RunnableConfig(recursion_limit=recursion_limit), ): pass except Exception as e: logger.error(f"Error processing {file_path}: {str(e)}") asyncio.run(process_files()) else: app = create_app( tools=tools, server_config=config.server, head_chunks=head_chunks, ) ``` -------------------------------- ### ontology_id Source: https://growgraph.github.io/ontocast/reference/onto/state Gets the ontology ID from the current ontology. ```APIDOC ## ontology_id ### Description Get the ontology ID. ### Property @property def ontology_id(self): ### Returns str: The ontology ID. ``` -------------------------------- ### get_context_for_agent Source: https://growgraph.github.io/ontocast/reference/onto/state Gets or creates the context for a specific agent type. ```APIDOC ## get_context_for_agent ### Description Get or create context for a specific agent. ### Method Signature def get_context_for_agent(self, agent_type: AgentType) -> AgentContext: ### Parameters #### Arguments - **agent_type** (AgentType): Type of agent (renderer, critic, etc.). ### Returns AgentContext: The context for the agent. ``` -------------------------------- ### __init__ Source: https://growgraph.github.io/ontocast/reference/tool/triple_manager/neo4j Initializes the Neo4j triple store manager, setting up the connection, n10s plugin configuration, and creating necessary database constraints and indexes. The database is not cleaned on initialization. ```APIDOC ## Neo4jTripleStoreManager.__init__ ### Description Initialize the Neo4j triple store manager. This method sets up the connection to Neo4j, initializes the n10s plugin configuration, and creates necessary constraints and indexes. The database is NOT cleaned on initialization. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method Signature `__init__(uri=None, auth=None, **kwargs)` ### Parameters - **uri** (string) - Optional - Neo4j connection URI (e.g., "bolt://localhost:7687"). - **auth** (string) - Optional - Authentication tuple (username, password) or string in "user/password" format. - **kwargs** (dict) - Optional - Additional keyword arguments passed to the parent class. ### Raises - **ImportError**: If the neo4j Python driver is not installed. ### Example ```python manager = Neo4jTripleStoreManager( uri="bolt://localhost:7687", auth="neo4j/password" ) # To clean the database, use the clean() method explicitly: await manager.clean() ``` ``` -------------------------------- ### doc_namespace Source: https://growgraph.github.io/ontocast/reference/onto/state Gets the document namespace, derived from the document IRI. ```APIDOC ## doc_namespace ### Description Get the document namespace. ### Property @property def doc_namespace(self): ### Returns str: The document namespace. ``` -------------------------------- ### Initialize LLM Tool with Budget Tracker Source: https://growgraph.github.io/ontocast/reference/toolbox Creates and returns an LLM tool instance, associating it with a specific budget tracker for managing resource consumption. ```python async def get_llm_tool(self, budget_tracker): """Get an LLM tool instance with a specific budget tracker. Args: budget_tracker: The budget tracker instance to use. Returns: LLMTool: LLM tool with the specified budget tracker. """ # Create a new LLM tool with the budget tracker return await LLMTool.acreate( config=self.config.tool_config.llm_config, cache=self.shared_cache, budget_tracker=budget_tracker, ) ``` -------------------------------- ### Get UPDATE Operations Source: https://growgraph.github.io/ontocast/reference/onto/sparql_models Retrieves all operations of type UPDATE from a collection. ```python def get_update_operations(self) -> list[SPARQLOperationModel]: """Get all UPDATE operations.""" return [ op for op in self.operations if op.operation_type == SPARQLOperationType.UPDATE ] ``` -------------------------------- ### __init__ Source: https://growgraph.github.io/ontocast/reference/tool/sparql Initializes the SPARQL tool. An optional triple store manager can be provided for persistent storage. ```APIDOC ## __init__ ### Description Initialize SPARQL tool. ### Parameters #### Path Parameters - **triple_store_manager** (TripleStoreManager | None) - Optional - Optional triple store manager for persistent storage. Defaults to None. ``` -------------------------------- ### Setup Language Model Source: https://growgraph.github.io/ontocast/reference/tool/__init__ Asynchronously sets up the language model based on the configured provider. This method handles the initialization of different LLM clients (e.g., OpenAI, Ollama) and may adjust parameters like temperature based on the model. ```APIDOC ## `setup()` `async` ### Description Set up the language model based on the configured provider. ### Raises - **ValueError** - If the provider is not supported. ``` -------------------------------- ### Get DELETE Operations Source: https://growgraph.github.io/ontocast/reference/onto/sparql_models Retrieves all operations of type DELETE from a collection. ```python def get_remove_operations(self) -> list[SPARQLOperationModel]: """Get all DELETE operations.""" return [ op for op in self.operations if op.operation_type == SPARQLOperationType.DELETE ] ``` -------------------------------- ### Get INSERT Operations Source: https://growgraph.github.io/ontocast/reference/onto/sparql_models Retrieves all operations of type INSERT from a collection. ```python def get_add_operations(self) -> list[SPARQLOperationModel]: """Get all INSERT operations.""" return [ op for op in self.operations if op.operation_type == SPARQLOperationType.INSERT ] ``` -------------------------------- ### FilesystemTripleStoreManager Initialization Source: https://growgraph.github.io/ontocast/reference/tool/triple_manager/filesystem_manager Initializes the FilesystemTripleStoreManager with specified working and ontology directories. ```APIDOC ## FilesystemTripleStoreManager ### Description Filesystem-based implementation of triple store management. This class provides a concrete implementation of triple store management using the local filesystem for storage. It reads and writes ontologies and facts as Turtle (.ttl) files in specified directories. ### Attributes - `working_directory` (Path | None): Path to the working directory for storing data. - `ontology_path` (Path | None): Optional path to the ontology directory for loading ontologies. ### Method `__init__(self, **kwargs)` ### Parameters #### Keyword Arguments - `working_directory` (Path): Path to the working directory for storing data. - `ontology_path` (Path): Path to the ontology directory for loading ontologies. ### Example ```python manager = FilesystemTripleStoreManager( working_directory="/path/to/work", ontology_path="/path/to/ontologies" ) ``` ``` -------------------------------- ### get_llm_tool(budget_tracker) Source: https://growgraph.github.io/ontocast/reference/toolbox Get an LLM tool instance with a specific budget tracker. ```APIDOC ## get_llm_tool(budget_tracker) ### Description Get an LLM tool instance with a specific budget tracker. ### Method POST (assumed, as it creates a resource) ### Endpoint (Not specified, likely a method within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **budget_tracker** (any) - Required - The budget tracker instance to use. ### Returns - `LLMTool`: LLM tool with the specified budget tracker. ``` -------------------------------- ### Setup LLM Provider Source: https://growgraph.github.io/ontocast/reference/tool/__init__ Sets up the language model based on the configured provider. This method should be called after instance creation to prepare the LLM for use. ```python async def setup(self): """Set up the language model based on the configured provider. ``` -------------------------------- ### Get All Entities Source: https://growgraph.github.io/ontocast/reference/tool/validate Extracts all unique entities (URIs) present in the RDF graph. ```APIDOC ## get_all_entities() ### Description Extract all unique entities from the graph. ### Returns - **set[URIRef]]** - Set of all unique entity URIs in the graph. ``` -------------------------------- ### initialize() Source: https://growgraph.github.io/ontocast/reference/toolbox Initialize the toolbox with ontologies and their properties. ```APIDOC ## initialize() ### Description Initialize the toolbox with ontologies and their properties. This method synchronizes ontologies between the filesystem and the triple store, then fetches ontologies from the triple store and updates their properties using the LLM tool. ### Method POST (assumed, as it performs an initialization action) ### Endpoint (Not specified, likely a method within a class) ### Parameters None ### Returns None ``` -------------------------------- ### doc_iri Source: https://growgraph.github.io/ontocast/reference/onto/state Gets the document IRI (Internationalized Resource Identifier) for the current document. ```APIDOC ## doc_iri ### Description Get the document IRI. ### Property @property def doc_iri(self) -> URIRef: ### Returns URIRef: The document IRI. ``` -------------------------------- ### Get Known Prefixes Source: https://growgraph.github.io/ontocast/reference/onto/rdfgraph Retrieves the currently configured known prefixes from the context. ```python def get_known_prefixes(cls) -> dict[str, str] | None: """Get currently known prefixes from context. Returns: Dictionary mapping prefix names to namespace URIs, or None. """ return _known_prefixes_context.get() ``` -------------------------------- ### `__init__(**kwargs)` Source: https://growgraph.github.io/ontocast/reference/onto/state Initializes the agent state with provided keyword arguments. ```APIDOC ## `__init__(**kwargs)` ### Description Initialize the agent state with given keyword arguments. ### Parameters #### Keyword Arguments - **kwargs**: Arbitrary keyword arguments to initialize the state. ``` -------------------------------- ### __init__ Source: https://growgraph.github.io/ontocast/reference/onto/context Initializes the context manager. This is a constructor method. ```APIDOC ## __init__ ### Description Initializes the context manager. ### Method __init__ ### Parameters This method accepts arbitrary keyword arguments (**kwargs) for initialization. ### Code Example ```python context_manager = OntocastContextManager(**kwargs) ``` ``` -------------------------------- ### Get Ontology ID Source: https://growgraph.github.io/ontocast/reference/onto/state Retrieves the ontology ID from the current ontology object. ```python return self.current_ontology.ontology_id ``` -------------------------------- ### `__init__(**kwargs)` Source: https://growgraph.github.io/ontocast/reference/tool/__init__ Initializes the tool, accepting keyword arguments passed to the parent class. ```APIDOC ## `__init__(**kwargs)` ### Description Initialize the tool. ### Parameters #### Keyword Arguments - `**kwargs`: Keyword arguments passed to the parent class. ### Source `ontocast/tool/onto.py` ``` -------------------------------- ### Get All Ontology IRIs Source: https://growgraph.github.io/ontocast/reference/tool/ontology_manager Retrieves a list of all unique ontology IRIs managed by the OntologyManager. ```python def get_ontology_iris(self) -> list[str]: """Get a list of all ontology IRIs. Returns: list[str]: List of ontology IRIs. """ return list(self.ontology_versions.keys()) ```