Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/arg-tech/xaif/llms.txt

Use this file to discover all available pages before exploring further.

The AIF class provides several methods for validating, inspecting, and traversing xAIF structures without modifying them. These methods are safe to call at any point in a graph’s lifecycle and can be combined to build custom traversal or export pipelines on top of the in-memory dict.

is_valid_json_aif()

aif.is_valid_json_aif() -> bool
Checks that the AIF section of the document contains all three required top-level keys: nodes, edges, and locutions. Returns True if all three are present, False otherwise. This is a lightweight structural check — it does not validate the content of each list.
if aif.is_valid_json_aif():
    print("Valid xAIF structure")

is_json_aif_dialog()

aif.is_json_aif_dialog() -> bool
Returns True if any node in AIF["nodes"] has type == "L" (i.e. at least one locution node is present), indicating that the graph represents a dialogue. Returns False for monological graphs that contain only I-nodes and relation nodes.
print(aif.is_json_aif_dialog())  # True if locution nodes exist

get_speaker(node_id)

aif.get_speaker(node_id: int) -> tuple
Looks up the participant associated with the L-node identified by node_id. The method joins AIF["locutions"] and AIF["participants"] in memory to resolve the name. Returns: ("Firstname Lastname", participantID) when a match is found, or ("None None", "None") when node_id is not present in any locution entry.
name, person_id = aif.get_speaker(0)
print(name)       # "Speaker 1"
print(person_id)  # 0

get_next_max_id(component_type, id_key_word)

aif.get_next_max_id(component_type: str, id_key_word: str) -> int | str
Scans the specified component list and returns the next available ID — one greater than the current maximum. Handles both integer IDs and the underscore-format string IDs used by OVA exports (e.g. "12_0"). Returns 0 when the list is empty.
component_type
str
required
The top-level key in aif to scan. Use "nodes" to get the next node ID or "edges" to get the next edge ID.
id_key_word
str
required
The key within each entry that holds the ID value. Use "nodeID" when scanning nodes and "edgeID" when scanning edges.
next_node_id = aif.get_next_max_id("nodes", "nodeID")
next_edge_id = aif.get_next_max_id("edges", "edgeID")

get_i_node_ya_nodes_for_l_node(Lnode_ID)

aif.get_i_node_ya_nodes_for_l_node(Lnode_ID) -> tuple
Traverses AIF["edges"] to find the YA-node immediately downstream of the given L-node and the I-node downstream of that YA-node. This reflects the standard L → YA → I chain created by add_component("proposition", ...). Returns: (inode_id, ya_node_id) when the chain is found, or (None, None) if the L-node has no outgoing edges or its YA-node has no outgoing edges.
inode_id, ya_node_id = aif.get_i_node_ya_nodes_for_l_node(0)

get_xAIF_arrays(aif_section, xaif_elements)

aif.get_xAIF_arrays(aif_section: dict, xaif_elements: List) -> tuple
Extracts multiple fields from an AIF section dict by key name and returns them as a tuple in the same order as xaif_elements. Missing keys return None (the dict’s default for .get()).
aif_section
dict
required
Any dict conforming to the AIF section schema — typically aif.aif or a sub-section of it.
xaif_elements
List[str]
required
An ordered list of key names to extract. The returned tuple preserves this order.
nodes, edges = aif.get_xAIF_arrays(aif.aif, ["nodes", "edges"])

remove_entry(Lnode_ID)

aif.remove_entry(Lnode_ID)
Removes the specified L-node and its entire downstream proposition chain from the in-memory graph. Specifically, it:
  1. Resolves the YA-node and I-node connected to Lnode_ID via get_i_node_ya_nodes_for_l_node.
  2. Filters AIF["nodes"] to remove the L-node, I-node, and YA-node.
  3. Filters AIF["locutions"] to remove the locution entry for Lnode_ID.
  4. Filters AIF["edges"] to remove all edges that reference the L-node, I-node, or YA-node as either fromID or toID.
remove_entry is called internally by _add_segment after creating replacement nodes, but it can also be called directly to delete a locution and its proposition.
aif.remove_entry(2)  # Remove L-node 2 and its full proposition chain
remove_entry is irreversible. It modifies the in-memory dict in place and there is no undo mechanism. If you need to preserve the original graph, take a deep copy with copy.deepcopy(aif.xaif) before calling this method.

create_turn_entry(...)

aif.create_turn_entry(
    nodes,
    node_id,
    person_id,
    text_with_span,
    propositions,
    locutions,
    participants,
    dialogue
) -> tuple
A lower-level helper used internally by initilise_empty to populate node, locution, participant, and text-span lists from a single turn (or a batch of turns when dialogue=True). Returns a tuple of (nodes, locutions, participants, text_with_span, node_id, person_id) with all lists and counters updated. When dialogue=False (the default during plain-text initialisation), propositions is treated as a single string and attributed to "Default Speaker". When dialogue=True, propositions must be a list of (speaker_name, text) tuples.
nodes, locutions, participants, text_with_span, node_id, person_id = aif.create_turn_entry(
    nodes=[],
    node_id=0,
    person_id=0,
    text_with_span="",
    propositions="Here is the argument.",
    locutions=[],
    participants=[],
    dialogue=False
)

Build docs developers (and LLMs) love