Domain Genflow
verifia.generation.DomainGenFlow
A class to generate a domain graph flow based on provided dataset, PDFs or vector database, and a model card.
This class encapsulates the process of loading the necessary context (data, agents, and model card) to build and run a domain graph. It allows the context to be loaded from file paths or directly from provided objects. It orchestrates the domain graph generation, human interruptions, and final domain export.
__init__()
Initialize the DomainGenFlow instance.
launch(server_name=DEFAULT_HOST, server_port=DEFAULT_PORT)
Launch the interactive Gradio UI tied to this flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_name
|
str
|
Host/IP for the Gradio server. |
DEFAULT_HOST
|
server_port
|
int
|
Port for the Gradio server. |
DEFAULT_PORT
|
load_ctx(data_fpath=None, dataframe=None, pdfs_dirpath=None, db_str_content=None, vectordb=None, model_card_fpath=None, model_card=None)
Load and initialize the domain context required to build the domain graph.
At least one of 'data_fpath' or 'dataframe' must be provided, as well as one of 'pdfs_dirpath', 'vectordb', or 'db_str_content'. Similarly, either 'model_card' or 'model_card_fpath' must be provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_fpath
|
Optional[Union[str, Path]]
|
Path to the CSV or data file. |
None
|
dataframe
|
Optional[DataFrame]
|
DataFrame containing the data. |
None
|
pdfs_dirpath
|
Optional[Union[str, Path]]
|
Directory path containing PDF files. |
None
|
db_str_content
|
Optional[str]
|
String content to build a vector database. |
None
|
vectordb
|
Optional[Chroma]
|
Pre-initialized vector database. |
None
|
model_card_fpath
|
Optional[Union[str, Path]]
|
Path to the model card YAML file. |
None
|
model_card
|
Optional[Dict[str, Any]]
|
Model card as a dictionary. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DomainGenFlow |
DomainGenFlow
|
The instance with the graph_context loaded. |
Raises:
Type | Description |
---|---|
ValueError
|
If required context arguments are missing. |
next_action(gen, action, yaml_str, instructions='')
Resume the flow based on a UI action (validate/regenerate/finish).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gen
|
Generator[Dict[str, Any], Any, None]
|
Active generator from start or previous next_action. |
required |
action
|
str
|
Action keyword. |
required |
yaml_str
|
str
|
Current YAML shown to the user. |
required |
instructions
|
str
|
User instructions for regeneration. |
''
|
Returns:
Type | Description |
---|---|
Tuple[str, str, Generator[Dict[str, Any], Any, None]]
|
Tuple of updated (yaml_text, validation_output, generator). |
start()
Kick off the flow until first human interrupt, returning initial YAML and validation.
Returns:
Name | Type | Description |
---|---|---|
init_yaml |
str
|
Initial generated YAML spec. |
init_val |
str
|
Initial validation output. |
gen |
Generator[Dict[str, Any], Any, None]
|
Generator to drive subsequent actions. |