Skip to main content

aixplain.v2.graph

from aixplain import AgentNode, Condition, ConditionDict, ConditionalNode, Edge, EdgeDict, Graph, GraphDict, InspectorNode, LLMNode, Node, RawNode, RetryPolicy, RetryPolicyDict, ScriptNode, StaticGraphStrategy, StaticGraphStrategyDict, ToolNode

Portable static graph definitions for aiXplain v2 agents.

Copyright 2022 The aiXplain SDK authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

RetryPolicyDict Objects​

class RetryPolicyDict(TypedDict)

[view_source]

The dict form of RetryPolicy.

ConditionDict Objects​

class ConditionDict(TypedDict)

[view_source]

The dict form of Condition.

EdgeDict Objects​

class EdgeDict(_EdgeRequired)

[view_source]

The dict form of Edge.

StaticGraphStrategyDict Objects​

class StaticGraphStrategyDict(TypedDict)

[view_source]

The dict form of StaticGraphStrategy.

GraphDict Objects​

class GraphDict(_GraphRequired)

[view_source]

The dict form of Graph; nodes is a list of nodes or the wire map of id to node dict.

RetryPolicy Objects​

@dataclass
class RetryPolicy()

[view_source]

Retry settings applied by the static graph executor.

validate​

def validate() -> None

[view_source]

Validate retry limits accepted by the backend.

to_dict​

def to_dict(validate: bool = True) -> Dict[str, Any]

[view_source]

Serialize using the engine's canonical snake_case contract.

from_dict​

@classmethod
def from_dict(cls,
value: Union["RetryPolicy", RetryPolicyDict],
strict: bool = True) -> "RetryPolicy"

[view_source]

Deserialize a retry policy; strict=False ignores unknown keys.

Condition Objects​

@dataclass(frozen=True)
class Condition()

[view_source]

A portable edge condition evaluated against graph state.

__post_init__​

def __post_init__() -> None

[view_source]

Validate the backend's structured edge-condition contract.

equals​

@classmethod
def equals(cls, key: str, value: Any) -> "Condition"

[view_source]

Match when a state value equals value.

not_equals​

@classmethod
def not_equals(cls, key: str, value: Any) -> "Condition"

[view_source]

Match when a state value does not equal value.

greater_than​

@classmethod
def greater_than(cls, key: str, value: Any) -> "Condition"

[view_source]

Match when a state value is greater than value.

greater_than_or_equal​

@classmethod
def greater_than_or_equal(cls, key: str, value: Any) -> "Condition"

[view_source]

Match when a state value is greater than or equal to value.

less_than​

@classmethod
def less_than(cls, key: str, value: Any) -> "Condition"

[view_source]

Match when a state value is less than value.

less_than_or_equal​

@classmethod
def less_than_or_equal(cls, key: str, value: Any) -> "Condition"

[view_source]

Match when a state value is less than or equal to value.

is_true​

@classmethod
def is_true(cls, key: str) -> "Condition"

[view_source]

Match a boolean true state value.

is_false​

@classmethod
def is_false(cls, key: str) -> "Condition"

[view_source]

Match a boolean false state value.

to_dict​

def to_dict() -> Dict[str, Any]

[view_source]

Serialize the condition to the backend/engine contract.

from_dict​

@classmethod
def from_dict(cls,
value: Union["Condition", ConditionDict],
strict: bool = True) -> "Condition"

[view_source]

Deserialize a structured edge condition; strict=False keeps one the SDK cannot validate.

Node Objects​

@dataclass
class Node()

[view_source]

Common configuration shared by all portable graph nodes.

__post_init__​

def __post_init__() -> None

[view_source]

Assign and validate the graph-local identifier.

id​

@property
def id() -> str

[view_source]

Return the graph-local node ID.

validate​

def validate() -> None

[view_source]

Validate node-specific configuration.

to_dict​

def to_dict(validate: bool = True) -> Dict[str, Any]

[view_source]

Serialize the node to the engine's canonical contract.

from_dict​

@classmethod
def from_dict(cls,
value: Mapping[str, Any],
node_id: Optional[str] = None,
strict: bool = True) -> "Node"

[view_source]

Build the typed node named by value["type"].

With strict=False a node the SDK cannot model or validate comes back as a RawNode.

LLMNode Objects​

@dataclass
class LLMNode(Node)

[view_source]

A single model call in a static graph.

validate​

def validate() -> None

[view_source]

Validate model generation settings.

ToolNode Objects​

@dataclass
class ToolNode(Node)

[view_source]

A registered tool invocation.

validate​

def validate() -> None

[view_source]

Require the engine registry name for the tool.

AgentNode Objects​

@dataclass
class AgentNode(Node)

[view_source]

A registered sub-agent invocation.

validate​

def validate() -> None

[view_source]

Require the engine registry name for the sub-agent.

ScriptNode Objects​

@dataclass
class ScriptNode(Node)

[view_source]

Sandboxed Python source executed as a graph step.

validate​

def validate() -> None

[view_source]

Require source and sandboxing for backend-authored graphs.

InspectorNode Objects​

@dataclass
class InspectorNode(Node)

[view_source]

A registered inspector check.

validate​

def validate() -> None

[view_source]

Validate inspector configuration.

ConditionalNode Objects​

@dataclass
class ConditionalNode(Node)

[view_source]

A sandboxed expression that writes a boolean routing value.

validate​

def validate() -> None

[view_source]

Require a sandboxed expression.

RawNode Objects​

@dataclass
class RawNode(Node)

[view_source]

A fetched node the SDK does not model, kept verbatim so the graph saves back unchanged.

to_dict​

def to_dict(validate: bool = True) -> Dict[str, Any]

[view_source]

Return the node exactly as the backend sent it.

Edge Objects​

@dataclass
class Edge()

[view_source]

A directed graph edge with an optional portable condition.

__post_init__​

def __post_init__() -> None

[view_source]

Coerce a dict condition and check the endpoints.

source_id​

@property
def source_id() -> str

[view_source]

Return the source node ID.

target_id​

@property
def target_id() -> str

[view_source]

Return the target node ID.

to_dict​

def to_dict() -> Dict[str, Any]

[view_source]

Serialize the edge.

from_dict​

@classmethod
def from_dict(cls,
value: Union["Edge", EdgeDict],
strict: bool = True) -> "Edge"

[view_source]

Deserialize an edge; strict=False ignores unknown keys and keeps unvalidated conditions.

StaticGraphStrategy Objects​

@dataclass
class StaticGraphStrategy()

[view_source]

Execution settings stored alongside an agent graph.

validate​

def validate() -> None

[view_source]

Validate strategy settings accepted by the platform backend.

to_dict​

def to_dict(validate: bool = True) -> Dict[str, Any]

[view_source]

Serialize static graph strategy settings.

from_dict​

@classmethod
def from_dict(cls,
value: Union["StaticGraphStrategy", StaticGraphStrategyDict],
strict: bool = True) -> "StaticGraphStrategy"

[view_source]

Deserialize strategy settings; strict=False ignores unknown keys and skips validation.

Graph Objects​

@dataclass
class Graph()

[view_source]

A validated, portable static execution graph.

__post_init__​

def __post_init__() -> None

[view_source]

Coerce dict nodes and edges into their typed forms.

entry_point_id​

@property
def entry_point_id() -> str

[view_source]

Return the entry-point node ID.

validate​

def validate() -> None

[view_source]

Validate graph structure before it is sent to the platform.

to_dict​

def to_dict(validate: bool = True) -> Dict[str, Any]

[view_source]

Serialize the graph to the backend/engine wire contract.

from_dict​

@classmethod
def from_dict(cls,
value: Union["Graph", GraphDict],
strict: bool = True) -> "Graph"

[view_source]

Build a graph from its dict form.

strict=True (caller input) rejects unknown keys and validates. strict=False (a backend response) ignores unknown keys, keeps unmodeled nodes as RawNode, and skips validation: the backend is authoritative for what it already stored.