haive.core.graph.branches.utils¶

Utility functions for working with branches.

Functions¶

extract_base_field(field_path)

Extract the base field from a path.

extract_field(state, field_path)

Extract a field value from state using a path.

extract_fields_from_function(func)

Extract field references from a function.

get_field_value(obj, key)

Get a field value using various access methods.

Module Contents¶

haive.core.graph.branches.utils.extract_base_field(field_path)[source]¶

Extract the base field from a path.

Parameters:

field_path (str)

Return type:

str

haive.core.graph.branches.utils.extract_field(state, field_path)[source]¶

Extract a field value from state using a path.

Supports: - Simple keys: “fieldname” - Nested paths: “nested.field.path” - Array indexing: “array.0.field” - Special paths: “messages.last.content”

Parameters:
  • state (Any) – State object

  • field_path (str) – Path to the field

Returns:

Extracted value or None if not found

Return type:

Any

haive.core.graph.branches.utils.extract_fields_from_function(func)[source]¶

Extract field references from a function.

Parameters:

func (callable) – Function to analyze

Returns:

Set of field names referenced

Return type:

set[str]

haive.core.graph.branches.utils.get_field_value(obj, key)[source]¶

Get a field value using various access methods.

Parameters:
  • obj (Any) – Object to extract from

  • key (Any) – Key or index to extract

Returns:

Extracted value or None if not found

Return type:

Any