dataflow.registry.modelsΒΆ
Models for the Haive Registry System.
This module defines the core data models used by the registry system to represent different types of entities, configurations, dependencies, and other components. These models provide a structured way to store and retrieve information about various components in the Haive ecosystem.
The models use Pydantic for validation, serialization, and deserialization, ensuring type safety and consistent data structures throughout the system.
- Classes:
EntityType: Enumeration of entity types that can be registered ConfigType: Enumeration of configuration types for registry items DependencyType: Enumeration of dependency relationships between entities ImportStatus: Enumeration of import operation status values RegistryItem: Base model for all registry entries Configuration: Model for configuration data associated with registry items GraphDefinition: Model for graph structure definitions (nodes and edges) Dependency: Model for dependency relationships between registry items EnvironmentVar: Model for environment variable requirements ImportLogItem: Model for logging import operations
Example
Creating registry models:
>>> from haive.dataflow.registry.models import RegistryItem, EntityType
>>> from datetime import datetime
>>>
>>> # Create a new registry item
>>> item = RegistryItem(
... name="TextClassifier",
... type=EntityType.AGENT,
... description="Classifies text into categories",
... module_path="haive.agents.classifiers",
... class_name="TextClassifierAgent",
... created_at=datetime.now()
... )
>>>
>>> # Access properties
>>> print(f"Registry item: {item.name} ({item.type})")
>>> print(f"Created at: {item.created_at}")
ClassesΒΆ
Types of configurations. |
|
Configuration for a registry item. |
|
Dependency relationship between registry items. |
|
Types of dependencies between entities. |
|
Types of entities that can be registered. |
|
Environment variable requirement for a registry item. |
|
Graph definition for a registry item. |
|
Log entry for import operations. |
|
Import operation status. |
|
Definition of an MCP prompt template. |
|
Definition of an MCP resource. |
|
Configuration for an MCP server. |
|
Health status of an MCP server. |
|
Definition of an MCP tool. |
|
Transport types for MCP servers. |
|
Base model for registry items. |
Module ContentsΒΆ
- class dataflow.registry.models.ConfigTypeΒΆ
-
Types of configurations.
Initialize self. See help(type(self)) for accurate signature.
- class dataflow.registry.models.Configuration(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Configuration for a registry item.
This model represents configuration data associated with a registry item. Configurations can include schema definitions, initialization parameters, prompt templates, and other settings needed for component operation.
- Parameters:
data (Any)
- config_typeΒΆ
Type of configuration (STATE_SCHEMA, INPUT_SCHEMA, etc.)
- Type:
- created_atΒΆ
Timestamp when the configuration was created
- Type:
datetime, optional
- updated_atΒΆ
Timestamp when the configuration was last updated
- Type:
datetime, optional
Example
>>> from haive.dataflow.registry.models import Configuration, ConfigType >>> from datetime import datetime >>> >>> config = Configuration( ... registry_id="tool-123", ... config_type=ConfigType.INPUT_SCHEMA, ... config_data={ ... "type": "object", ... "properties": { ... "text": {"type": "string", "description": "Text to process"}, ... "max_length": {"type": "integer", "default": 100} ... }, ... "required": ["text"] ... }, ... created_at=datetime.now() ... )
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.
- class dataflow.registry.models.Dependency(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Dependency relationship between registry items.
This model represents a dependency relationship between two registry items, such as a tool requiring a specific engine, or an agent extending another agent. It captures the type of relationship and the entities involved.
- Parameters:
data (Any)
- dependency_typeΒΆ
Type of dependency relationship
- Type:
- created_atΒΆ
Timestamp when the dependency was created
- Type:
datetime, optional
Example
>>> from haive.dataflow.registry.models import Dependency, DependencyType >>> from datetime import datetime >>> >>> dependency = Dependency( ... registry_id="tool-123", ... dependent_id="engine-456", ... dependency_type=DependencyType.REQUIRES, ... created_at=datetime.now() ... )
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.
- class dataflow.registry.models.DependencyTypeΒΆ
-
Types of dependencies between entities.
Initialize self. See help(type(self)) for accurate signature.
- class dataflow.registry.models.EntityTypeΒΆ
-
Types of entities that can be registered.
Initialize self. See help(type(self)) for accurate signature.
- class dataflow.registry.models.EnvironmentVar(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Environment variable requirement for a registry item.
This model represents an environment variable that a component requires or can use. It tracks whether the variable is required, and can provide a default value for optional variables.
- Parameters:
data (Any)
- created_atΒΆ
Timestamp when the entry was created
- Type:
datetime, optional
Example
>>> from haive.dataflow.registry.models import EnvironmentVar >>> from datetime import datetime >>> >>> env_var = EnvironmentVar( ... registry_id="agent-123", ... env_name="OPENAI_API_KEY", ... is_required=True, ... created_at=datetime.now() ... ) >>> >>> optional_var = EnvironmentVar( ... registry_id="tool-456", ... env_name="DEBUG_LEVEL", ... is_required=False, ... default_value="INFO", ... created_at=datetime.now() ... )
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.
- class dataflow.registry.models.GraphDefinition(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Graph definition for a registry item.
This model represents a graph structure definition for a component, such as an agent or engine. It stores the nodes and edges that define the componentβs execution flow or structure.
- Parameters:
data (Any)
- created_atΒΆ
Timestamp when the graph was created
- Type:
datetime, optional
- updated_atΒΆ
Timestamp when the graph was last updated
- Type:
datetime, optional
Example
>>> from haive.dataflow.registry.models import GraphDefinition >>> from datetime import datetime >>> >>> graph = GraphDefinition( ... registry_id="agent-123", ... nodes=[ ... {"id": "node1", "type": "input", "config": {...}}, ... {"id": "node2", "type": "processing", "config": {...}}, ... {"id": "node3", "type": "output", "config": {...}} ... ], ... edges=[ ... {"source": "node1", "target": "node2"}, ... {"source": "node2", "target": "node3"} ... ], ... created_at=datetime.now() ... )
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.
- class dataflow.registry.models.ImportLogItem(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Log entry for import operations.
This model represents a log entry for an import operation, recording the details of a single entity import attempt. It tracks the status, any error messages, and the session it belongs to.
- Parameters:
data (Any)
- statusΒΆ
Status of the import operation (SUCCESS, FAILURE)
- Type:
Example
>>> from haive.dataflow.registry.models import ImportLogItem, ImportStatus >>> from datetime import datetime >>> >>> log_entry = ImportLogItem( ... import_session="session-123", ... entity_name="gpt-4", ... entity_type="llm_model", ... status=ImportStatus.SUCCESS, ... message="Successfully imported model" ... ) >>> >>> error_log = ImportLogItem( ... import_session="session-123", ... entity_name="invalid-model", ... entity_type="llm_model", ... status=ImportStatus.FAILURE, ... message="Failed to import model", ... traceback="ImportError: Model not found" ... )
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.
- class dataflow.registry.models.ImportStatusΒΆ
-
Import operation status.
Initialize self. See help(type(self)) for accurate signature.
- class dataflow.registry.models.MCPPromptDefinition(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Definition of an MCP prompt template.
This model represents a prompt template provided by an MCP server, including variables, instructions, and metadata for prompt execution.
- Parameters:
data (Any)
Example
>>> prompt = MCPPromptDefinition( ... name="code_review", ... description="Review code for best practices", ... server_name="github", ... template="Review this code: {code}", ... variables=[{"name": "code", "type": "string", "required": True}], ... tags=["code", "review"] ... )
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.
- class dataflow.registry.models.MCPResourceDefinition(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Definition of an MCP resource.
This model represents a resource provided by an MCP server, such as files, datasets, or other data sources that can be accessed by LLMs.
- Parameters:
data (Any)
- last_modifiedΒΆ
Last modification timestamp
- Type:
datetime, optional
Example
>>> resource = MCPResourceDefinition( ... name="project_docs", ... uri="file:///project/docs/", ... server_name="filesystem", ... mime_type="text/markdown", ... description="Project documentation files" ... )
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.
- class dataflow.registry.models.MCPServerConfig(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Configuration for an MCP server.
This model represents the configuration needed to connect to and interact with an MCP (Model Context Protocol) server, including connection details, authentication, and capabilities.
- Parameters:
data (Any)
- transportΒΆ
Communication transport type
- Type:
Example
>>> config = MCPServerConfig( ... name="filesystem", ... transport=MCPTransport.STDIO, ... command="npx", ... args=["-y", "@modelcontextprotocol/server-filesystem"], ... capabilities=["file_read", "file_write", "directory_list"] ... )
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.
- class dataflow.registry.models.MCPServerHealth(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Health status of an MCP server.
This model tracks the health and performance metrics of an MCP server, including connection status, response times, and error rates.
- Parameters:
data (Any)
- last_checkΒΆ
Last health check timestamp
- Type:
datetime
Example
>>> health = MCPServerHealth( ... server_name="filesystem", ... is_healthy=True, ... last_check=datetime.now(), ... response_time_ms=50.0, ... error_count=0, ... capabilities_available=["file_read", "file_write"] ... )
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.
- class dataflow.registry.models.MCPToolDefinition(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Definition of an MCP tool.
This model represents a tool provided by an MCP server, including its name, description, schema, and metadata needed for execution.
- Parameters:
data (Any)
- schemaΒΆ
JSON schema for tool parameters
Example
>>> tool = MCPToolDefinition( ... name="read_file", ... description="Read contents of a file", ... server_name="filesystem", ... schema={"type": "object", "properties": {"path": {"type": "string"}}}, ... tags=["filesystem", "read"] ... )
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.
- class dataflow.registry.models.MCPTransportΒΆ
-
Transport types for MCP servers.
Initialize self. See help(type(self)) for accurate signature.
- class dataflow.registry.models.RegistryItem(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Base model for registry items.
This model represents a component registered in the registry system, such as an agent, tool, engine, or game. It stores essential metadata about the component, including its type, location, and description.
- Parameters:
data (Any)
- typeΒΆ
Type of the component (AGENT, TOOL, etc.)
- Type:
- created_atΒΆ
Timestamp when the item was created
- Type:
datetime, optional
- updated_atΒΆ
Timestamp when the item was last updated
- Type:
datetime, optional
Example
>>> from haive.dataflow.registry.models import RegistryItem, EntityType >>> from datetime import datetime >>> >>> item = RegistryItem( ... name="TextSummarizer", ... type=EntityType.TOOL, ... description="Summarizes long text documents", ... module_path="haive.tools.summarizers", ... class_name="TextSummarizerTool", ... created_at=datetime.now(), ... metadata={"version": "1.0", "author": "Haive Team"} ... )
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.