haive.core.graph.common.field_utils¶

Utilities for working with fields and state objects.

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.

get_last_message_content(state[, message_key])

Get the content of the last message from state.

Module Contents¶

haive.core.graph.common.field_utils.extract_base_field(field_path)[source]¶

Extract the base field from a path.

Parameters:

field_path (str)

Return type:

str

haive.core.graph.common.field_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.common.field_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.common.field_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

haive.core.graph.common.field_utils.get_last_message_content(state, message_key='messages')[source]¶

Get the content of the last message from state.

Parameters:
  • state (Any) – State object

  • message_key (str) – Key for messages list

Returns:

Content string or None

Return type:

str | None