redbird_agent_sdk module
redbird_agent_sdk module
class redbird_agent_sdk.DatasetObject(name, data: bytes, extension)
Bases: object
A simple container for handling datasets generated by the Redbird Agents. These objects will be used to return datasets generated by Agents to the user.
name
The name of the dataset
- Type: str
filepath
The filepath for the dataset
- Type: str
extension
The associated extension for the dataset
- Type: str
extension : str
get_dataframe() → DataFrame
Returns a Pandas dataframe with the dataset contents
- Returns: Dataframe representation of dataset contents
- Return type: pd.DataFrame
get_list() → List
Returns a list of lists of dataset contents
- Returns: list representation of dataset contents
- Return type: list
get_string() → str
Returns a raw string representation of the dataset using standard CSV delimiters
- Returns: string representation of dataset contents
- Return type: str
name : str
class redbird_agent_sdk.RedbirdAgent(name, id, description, requirements, manifested_requirements, user_id, project_folder_id)
Bases: object
This is the RedbirdAgent class, which connects with a single Redbird Agent, sets requirements for that agent and can remotely execute an agent run and retrieve Agent-generated outputs.
name
The name of the agent
- Type: str
id
The unqiue Redbird ID of the agent
- Type: int
description
A short description of the agent’s functionality and abilities
- Type: str
requirements
A dictionary of the agent requirements, both mandatory and optional. In order for the agent to run successfully, all mandatory requirements must be provided to the agent using the populate_requirements() function.
- Type: dict
manifested_requirements
A dictionary of all currently provided user inputs to the corresponding agent requirements. These are provided to the agent in order to execute the required functionality.
- Type: dict
output_response
This contains the latest text responses from the most recent agent run.
- Type: str
output_objects
This is a list of any objects generated from the most recent agent run.
- Type: list
description : str
get_manifested_requirements() → Dict
Returns a dictionary of the currently set requirements
- Returns: Dictionary of the user-provided values for each requirement.
- Return type: dict
get_output() → tuple[str, List[Any]]
Returns a tuple of the text-based output_response and object-base output_objects
- Returns: Returns a tuple of the string-based output response and the list of objects generated by the most recent agent run.
- Return type: tuple
get_requirements() → Dict
Returns a dictionary of the mandatory and optional agent requirements, including names, default values, and typing requirements
- Returns: Dictionary of the agent requirements.
- Return type: dict
id : int
manifested_requirements : dict
name : str
output_objects : list
output_response : str
populate_requirements(requirements: List[Dict[str, Any]]) → bool
Sets requirements for an agent. Requirements must be provided in the format
[{'name': <RequirementName>, 'value': <ProposedValues>, 'files': <filepaths>}, {...}]
Any proposed values for an agent requirement are validated by the agent itself and any necessary typecasting or conversions are performed automatically to conform with the agent requirements. You can provide any serializeable python object including dicts, lists, or single objects.
For files, the following formats are accepted: CSV, XLSX, DOCX, TXT.
- Parameters: requirements (List *[*Dict *[*str , Any ] ])
- Returns: True if the run was successful, False otherwise. An error or warning is also raised.
- Return type: bool
requirements : dict
retrieve_results(verbose=False) → bool
Checks to see if the agent run is complete on the Redbird side. Typically, this is placed in a while loop and run on a cadence to check if the run was completed successfully. Once the agent has completed its task, the data will automatically be ready for use in the SDK.
- Parameters: verbose (bool) – Whether or not to enable additional printout information (default=False)
- Returns: True if the run is completed and data is ready, False otherwise.
- Return type: bool
run() → bool
Remotely executes the agent using the currently loaded manifested_requirements
- Returns: True if the run was successful, False otherwise. An error or warning is also raised.
- Return type: bool
to_dict() → Dict
Returns a dictionary representation of the RedbirdAgent contents
- Returns: Dictionary representation of all RedbirdAgent contents
- Return type: dict
class redbird_agent_sdk.RedbirdAgentSDK(user_id: int, project_folder_id: int)
Bases: object
This is base level RedbirdAgentSDK class, which allows interfacing directly with Redbird Agents using API calls to the Redbird platform. The agents can accept values for their requirements and run remotely, returning any responses and generated objects, including datasets and media.
agent_list
The list of available agents and their corresponding Agent IDs for the currently logged-in user on the Redbird platform. This will auto-populate when a new RedbirdAgentSDK class is instantiated.
- Type: List[str]
user_id
The Redbird user id
- Type: int
project_folder_id
The Redbird project folder id
- Type: int
agent_list : List[RedbirdAgent] = []
get_agent(agent_id: int) → RedbirdAgent | None
Retrieves the RedbirdAgent corresponding to the provided Agent ID
- Parameters: agent_id (int) – Redbird Agent ID of the agent-in-question
- Returns: Returns a RedbirdAgent if that Agent ID is valid, else returns None.
- Return type: Union[RedbirdAgent, None]
get_agent_by_name(agent_name: str) → RedbirdAgent | None
Retrieves the RedbirdAgent corresponding to the provided Agent name
- Parameters: agent_name (str) – Redbird Agent name of the agent-in-question
- Returns: Returns a RedbirdAgent if that name is valid, else returns None.
- Return type: Union[RedbirdAgent, None]
get_agent_list(print=False) → List[Dict] | None
Returns the list of currently available agents and their Redbird IDs
- Parameters: print (bool) – Whether or not to print to screen
- Returns: Dictionary of the available agents and IDs on the Redbird Platform.
- Return type: List[Dict]
get_agent_requirements(agent_id: int) → Dict | None
Returns a dictionary of the mandatory and optional agent requirements, including names, default values, and typing requirements for a given agent_id
- Parameters: agent_id (int) – Redbird Agent ID of the agent-in-question
- Returns: Returns the dict representation of the agent requirements if that Agent ID is valid, else returns None.
- Return type: Union[Dict, None]
populate_requirements(agent_id: int, requirements: List[Dict[str, Any]]) → bool
Remotely runs the agent with the given agent_id
- Parameters:
- agent_id (int) – Redbird Agent ID of the agent-in-question
- requirements (List *[*Dict *[*str , Any ] ]) – List of requirements to be set for the agent in question. See RedbirdAgent.set_requirements() for more details on how the requirements should be configured.
- Returns: Returns True if the requirements were successfully set, else returns False.
- Return type: bool
project_folder_id : int
run_agent(agent_id: int) → bool
Remotely runs the agent with the given agent_id
- Parameters: agent_id (int) – Redbird Agent ID of the agent-in-question
- Returns: Returns True if the agent succeeds, else returns False.
- Return type: bool
user_id : int
class redbird_agent_sdk.RequirementsObject(name='', value=[], files=[])
Bases: object
A simple container for Redbird Agent Requirements
name
The name of the requirement. This must correspond to the Agent requirement name
- Type: str
value
The new value(s) to be set for the requirement. This can be any serialized python object
- Type: Any
file
The filepaths for any files that should be used as the requirement value, e.g. in the case of a dataset requirement.
- Type: List[str]
files : List[str]
name : str
to_basic_dict() → Dict
Returns the current name and value of the Requirement
- Returns: Name and value of the RequirementsObject
- Return type: dict
to_full_dict() → Dict
Returns the current name, value, and any filepaths attached to the Requirement
- Returns: Full contents of the RequirementsObject
- Return type: dict
value : Any
Updated about 1 month ago
