haive.core.graph.patterns.base¶
Base pattern definitions for the Haive framework.
This module provides the core classes for pattern definition, registration, and application in graph-based workflows.
Classes¶
Enhanced branch definition with metadata. |
|
Defines a requirement for a component needed by a pattern. |
|
Defines a reusable graph pattern. |
|
Definition of a parameter for patterns and branches. |
|
Enhanced metadata for graph patterns. |
Module Contents¶
- class haive.core.graph.patterns.base.BranchDefinition(/, **data)[source]¶
Bases:
pydantic.BaseModel
Enhanced branch definition with metadata.
Defines a reusable branch condition that can be applied to graphs.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- apply_to_graph(graph, source_node, **kwargs)[source]¶
Apply this branch directly to a graph.
- Parameters:
graph (Any) – Graph to add branch to
source_node (str) – Source node for branching
**kwargs – Parameter values
- Returns:
Modified graph
- Return type:
Any
- create_condition(**kwargs)[source]¶
Create a condition function with parameters.
- Parameters:
**kwargs – Parameter values
- Returns:
Configured condition function
- Return type:
- classmethod from_dict(data, func_resolver=None)[source]¶
Create from a serialized dictionary.
- Parameters:
func_resolver (collections.abc.Callable | None) – Optional function to resolve function references
- Returns:
New BranchDefinition instance
- Return type:
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.core.graph.patterns.base.ComponentRequirement(/, **data)[source]¶
Bases:
pydantic.BaseModel
Defines a requirement for a component needed by a pattern.
Component requirements can specify types, capabilities, and other attributes that must be present for a pattern to be applied successfully.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class haive.core.graph.patterns.base.GraphPattern(/, **data)[source]¶
Bases:
pydantic.BaseModel
Defines a reusable graph pattern.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- apply(graph, **kwargs)[source]¶
Apply this pattern to a graph.
- Parameters:
graph (Any)
- Return type:
Any
- abstractmethod create_node_config(node_name, **kwargs)[source]¶
Create a NodeConfig based on this pattern.
- Parameters:
node_name (str) – Name for the node
**kwargs – Configuration parameters
- Returns:
NodeConfig instance
- Return type:
Any
- classmethod from_dict(data, func_resolver=None)[source]¶
Create from a serialized dictionary.
- Parameters:
func_resolver (collections.abc.Callable | None) – Optional function to resolve function references
- Returns:
New GraphPattern instance
- Return type:
- validate_for_application(components, params)[source]¶
Validate that a pattern can be applied with the provided components and parameters.
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.core.graph.patterns.base.ParameterDefinition(/, **data)[source]¶
Bases:
pydantic.BaseModel
Definition of a parameter for patterns and branches.
Includes type information, validation rules, and documentation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class haive.core.graph.patterns.base.PatternMetadata(/, **data)[source]¶
Bases:
pydantic.BaseModel
Enhanced metadata for graph patterns.
Provides comprehensive information about a pattern, including its requirements, parameters, and documentation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)