haive.core.graph.node.composer.path_resolver¶
Path resolver for extracting values from objects using path notation.
This module provides path-based value extraction from objects, supporting simple field access initially, with progressive enhancement for complex paths.
Classes¶
Resolver for extracting values from objects using path notation. |
Module Contents¶
- class haive.core.graph.node.composer.path_resolver.PathResolver¶
Resolver for extracting values from objects using path notation.
This class handles path-based extraction from objects, supporting:
Phase 1: Simple field access (e.g., “messages”, “temperature”) Phase 2: Dot notation (e.g., “config.temperature”) Phase 2: Array access (e.g., “messages[0]”, “messages[-1]”) Phase 3: Advanced patterns (wildcards, method calls, etc.)
- extract_value(obj, path, default=None)¶
Extract value from object using path notation.
- Parameters:
obj (Any) – Object to extract from (dict, Pydantic model, etc.)
path (str) – Path string (e.g., “messages”, “config.temp”, “messages[0]”)
default (Any) – Default value if path not found or None
- Returns:
Extracted value or default
- Return type:
Any
Examples
# Simple field access (Phase 1) resolver = PathResolver() state = {“messages”: [“hello”], “temp”: 0.7}
value = resolver.extract_value(state, “messages”) # Returns: [“hello”]
# Dot notation (Phase 2) value = resolver.extract_value(state, “config.temperature”) # Returns: 0.7
# Array access (Phase 2) value = resolver.extract_value(state, “messages[0]”) # Returns: “hello”