Skip to content

Commit

Permalink
Version 1.4.15
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumfusion committed Oct 17, 2024
1 parent cfde11e commit e6de9b7
Show file tree
Hide file tree
Showing 271 changed files with 3,338 additions and 2,288 deletions.
2 changes: 1 addition & 1 deletion abacusai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@
from .workflow_node_template import WorkflowNodeTemplate


__version__ = "1.4.14"
__version__ = "1.4.15"
21 changes: 21 additions & 0 deletions abacusai/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@ def list_versions(self, limit: int = 100, start_after_version: str = None):
"""
return self.client.list_agent_versions(self.agent_id, limit, start_after_version)

@property
def description(self) -> str:
"""
The description of the agent.
"""
return (self.agent_config or {}).get('DESCRIPTION')

@property
def agent_interface(self) -> str:
"""
The interface that the agent will be deployed with.
"""
return (self.agent_config or {}).get('AGENT_INTERFACE')

@property
def agent_connectors(self) -> 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.
"""
return (self.agent_config or {}).get('AGENT_CONNECTORS')

def wait_for_publish(self, timeout=None):
"""
A waiting call until agent is published.
Expand Down
58 changes: 52 additions & 6 deletions abacusai/api_class/ai_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ class WorkflowNodeOutputMapping(ApiClass):
Args:
name (str): The name of the output.
variable_type (WorkflowNodeOutputType): The type of the output.
variable_type (Union[WorkflowNodeOutputType, str]): The type of the output in the form of an enum or a string.
"""
name: str
variable_type: enums.WorkflowNodeOutputType = dataclasses.field(default=enums.WorkflowNodeOutputType.ANY)
variable_type: Union[enums.WorkflowNodeOutputType, str] = dataclasses.field(default=enums.WorkflowNodeOutputType.ANY)

def __post_init__(self):
if isinstance(self.variable_type, str):
self.variable_type = enums.WorkflowNodeOutputType(self.variable_type)

def to_dict(self):
return {
Expand Down Expand Up @@ -226,8 +230,9 @@ class WorkflowGraphNode(ApiClass):
input_schema (WorkflowNodeInputSchema): The react json schema for the user input variables.
output_schema (WorkflowNodeOutputSchema): The react json schema for the output to be shown on UI.
Raises:
ValueError: If neither `function` nor `function_name` and `source_code` are provided or the inputs are invalid.
Additional Attributes:
function_name (str): The name of the function.
source_code (str): The source code of the function.
"""

def __init__(self, name: str, input_mappings: Union[Dict[str, WorkflowNodeInputMapping], List[WorkflowNodeInputMapping]] = None, output_mappings: Union[List[str], Dict[str, str], List[WorkflowNodeOutputMapping]] = None, function: callable = None, function_name: str = None, source_code: str = None, input_schema: Union[List[str], WorkflowNodeInputSchema] = None, output_schema: Union[List[str], WorkflowNodeOutputSchema] = None, template_metadata: dict = None):
Expand All @@ -241,7 +246,6 @@ def __init__(self, name: str, input_mappings: Union[Dict[str, WorkflowNodeInputM
self.input_schema = input_schema
self.output_schema = output_schema
else:
self._user_args = locals()
if function:
self.function = function
self.function_name = function.__name__
Expand Down Expand Up @@ -328,6 +332,26 @@ def __init__(self, name: str, input_mappings: Union[Dict[str, WorkflowNodeInputM
else:
raise ValueError('workflow_graph_node', 'Invalid output schema. Must be a WorkflowNodeOutputSchema or a list of output section names.')

@classmethod
def _raw_init(cls, name: str, input_mappings: List[WorkflowNodeInputMapping] = None, output_mappings: List[WorkflowNodeOutputMapping] = None, function: callable = None, function_name: str = None, source_code: str = None, input_schema: WorkflowNodeInputSchema = None, output_schema: WorkflowNodeOutputSchema = None, template_metadata: dict = None):
workflow_node = cls.__new__(cls, name, input_mappings, output_mappings, input_schema, output_schema, template_metadata)
workflow_node.name = name
if function:
workflow_node.function = function
workflow_node.function_name = function.__name__
workflow_node.source_code = get_clean_function_source_code_for_agent(function)
elif function_name and source_code:
workflow_node.function_name = function_name
workflow_node.source_code = source_code
else:
raise ValueError('workflow_graph_node', 'Either function or function_name and source_code must be provided.')
workflow_node.input_mappings = input_mappings
workflow_node.output_mappings = output_mappings
workflow_node.input_schema = input_schema
workflow_node.output_schema = output_schema
workflow_node.template_metadata = template_metadata
return workflow_node

@classmethod
def from_template(cls, template_name: str, name: str, configs: dict = None, input_mappings: Union[Dict[str, WorkflowNodeInputMapping], List[WorkflowNodeInputMapping]] = None, input_schema: Union[List[str], WorkflowNodeInputSchema] = None, output_schema: Union[List[str], WorkflowNodeOutputSchema] = None):

Expand Down Expand Up @@ -388,7 +412,8 @@ def to_dict(self):
@classmethod
def from_dict(cls, node: dict):
validate_input_dict_param(node, friendly_class_name='workflow_graph_node', must_contain=['name', 'function_name', 'source_code'])
instance = cls(
_cls = cls._raw_init if node.get('__return_filter') else cls
instance = _cls(
name=node['name'],
function_name=node['function_name'],
source_code=node['source_code'],
Expand All @@ -400,6 +425,24 @@ def from_dict(cls, node: dict):
)
return instance

def __setattr__(self, name, value):
super().__setattr__(name, value)
if name == 'function':
if value:
self.function_name = value.__name__
self.source_code = get_clean_function_source_code_for_agent(value)

def __getattribute__(self, name):
if name == 'function':
try:
val = super().__getattribute__(name)
except AttributeError:
val = None
if val is None and self.function_name and self.source_code:
raise AttributeError("This WorkflowGraphNode object was not created using a callable `function`. Please refer to `function_name` and `source_code` attributes to get it's function's details.")
return val
return super().__getattribute__(name)

class Outputs:
def __init__(self, node: 'WorkflowGraphNode'):
self.node = node
Expand Down Expand Up @@ -471,6 +514,9 @@ def to_dict(self):
@classmethod
def from_dict(cls, graph: dict):
validate_input_dict_param(graph, friendly_class_name='workflow_graph')
if graph.get('__return_filter'):
for node in graph.get('nodes', []):
node['__return_filter'] = True
nodes = [WorkflowGraphNode.from_dict(node) for node in graph.get('nodes', [])]
edges = [WorkflowGraphEdge.from_dict(edge) for edge in graph.get('edges', [])]
if graph.get('primary_start_node') is None:
Expand Down
1 change: 1 addition & 0 deletions abacusai/api_class/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class FileFormat(ApiEnum):
MPEG = 'mpeg'
WEBM = 'webm'
WMV = 'wmv'
MSG = 'msg'


class ExperimentationMode(ApiEnum):
Expand Down
4 changes: 4 additions & 0 deletions abacusai/api_class/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ class ChatLLMTrainingConfig(TrainingConfig):
enable_code_execution (bool): Enable python code execution in the ChatLLM. This equips the LLM with a python kernel in which all its code is executed.
enable_response_caching (bool): Enable caching of LLM responses to speed up response times and improve reproducibility.
unknown_answer_phrase (str): Fallback response when the LLM can't find an answer.
enable_tool_bar (bool): Enable the tool bar in Enterprise ChatLLM to provide additional functionalities like tool_use, web_search, image_gen, etc.
enable_inline_source_citations (bool): Enable inline citations of the sources in the response.
"""
document_retrievers: List[str] = dataclasses.field(default=None)
num_completion_tokens: int = dataclasses.field(default=None)
Expand Down Expand Up @@ -512,6 +514,8 @@ class ChatLLMTrainingConfig(TrainingConfig):
lookup_rewrite_instructions: str = dataclasses.field(default=None, metadata={'deprecated': True})
enable_response_caching: bool = dataclasses.field(default=None)
unknown_answer_phrase: str = dataclasses.field(default=None)
enable_tool_bar: bool = dataclasses.field(default=None)
enable_inline_source_citations: bool = dataclasses.field(default=None)

def __post_init__(self):
self.problem_type = enums.ProblemType.CHAT_LLM
Expand Down
10 changes: 9 additions & 1 deletion abacusai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ def to_dict(self):
result[k] = v
return result

def __getattr__(self, item):
for section_data in self.section_data_list:
for k, v in section_data.items():
if k == item:
return v
raise AttributeError(
f"'{self.__class__.__name__}' object has no attribute '{item}'")


class ClientOptions:
"""
Expand Down Expand Up @@ -608,7 +616,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.14'
client_version = '1.4.15'

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
2 changes: 1 addition & 1 deletion abacusai/document_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DocumentData(AbstractApiClass):
tokens (list): List of extracted tokens in the document obtained from OCR.
metadata (list): List of metadata for each page in the document.
pageMarkdown (list): The markdown text for the page.
extractedPageText (list): List of extracted text for each page in the document obtained from OCR.
extractedPageText (list): List of extracted text for each page in the document obtained from OCR. Available when return_extracted_page_text parameter is set to True in the document data retrieval API.
augmentedPageText (list): List of extracted text for each page in the document obtained from OCR augmented with embedded links in the document.
"""

Expand Down
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
18 changes: 18 additions & 0 deletions docs/_sources/autoapi/abacusai/agent/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ 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.


.. py:method:: wait_for_publish(timeout=None)
A waiting call until agent is published.
Expand Down
24 changes: 20 additions & 4 deletions docs/_sources/autoapi/abacusai/api_class/ai_agents/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,19 @@ Module Contents

:param name: The name of the output.
:type name: str
:param variable_type: The type of the output.
:type variable_type: WorkflowNodeOutputType
:param variable_type: The type of the output in the form of an enum or a string.
:type variable_type: Union[WorkflowNodeOutputType, str]


.. py:attribute:: name
:type: str


.. py:attribute:: variable_type
:type: abacusai.api_class.enums.WorkflowNodeOutputType
:type: Union[abacusai.api_class.enums.WorkflowNodeOutputType, str]


.. py:method:: __post_init__()
.. py:method:: to_dict()
Expand Down Expand Up @@ -278,12 +281,19 @@ Module Contents
:param output_schema: The react json schema for the output to be shown on UI.
:type output_schema: WorkflowNodeOutputSchema

:raises ValueError: If neither `function` nor `function_name` and `source_code` are provided or the inputs are invalid.
Additional Attributes:
function_name (str): The name of the function.
source_code (str): The source code of the function.


.. py:attribute:: template_metadata
.. py:method:: _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)
:classmethod:



.. py:method:: from_template(template_name, name, configs = None, input_mappings = None, input_schema = None, output_schema = None)
:classmethod:

Expand All @@ -302,6 +312,12 @@ Module Contents



.. py:method:: __setattr__(name, value)
.. py:method:: __getattribute__(name)
.. py:class:: Outputs(node)
.. py:attribute:: node
Expand Down
5 changes: 5 additions & 0 deletions docs/_sources/autoapi/abacusai/api_class/enums/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,11 @@ Module Contents



.. py:attribute:: MSG
:value: 'msg'



.. py:class:: ExperimentationMode
Bases: :py:obj:`ApiEnum`
Expand Down
41 changes: 37 additions & 4 deletions docs/_sources/autoapi/abacusai/api_class/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,19 @@ Package Contents

:param name: The name of the output.
:type name: str
:param variable_type: The type of the output.
:type variable_type: WorkflowNodeOutputType
:param variable_type: The type of the output in the form of an enum or a string.
:type variable_type: Union[WorkflowNodeOutputType, str]


.. py:attribute:: name
:type: str


.. py:attribute:: variable_type
:type: abacusai.api_class.enums.WorkflowNodeOutputType
:type: Union[abacusai.api_class.enums.WorkflowNodeOutputType, str]


.. py:method:: __post_init__()
.. py:method:: to_dict()
Expand Down Expand Up @@ -607,12 +610,19 @@ Package Contents
:param output_schema: The react json schema for the output to be shown on UI.
:type output_schema: WorkflowNodeOutputSchema

:raises ValueError: If neither `function` nor `function_name` and `source_code` are provided or the inputs are invalid.
Additional Attributes:
function_name (str): The name of the function.
source_code (str): The source code of the function.


.. py:attribute:: template_metadata
.. py:method:: _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)
:classmethod:



.. py:method:: from_template(template_name, name, configs = None, input_mappings = None, input_schema = None, output_schema = None)
:classmethod:

Expand All @@ -631,6 +641,12 @@ Package Contents



.. py:method:: __setattr__(name, value)
.. py:method:: __getattribute__(name)
.. py:class:: Outputs(node)
.. py:attribute:: node
Expand Down Expand Up @@ -3880,6 +3896,11 @@ Package Contents



.. py:attribute:: MSG
:value: 'msg'



.. py:class:: ExperimentationMode
Bases: :py:obj:`ApiEnum`
Expand Down Expand Up @@ -7669,6 +7690,10 @@ Package Contents
:type enable_response_caching: bool
:param unknown_answer_phrase: Fallback response when the LLM can't find an answer.
:type unknown_answer_phrase: str
:param enable_tool_bar: Enable the tool bar in Enterprise ChatLLM to provide additional functionalities like tool_use, web_search, image_gen, etc.
:type enable_tool_bar: bool
:param enable_inline_source_citations: Enable inline citations of the sources in the response.
:type enable_inline_source_citations: bool


.. py:attribute:: document_retrievers
Expand Down Expand Up @@ -7791,6 +7816,14 @@ Package Contents
:type: str


.. py:attribute:: enable_tool_bar
:type: bool


.. py:attribute:: enable_inline_source_citations
:type: bool


.. py:method:: __post_init__()
Expand Down
Loading

0 comments on commit e6de9b7

Please sign in to comment.