Python Helper Functions

Natively Supported Helper Functions

This client provides an interface to interact with the AgenticFlow API. It includes functions to run various actions, insert and retrieve data, and upload temporary files.

Functions

Insert Data

Inserts data into an AgenticFlow dataset.

insert_data(dataset_id: str, data: List[Dict[str, Any]])

Arguments

  • dataset_id: The ID of the dataset to insert into.

  • data: A list of dictionaries containing the data to insert.

Returns

  • The response from the API as a JSON object.

Retrieve Data

Retrieves data from an AgenticFlow dataset.

retrieve_data(dataset_id: str, page_size: int = None, include_fields: List[str] = None)

Arguments

  • dataset_id: The ID of the dataset to retrieve from.

  • page_size: The number of results to return per page (optional).

  • include_fields: A list of fields to include in the response (optional).

Returns

  • The response from the API as a JSON object.

Retrieve All Data

Retrieves all data from an AgenticFlow dataset, paginated to handle large datasets.

retrieve_all(dataset_id: str, page_size: int = 1000, include_fields: List[str] = None) -> List[Dict[str, Any]]:

Arguments

  • dataset_id: The ID of the dataset to retrieve from.

  • page_size: The number of results to return per page. Defaults to 1000 (optional).

  • include_fields: A list of fields to include in the response. Defaults to None (optional).

Returns

  • A list of dictionaries containing the retrieved data. Each dictionary represents a document from the dataset.

Upload a Temporary File

Uploads a temporary file to AgenticFlow.

insert_temp_file(file_path_or_bytes: str, ext: str = None)

Arguments

  • file_path_or_bytes: The path to the file or the file contents as bytes.

  • ext: The file extension (optional).

Returns

  • A dictionary containing the download URL of the uploaded file.

Prompt Completion

Runs the prompt completion action with the given prompt and model.

prompt_completion(prompt: str, model: int = None)

Arguments

  • prompt: The prompt to complete.

  • model: The model to use for completion (optional).

Returns

  • The response from the API as a JSON object.

Run an Action

Runs an AgenticFlow action with the given name and parameters.

run_action(action_name: str, params: Dict[str, Any])

Arguments

  • action_name: The name of the action to run.

  • params: A dictionary of parameters to pass to the action.

Returns

  • The response from the API as a JSON object.

Usage Examples

Insert Data

data = [{"field1": "value1", "field2": "value2"}, {"field1": "value3", "field2": "value4"}]
response = insert_data("my_dataset", data)

Retrieve Data

response = retrieve_data("my_dataset", page_size=10, include_fields=["field1", "field2"])

Retrieve All

response = retrieve_all("my_dataset", page_size=500, include_fields=["field1", "field2"])

Upload a Temporary File

Note: Make sure to replace the region variable with your actual region.

file_path = "path/to/file.txt"
response = insert_temp_file(file_path)

Prompt Completion

response = prompt_completion("My prompt", model="openai-gpt35")

Run an Action

response = run_action("my_action", {"param1": "value1", "param2": "value2"})

Last updated