Skip to content

Commit

Permalink
Version 1.4.18
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumfusion committed Nov 7, 2024
1 parent 7330a71 commit 725d199
Show file tree
Hide file tree
Showing 276 changed files with 5,479 additions and 7,379 deletions.
4 changes: 3 additions & 1 deletion abacusai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
from .nested_feature import NestedFeature
from .nested_feature_schema import NestedFeatureSchema
from .news_search_result import NewsSearchResult
from .nlp_chat_response import NlpChatResponse
from .notebook_completion import NotebookCompletion
from .notebook_template import NotebookTemplate
from .null_violation import NullViolation
Expand All @@ -166,6 +167,7 @@
from .pipeline_step_version_reference import PipelineStepVersionReference
from .pipeline_version import PipelineVersion
from .pipeline_version_logs import PipelineVersionLogs
from .playground_text import PlaygroundText
from .point_in_time_feature import PointInTimeFeature
from .point_in_time_feature_info import PointInTimeFeatureInfo
from .point_in_time_group import PointInTimeGroup
Expand Down Expand Up @@ -219,4 +221,4 @@
from .workflow_node_template import WorkflowNodeTemplate


__version__ = "1.4.17"
__version__ = "1.4.18"
13 changes: 8 additions & 5 deletions abacusai/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class Agent(AbstractApiClass):
agentExecutionConfig (dict): The config for arguments used to execute the agent.
latestAgentVersion (AgentVersion): The latest agent version.
codeSource (CodeSource): If a python model, information on the source code
draftWorkflowGraph (WorkflowGraph): The last saved draft of workflow graph for the agent.
workflowGraph (WorkflowGraph): The workflow graph for the agent.
"""

def __init__(self, client, name=None, agentId=None, createdAt=None, projectId=None, notebookId=None, predictFunctionName=None, sourceCode=None, agentConfig=None, memory=None, trainingRequired=None, agentExecutionConfig=None, codeSource={}, latestAgentVersion={}, workflowGraph={}):
def __init__(self, client, name=None, agentId=None, createdAt=None, projectId=None, notebookId=None, predictFunctionName=None, sourceCode=None, agentConfig=None, memory=None, trainingRequired=None, agentExecutionConfig=None, codeSource={}, latestAgentVersion={}, draftWorkflowGraph={}, workflowGraph={}):
super().__init__(client, agentId)
self.name = name
self.agent_id = agentId
Expand All @@ -42,12 +43,14 @@ def __init__(self, client, name=None, agentId=None, createdAt=None, projectId=No
self.code_source = client._build_class(CodeSource, codeSource)
self.latest_agent_version = client._build_class(
AgentVersion, latestAgentVersion)
self.draft_workflow_graph = client._build_class(
WorkflowGraph, draftWorkflowGraph)
self.workflow_graph = client._build_class(WorkflowGraph, workflowGraph)
self.deprecated_keys = {}

def __repr__(self):
repr_dict = {f'name': repr(self.name), f'agent_id': repr(self.agent_id), f'created_at': repr(self.created_at), f'project_id': repr(self.project_id), f'notebook_id': repr(self.notebook_id), f'predict_function_name': repr(self.predict_function_name), f'source_code': repr(self.source_code), f'agent_config': repr(
self.agent_config), f'memory': repr(self.memory), f'training_required': repr(self.training_required), f'agent_execution_config': repr(self.agent_execution_config), f'code_source': repr(self.code_source), f'latest_agent_version': repr(self.latest_agent_version), f'workflow_graph': repr(self.workflow_graph)}
repr_dict = {f'name': repr(self.name), f'agent_id': repr(self.agent_id), f'created_at': repr(self.created_at), f'project_id': repr(self.project_id), f'notebook_id': repr(self.notebook_id), f'predict_function_name': repr(self.predict_function_name), f'source_code': repr(self.source_code), f'agent_config': repr(self.agent_config), f'memory': repr(
self.memory), f'training_required': repr(self.training_required), f'agent_execution_config': repr(self.agent_execution_config), f'code_source': repr(self.code_source), f'latest_agent_version': repr(self.latest_agent_version), f'draft_workflow_graph': repr(self.draft_workflow_graph), f'workflow_graph': repr(self.workflow_graph)}
class_name = "Agent"
repr_str = ',\n '.join([f'{key}={value}' for key, value in repr_dict.items(
) if getattr(self, key, None) is not None and key not in self.deprecated_keys])
Expand All @@ -60,8 +63,8 @@ def to_dict(self):
Returns:
dict: The dict value representation of the class parameters
"""
resp = {'name': self.name, 'agent_id': self.agent_id, 'created_at': self.created_at, 'project_id': self.project_id, 'notebook_id': self.notebook_id, 'predict_function_name': self.predict_function_name, 'source_code': self.source_code, 'agent_config': self.agent_config, 'memory': self.memory,
'training_required': self.training_required, 'agent_execution_config': self.agent_execution_config, 'code_source': self._get_attribute_as_dict(self.code_source), 'latest_agent_version': self._get_attribute_as_dict(self.latest_agent_version), 'workflow_graph': self._get_attribute_as_dict(self.workflow_graph)}
resp = {'name': self.name, 'agent_id': self.agent_id, 'created_at': self.created_at, 'project_id': self.project_id, 'notebook_id': self.notebook_id, 'predict_function_name': self.predict_function_name, 'source_code': self.source_code, 'agent_config': self.agent_config, 'memory': self.memory, 'training_required': self.training_required,
'agent_execution_config': self.agent_execution_config, 'code_source': self._get_attribute_as_dict(self.code_source), 'latest_agent_version': self._get_attribute_as_dict(self.latest_agent_version), 'draft_workflow_graph': self._get_attribute_as_dict(self.draft_workflow_graph), 'workflow_graph': self._get_attribute_as_dict(self.workflow_graph)}
return {key: value for key, value in resp.items() if value is not None and key not in self.deprecated_keys}

def refresh(self):
Expand Down
2 changes: 2 additions & 0 deletions abacusai/api_class/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
def _validate_instance(value, expected_type):
if expected_type == callable:
return callable(value)
if expected_type is Any:
return True
elif isinstance(expected_type, _GenericAlias):
if expected_type.__origin__ == list:
if not isinstance(value, list):
Expand Down
17 changes: 10 additions & 7 deletions abacusai/api_class/ai_agents.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ast
import dataclasses
from typing import Dict, List, Union
from typing import Any, Dict, List, Union

from . import enums
from .abstract import ApiClass, get_clean_function_source_code_for_agent, validate_constructor_arg_types
Expand Down Expand Up @@ -67,14 +67,16 @@ class WorkflowNodeInputMapping(ApiClass):
variable_source: str = dataclasses.field(default=None)
source_prop: str = dataclasses.field(default=None)
is_required: bool = dataclasses.field(default=True)
default_value: Any = dataclasses.field(default=None)

def to_dict(self):
return {
'name': self.name,
'variable_type': self.variable_type.value,
'variable_source': self.variable_source,
'source_prop': self.source_prop or self.name,
'is_required': self.is_required
'is_required': self.is_required,
'default_value': self.default_value
}

@classmethod
Expand All @@ -87,7 +89,8 @@ def from_dict(cls, mapping: dict):
variable_type=enums.WorkflowNodeInputType(mapping['variable_type']),
variable_source=mapping.get('variable_source'),
source_prop=mapping.get('source_prop') or mapping['name'] if mapping.get('variable_source') else None,
is_required=mapping.get('is_required', True)
is_required=mapping.get('is_required', True),
default_value=mapping.get('default_value')
)


Expand Down Expand Up @@ -283,14 +286,14 @@ def __init__(self, name: str, input_mappings: Union[Dict[str, WorkflowNodeInputM
raise ValueError('workflow_graph_node', f'Invalid input mapping. Argument "{input_name}" not found in function "{self.function_name}".')
for arg, default in arg_defaults.items():
if arg not in input_mapping_args:
self.input_mappings.append(WorkflowNodeInputMapping(name=arg, variable_type=enums.WorkflowNodeInputType.USER_INPUT, is_required=default is None))
self.input_mappings.append(WorkflowNodeInputMapping(name=arg, variable_type=enums.WorkflowNodeInputType.USER_INPUT, is_required=default is None, default_value=default.value if default else None))
elif isinstance(input_mappings, Dict) and all(isinstance(key, str) and isinstance(value, WorkflowNodeInputMapping) for key, value in input_mappings.items()):
is_shortform_input_mappings = True
self.input_mappings = [WorkflowNodeInputMapping(name=arg, variable_type=enums.WorkflowNodeInputType.USER_INPUT, is_required=default is None) for arg, default in arg_defaults.items() if arg not in input_mappings]
self.input_mappings = [WorkflowNodeInputMapping(name=arg, variable_type=enums.WorkflowNodeInputType.USER_INPUT, is_required=default is None, default_value=default.value if default else None) for arg, default in arg_defaults.items() if arg not in input_mappings]
for key, value in input_mappings.items():
if key not in arg_defaults:
raise ValueError('workflow_graph_node', f'Invalid input mapping. Argument "{key}" not found in function "{self.function_name}".')
self.input_mappings.append(WorkflowNodeInputMapping(name=key, variable_type=value.variable_type, variable_source=value.variable_source, source_prop=value.source_prop, is_required=arg_defaults.get(key) is None))
self.input_mappings.append(WorkflowNodeInputMapping(name=key, variable_type=value.variable_type, variable_source=value.variable_source, source_prop=value.source_prop, is_required=arg_defaults.get(key) is None, default_value=value.default_value))
else:
raise ValueError('workflow_graph_node', 'Invalid input mappings. Must be a list of WorkflowNodeInputMapping or a dictionary of input mappings in the form {arg_name: node_name.outputs.prop_name}.')

Expand Down Expand Up @@ -359,7 +362,7 @@ def from_template(cls, template_name: str, name: str, configs: dict = None, inpu
if isinstance(input_mappings, List) and all(isinstance(input, WorkflowNodeInputMapping) for input in input_mappings):
instance_input_mappings = input_mappings
elif isinstance(input_mappings, Dict) and all(isinstance(key, str) and isinstance(value, WorkflowNodeInputMapping) for key, value in input_mappings.items()):
instance_input_mappings = [WorkflowNodeInputMapping(name=arg, variable_type=mapping.variable_type, variable_source=mapping.variable_source, source_prop=mapping.source_prop) for arg, mapping in input_mappings]
instance_input_mappings = [WorkflowNodeInputMapping(name=arg, variable_type=mapping.variable_type, variable_source=mapping.variable_source, source_prop=mapping.source_prop, is_required=mapping.is_required, default_value=mapping.default_value) for arg, mapping in input_mappings]
elif input_mappings is None:
instance_input_mappings = []
else:
Expand Down
2 changes: 1 addition & 1 deletion abacusai/api_class/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _detect_ocr_mode(self):
elif self.document_type == DocumentType.EMBEDDED_IMAGES:
return OcrMode.SCANNED
elif self.document_type == DocumentType.SCANNED_TEXT:
return OcrMode.DEFAULT
return OcrMode.SCANNED
if self.ocr_mode is not None:
return self.ocr_mode
return OcrMode.AUTO
Expand Down
5 changes: 4 additions & 1 deletion abacusai/api_class/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,10 @@ class LLMName(ApiEnum):
CLAUDE_V3_SONNET = 'CLAUDE_V3_SONNET'
CLAUDE_V3_HAIKU = 'CLAUDE_V3_HAIKU'
CLAUDE_V3_5_SONNET = 'CLAUDE_V3_5_SONNET'
CLAUDE_V3_5_HAIKU = 'CLAUDE_V3_5_HAIKU'
GEMINI_1_5_PRO = 'GEMINI_1_5_PRO'
ABACUS_SMAUG3 = 'ABACUS_SMAUG3'
ABACUS_DRACARYS = 'ABACUS_DRACARYS'
GEMINI_1_5_FLASH = 'GEMINI_1_5_FLASH'


Expand Down Expand Up @@ -594,14 +596,15 @@ class OcrMode(ApiEnum):
COMPREHENSIVE = 'COMPREHENSIVE'
COMPREHENSIVE_V2 = 'COMPREHENSIVE_V2'
COMPREHENSIVE_TABLE_MD = 'COMPREHENSIVE_TABLE_MD'
COMPREHENSIVE_FORM_MD = 'COMPREHENSIVE_FORM_MD'
COMPREHENSIVE_FORM_AND_TABLE_MD = 'COMPREHENSIVE_FORM_AND_TABLE_MD'
TESSERACT_FAST = 'TESSERACT_FAST'
LLM = 'LLM'
AUGMENTED_LLM = 'AUGMENTED_LLM'

@classmethod
def aws_ocr_modes(cls):
return [cls.COMPREHENSIVE_V2, cls.COMPREHENSIVE_TABLE_MD, cls.COMPREHENSIVE_FORM_AND_TABLE_MD]
return [cls.COMPREHENSIVE_V2, cls.COMPREHENSIVE_TABLE_MD, cls.COMPREHENSIVE_FORM_MD, cls.COMPREHENSIVE_FORM_AND_TABLE_MD]


class DocumentType(ApiEnum):
Expand Down
11 changes: 10 additions & 1 deletion abacusai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ def __init__(self, *args, **kwargs):
self.section_data_list.append({key: value})

def to_dict(self):
"""
Get a dict representation of the response object
"""
result = {}
if self.data_list:
result['data_list'] = self.data_list
Expand Down Expand Up @@ -589,6 +592,9 @@ class _ApiExceptionFactory:
"""
@classmethod
def from_response(cls, message: str, http_status: int, exception: str = None, request_id: str = None):
"""
Creates an appropriate exception instance based on HTTP response data.
"""
if http_status == 504:
message = 'Gateway timeout, please try again later'
return GatewayTimeoutError(message, http_status, exception, request_id)
Expand Down Expand Up @@ -618,7 +624,7 @@ class BaseApiClient:
client_options (ClientOptions): Optional API client configurations
skip_version_check (bool): If true, will skip checking the server's current API version on initializing the client
"""
client_version = '1.4.17'
client_version = '1.4.18'

def __init__(self, api_key: str = None, server: str = None, client_options: ClientOptions = None, skip_version_check: bool = False, include_tb: bool = False):
self.api_key = api_key
Expand Down Expand Up @@ -3612,6 +3618,9 @@ def run_workflow_graph(self, workflow_graph: WorkflowGraph, sample_user_inputs:
return workflow_info['run_info']

def execute_workflow_node(self, node: WorkflowGraphNode, inputs: dict):
"""
Executes a workflow node.
"""
source_code = None
function_name = None
if node.template_metadata:
Expand Down
37 changes: 37 additions & 0 deletions abacusai/nlp_chat_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from .return_class import AbstractApiClass


class NlpChatResponse(AbstractApiClass):
"""
A chat response from an LLM
Args:
client (ApiClient): An authenticated API Client instance
deploymentConversationId (str): The unique identifier of the deployment conversation.
messages (list): The conversation messages in the chat.
"""

def __init__(self, client, deploymentConversationId=None, messages=None):
super().__init__(client, None)
self.deployment_conversation_id = deploymentConversationId
self.messages = messages
self.deprecated_keys = {}

def __repr__(self):
repr_dict = {f'deployment_conversation_id': repr(
self.deployment_conversation_id), f'messages': repr(self.messages)}
class_name = "NlpChatResponse"
repr_str = ',\n '.join([f'{key}={value}' for key, value in repr_dict.items(
) if getattr(self, key, None) is not None and key not in self.deprecated_keys])
return f"{class_name}({repr_str})"

def to_dict(self):
"""
Get a dict representation of the parameters in this class
Returns:
dict: The dict value representation of the class parameters
"""
resp = {'deployment_conversation_id': self.deployment_conversation_id,
'messages': self.messages}
return {key: value for key, value in resp.items() if value is not None and key not in self.deprecated_keys}
37 changes: 37 additions & 0 deletions abacusai/playground_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from .return_class import AbstractApiClass


class PlaygroundText(AbstractApiClass):
"""
The text content inside of a playground segment.
Args:
client (ApiClient): An authenticated API Client instance
playgroundText (str): The text of the playground segment.
renderingCode (str): The rendering code of the playground segment.
"""

def __init__(self, client, playgroundText=None, renderingCode=None):
super().__init__(client, None)
self.playground_text = playgroundText
self.rendering_code = renderingCode
self.deprecated_keys = {}

def __repr__(self):
repr_dict = {f'playground_text': repr(
self.playground_text), f'rendering_code': repr(self.rendering_code)}
class_name = "PlaygroundText"
repr_str = ',\n '.join([f'{key}={value}' for key, value in repr_dict.items(
) if getattr(self, key, None) is not None and key not in self.deprecated_keys])
return f"{class_name}({repr_str})"

def to_dict(self):
"""
Get a dict representation of the parameters in this class
Returns:
dict: The dict value representation of the class parameters
"""
resp = {'playground_text': self.playground_text,
'rendering_code': self.rendering_code}
return {key: value for key, value in resp.items() if value is not None and key not in self.deprecated_keys}
4 changes: 2 additions & 2 deletions docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 787e52a6c82af449544cb6a1253baab3
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 12535596649b36dd1c7e0cddf2d1e3b2
tags: 645f666f9bcd5a90fca523b33c5a78b7
10 changes: 6 additions & 4 deletions docs/_sources/autoapi/abacusai/agent/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Classes
Module Contents
---------------

.. py:class:: Agent(client, name=None, agentId=None, createdAt=None, projectId=None, notebookId=None, predictFunctionName=None, sourceCode=None, agentConfig=None, memory=None, trainingRequired=None, agentExecutionConfig=None, codeSource={}, latestAgentVersion={}, workflowGraph={})
.. py:class:: Agent(client, name=None, agentId=None, createdAt=None, projectId=None, notebookId=None, predictFunctionName=None, sourceCode=None, agentConfig=None, memory=None, trainingRequired=None, agentExecutionConfig=None, codeSource={}, latestAgentVersion={}, draftWorkflowGraph={}, workflowGraph={})
Bases: :py:obj:`abacusai.return_class.AbstractApiClass`

Expand Down Expand Up @@ -50,6 +50,8 @@ Module Contents
:type latestAgentVersion: AgentVersion
:param codeSource: If a python model, information on the source code
:type codeSource: CodeSource
:param draftWorkflowGraph: The last saved draft of workflow graph for the agent.
:type draftWorkflowGraph: WorkflowGraph
:param workflowGraph: The workflow graph for the agent.
:type workflowGraph: WorkflowGraph

Expand Down Expand Up @@ -93,6 +95,9 @@ Module Contents
.. py:attribute:: latest_agent_version
.. py:attribute:: draft_workflow_graph
.. py:attribute:: workflow_graph
Expand Down Expand Up @@ -149,21 +154,18 @@ Module Contents
.. py:property:: description
:type: str


The description of the agent.


.. py:property:: agent_interface
:type: str


The interface that the agent will be deployed with.


.. py:property:: agent_connectors
:type: dict


A dictionary mapping ApplicationConnectorType keys to lists of OAuth scopes. Each key represents a specific application connector, while the value is a list of scopes that define the permissions granted to the application.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Module Contents
:type: bool


.. py:attribute:: default_value
:type: Any


.. py:method:: to_dict()
Standardizes converting an ApiClass to dictionary.
Expand Down
Loading

0 comments on commit 725d199

Please sign in to comment.