abacusai.api_class.ai_agents — AbacusAI documentation

# abacusai.api_class.ai_agents

## Classes

`FieldDescriptor` | Configs for vector store indexing.
`JSONSchema` |
`WorkflowNodeInputMapping` | Represents a mapping of inputs to a workflow node.
`WorkflowNodeInputSchema` | A schema conformant to react-jsonschema-form for workflow node input.
`WorkflowNodeOutputMapping` | Represents a mapping of output from a workflow node.
`WorkflowNodeOutputSchema` | A schema conformant to react-jsonschema-form for a workflow node output.
`TriggerConfig` | Represents the configuration for a trigger workflow node.
`WorkflowGraphNode` | Represents a node in an Agent workflow graph.
`DecisionNode` | Represents a decision node in an Agent workflow graph. It is connected between two workflow nodes and is used to determine if subsequent nodes should be executed.
`WorkflowGraphEdge` | Represents an edge in an Agent workflow graph.
`WorkflowGraph` | Represents an Agent workflow graph.
`AgentConversationMessage` | Message format for agent conversation
`WorkflowNodeTemplateConfig` | Represents a WorkflowNode template config.
`WorkflowNodeTemplateInput` | Represents an input to the workflow node generated using template.
`WorkflowNodeTemplateOutput` | Represents an output returned by the workflow node generated using template.

## Functions

`validate_input_dict_param`(dict_object, friendly_class_name) |

## Module Contents

abacusai.api_class.ai_agents.validate_input_dict_param(dict_object, friendly_class_name, must_contain=[])

class abacusai.api_class.ai_agents.FieldDescriptor

  Bases: `abacusai.api_class.abstract.ApiClass`

  Configs for vector store indexing.

  Parameters:

    - field (str) – The field to be extracted. This will be used as the key in the response.

    - description (str) – The description of this field. If not included, the response_field will be used.

    - example_extraction (Union[str, int, bool, float]) – An example of this extracted field.

    - type (FieldDescriptorType) – The type of this field. If not provided, the default type is STRING.

  field: str
  description: str = None
  example_extraction: str | int | bool | float | list | dict = None
  type: abacusai.api_class.enums.FieldDescriptorType

class abacusai.api_class.ai_agents.JSONSchema
  classmethod from_fields_list(fields_list)
    Parameters:

      fields_list (List[str])

  classmethod to_fields_list(json_schema)
    Return type:

      List[str]

class abacusai.api_class.ai_agents.WorkflowNodeInputMapping

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents a mapping of inputs to a workflow node.

  Parameters:

    - name (str) – The name of the input variable of the node function.

    - variable_type (Union[WorkflowNodeInputType, str]) – The type of the input. If the type is IGNORE, the input will be ignored.

    - variable_source (str) – The name of the node this variable is sourced from. If the type is WORKFLOW_VARIABLE, the value given by the source node will be directly used. If the type is USER_INPUT, the value given by the source node will be used as the default initial value before the user edits it. Set to None if the type is USER_INPUT and the variable doesn’t need a pre-filled initial value.

    - is_required (bool) – Indicates whether the input is required. Defaults to True.

    - description (str) – The description of this input.

    - constant_value (str) – The constant value of this input if variable type is CONSTANT. Only applicable for template nodes.

  name: str
  variable_type: abacusai.api_class.enums.WorkflowNodeInputType
  variable_source: str = None
  source_prop: str = None
  is_required: bool = True
  description: str = None
  constant_value: str = None
  __post_init__()
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(mapping)
    Parameters:

      mapping (dict)

class abacusai.api_class.ai_agents.WorkflowNodeInputSchema

  Bases: `abacusai.api_class.abstract.ApiClass`, `JSONSchema`

  A schema conformant to react-jsonschema-form for workflow node input.

  To initialize a WorkflowNodeInputSchema dependent on another node’s output, use the from_workflow_node method.

  Parameters:

    - json_schema (dict) – The JSON schema for the input, conformant to react-jsonschema-form specification. Must define keys like “title”, “type”, and “properties”. Supported elements include Checkbox, Radio Button, Dropdown, Textarea, Number, Date, and file upload. Nested elements, arrays, and other complex types are not supported.

    - ui_schema (dict) – The UI schema for the input, conformant to react-jsonschema-form specification.

  json_schema: dict
  ui_schema: dict
  schema_source: str = None
  schema_prop: str = None
  runtime_schema: bool = False
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(schema)
    Parameters:

      schema (dict)

  classmethod from_workflow_node(schema_source, schema_prop)

    Creates a WorkflowNodeInputSchema instance which references the schema generated by a WorkflowGraphNode.

    Parameters:

      - schema_source (str) – The name of the source WorkflowGraphNode.

      - schema_prop (str) – The name of the input schema parameter which source node outputs.

  classmethod from_input_mappings(input_mappings)

    Creates a json_schema for the input schema of the node from it’s input mappings.

    Parameters:

      input_mappings (List[WorkflowNodeInputMapping]) – The input mappings for the node.

  classmethod from_tool_variable_mappings(tool_variable_mappings)

    Creates a WorkflowNodeInputSchema for the given tool variable mappings.

    Parameters:

      tool_variable_mappings (List[dict]) – The tool variable mappings for the node.

class abacusai.api_class.ai_agents.WorkflowNodeOutputMapping

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents a mapping of output from a workflow node.

  Parameters:

    - name (str) – The name of the output.

    - variable_type (Union[WorkflowNodeOutputType, str]) – The type of the output in the form of an enum or a string.

    - description (str) – The description of this output.

  name: str
  variable_type: abacusai.api_class.enums.WorkflowNodeOutputType | str
  description: str = None
  __post_init__()
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(mapping)
    Parameters:

      mapping (dict)

class abacusai.api_class.ai_agents.WorkflowNodeOutputSchema

  Bases: `abacusai.api_class.abstract.ApiClass`, `JSONSchema`

  A schema conformant to react-jsonschema-form for a workflow node output.

  Parameters:

    json_schema (dict) – The JSON schema for the output, conformant to react-jsonschema-form specification.

  json_schema: dict
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(schema)
    Parameters:

      schema (dict)

class abacusai.api_class.ai_agents.TriggerConfig

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents the configuration for a trigger workflow node.

  Parameters:

    sleep_time (int) – The time in seconds to wait before the node gets executed again.

  sleep_time: int = None
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(configs)
    Parameters:

      configs (dict)

class abacusai.api_class.ai_agents.WorkflowGraphNode(name, function=None, input_mappings=None, output_mappings=None, function_name=None, source_code=None, input_schema=None, output_schema=None, template_metadata=None, trigger_config=None)

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents a node in an Agent workflow graph.

  Parameters:

    - name (str) – A unique name for the workflow node.

    - input_mappings (List[WorkflowNodeInputMapping]) – List of input mappings for the node. Each arg/kwarg of the node function should have a corresponding input mapping.

    - output_mappings (List[str]) – List of outputs for the node. Each field in the returned dict/AgentResponse must have a corresponding output in the list.

    - function (callable) – The callable node function reference.

    - input_schema (WorkflowNodeInputSchema) – The react json schema for the user input variables. This should be empty for CHAT interface.

    - output_schema (List[str]) – The list of outputs to be shown on UI. Each output corresponds to a field in the output mappings of the node.

    - function_name (str)

    - source_code (str)

    - template_metadata (dict)

    - trigger_config (TriggerConfig)

  Additional Attributes:

    function_name (str): The name of the function. source_code (str): The source code of the function. trigger_config (TriggerConfig): The configuration for a trigger workflow node.

  template_metadata = None
  trigger_config = None
  node_type = 'workflow_node'
  classmethod _raw_init(name, input_mappings=None, output_mappings=None, function=None, function_name=None, source_code=None, input_schema=None, output_schema=None, template_metadata=None, trigger_config=None)
    Parameters:

      - name (str)

      - input_mappings (List[WorkflowNodeInputMapping])

      - output_mappings (List[WorkflowNodeOutputMapping])

      - function (callable)

      - function_name (str)

      - source_code (str)

      - input_schema (WorkflowNodeInputSchema)

      - output_schema (WorkflowNodeOutputSchema)

      - template_metadata (dict)

      - trigger_config (TriggerConfig)

  classmethod from_template(template_name, name, configs=None, input_mappings=None, input_schema=None, output_schema=None, sleep_time=None)
    Parameters:

      - template_name (str)

      - name (str)

      - configs (dict)

      - input_mappings (Union[Dict[str, WorkflowNodeInputMapping], List[WorkflowNodeInputMapping]])

      - input_schema (Union[List[str], WorkflowNodeInputSchema])

      - output_schema (Union[List[str], WorkflowNodeOutputSchema])

      - sleep_time (int)

  classmethod from_tool(tool_name, name, configs=None, input_mappings=None, input_schema=None, output_schema=None)

    Creates and returns a WorkflowGraphNode based on an available user created tool. Note: DO NOT specify the output mapping for the tool; it will be inferred automatically. Doing so will raise an error.

    Parameters:

      - tool_name (str) – The name of the tool. There should already be a tool created in the platform with tool_name.

      - name (str) – The name to assign to the WorkflowGraphNode instance.

      - configs (optional) – The configuration state of the tool to use (if necessary). If not specified, will use the tool’s default configuration.

      - input_mappings (optional) – The WorkflowNodeInputMappings for this node.

      - input_schema (optional) – The WorkflowNodeInputSchema for this node.

      - output_schema (optional) – The WorkflowNodeOutputSchema for this node.

  classmethod from_system_tool(tool_name, name, configs=None, input_mappings=None, input_schema=None, output_schema=None)

    Creates and returns a WorkflowGraphNode based on the name of an available system tool. Note: DO NOT specify the output mapping for the tool; it will be inferred automatically. Doing so will raise an error.

    Parameters:

      - tool_name (str) – The name of the tool. There should already be a tool created in the platform with tool_name.

      - name (str) – The name to assign to the WorkflowGraphNode instance.

      - configs (optional) – The configuration state of the tool to use (if necessary). If not specified, will use the tool’s default configuration.

      - input_mappings (optional) – The WorkflowNodeInputMappings for this node.

      - input_schema (optional) – The WorkflowNodeInputSchema for this node.

      - output_schema (optional) – The WorkflowNodeOutputSchema for this node.

  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  is_template_node()
  is_trigger_node()
  classmethod from_dict(node)
    Parameters:

      node (dict)

  __setattr__(name, value)
  __getattribute__(name)
  class Outputs(node)
    Parameters:

      node (WorkflowGraphNode)

    node
    __getattr__(name)
  property outputs

class abacusai.api_class.ai_agents.DecisionNode(name, condition, input_mappings)

  Bases: `WorkflowGraphNode`

  Represents a decision node in an Agent workflow graph. It is connected between two workflow nodes and is used to determine if subsequent nodes should be executed.

  Parameters:

    - name (str)

    - condition (str)

    - input_mappings (Union[Dict[str, WorkflowNodeInputMapping], List[WorkflowNodeInputMapping]])

  node_type = 'decision_node'
  name
  source_code
  output_mappings
  template_metadata = None
  trigger_config = None
  input_schema = None
  output_schema = None
  function_name = None
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(node)
    Parameters:

      node (dict)

class abacusai.api_class.ai_agents.WorkflowGraphEdge(source, target, details=None)

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents an edge in an Agent workflow graph.

  To make an edge conditional, provide {‘EXECUTION_CONDITION’: ‘<condition>’} key-value in the details dictionary. The condition should be a Pythonic expression string that evaluates to a boolean value and only depends on the outputs of the source node of the edge.

  Parameters:

    - source (str) – The name of the source node of the edge.

    - target (str) – The name of the target node of the edge.

    - details (dict) – Additional details about the edge. Like the condition for edge execution.

  source: str | WorkflowGraphNode
  target: str | WorkflowGraphNode
  details: dict
  to_nx_edge()
  classmethod from_dict(input_dict)
    Parameters:

      input_dict (dict)

class abacusai.api_class.ai_agents.WorkflowGraph

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents an Agent workflow graph.

  Parameters:

    - nodes (List[Union[WorkflowGraphNode, DecisionNode]]) – A list of nodes in the workflow graph.

    - primary_start_node (Union[str, WorkflowGraphNode]) – The primary node to start the workflow from.

    - common_source_code (str) – Common source code that can be used across all nodes.

  nodes: List[WorkflowGraphNode | DecisionNode] = []
  edges: List[WorkflowGraphEdge | Tuple[WorkflowGraphNode, WorkflowGraphNode, dict] | Tuple[str, str, dict]] = []
  primary_start_node: str | WorkflowGraphNode = None
  common_source_code: str = None
  specification_type: str = 'data_flow'
  __post_init__()
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(graph)
    Parameters:

      graph (dict)

class abacusai.api_class.ai_agents.AgentConversationMessage

  Bases: `abacusai.api_class.abstract.ApiClass`

  Message format for agent conversation

  Parameters:

    - is_user (bool) – Whether the message is from the user.

    - text (str) – The message’s text.

    - document_contents (dict) – Dict of document name to document text in case of any document present.

  is_user: bool = None
  text: str = None
  document_contents: dict = None
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

class abacusai.api_class.ai_agents.WorkflowNodeTemplateConfig

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents a WorkflowNode template config.

  Parameters:

    - name (str) – A unique name of the config.

    - description (str) – The description of this config.

    - default_value (str) – Default value of the config to be used if value is not provided during node initialization.

    - is_required (bool) – Indicates whether the config is required. Defaults to False.

  name: str
  description: str = None
  default_value: str = None
  is_required: bool = False
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(mapping)
    Parameters:

      mapping (dict)

class abacusai.api_class.ai_agents.WorkflowNodeTemplateInput

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents an input to the workflow node generated using template.

  Parameters:

    - name (str) – A unique name of the input.

    - is_required (bool) – Indicates whether the input is required. Defaults to False.

    - description (str) – The description of this input.

  name: str
  is_required: bool = False
  description: str = ''
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(mapping)
    Parameters:

      mapping (dict)

class abacusai.api_class.ai_agents.WorkflowNodeTemplateOutput

  Bases: `abacusai.api_class.abstract.ApiClass`

  Represents an output returned by the workflow node generated using template.

  Parameters:

    - name (str) – The name of the output.

    - variable_type (WorkflowNodeOutputType) – The type of the output.

    - description (str) – The description of this output.

  name: str
  variable_type: abacusai.api_class.enums.WorkflowNodeOutputType
  description: str = ''
  to_dict()

    Standardizes converting an ApiClass to dictionary. Keys of response dictionary are converted to camel case. This also validates the fields ( type, value, etc ) received in the dictionary.

  classmethod from_dict(mapping)
    Parameters:

      mapping (dict)