owlapy.agen_kg.domain_examples_cache
Domain-Specific Few-Shot Examples Cache Manager
This module manages caching of domain-specific few-shot examples generated by the DomainGraphExtractor. Examples are saved to and loaded from JSON files organized by domain.
The cache helps avoid regenerating examples for the same domain multiple times, improving performance when processing multiple documents from the same domain.
Attributes
Classes
Manages caching of domain-specific few-shot examples. |
Module Contents
- owlapy.agen_kg.domain_examples_cache.logger
- owlapy.agen_kg.domain_examples_cache.EXAMPLE_TYPE_MAPPING
- owlapy.agen_kg.domain_examples_cache.VARIABLE_NAME_TO_TYPE
- class owlapy.agen_kg.domain_examples_cache.DomainExamplesCache(cache_dir: str | None = None)[source]
Manages caching of domain-specific few-shot examples.
Examples are stored in JSON format with the filename pattern: domain_examples_{domain_name}.json
The cache directory defaults to the current working directory but can be configured.
- cache_dir
- save_examples(domain: str, examples: Dict[str, str]) bool[source]
Save generated examples for a domain.
- Parameters:
domain – The domain name.
examples – Dictionary mapping example types to example strings. Expected keys are from EXAMPLE_TYPE_MAPPING.keys()
- Returns:
True if save was successful, False otherwise.
- load_examples(domain: str) Dict[str, str] | None[source]
Load cached examples for a domain.
- Parameters:
domain – The domain name.
- Returns:
Dictionary mapping example types to example strings, or None if not cached.
- examples_exist(domain: str) bool[source]
Check if cached examples exist for a domain.
- Parameters:
domain – The domain name.
- Returns:
True if examples are cached, False otherwise.
- get_cache_file_path(domain: str) str[source]
Get the full path to the cache file for a domain.
- Parameters:
domain – The domain name.
- Returns:
String path to the cache file.
- clear_domain_cache(domain: str) bool[source]
Delete the cache file for a domain.
- Parameters:
domain – The domain name.
- Returns:
True if deletion was successful, False otherwise.