MaximApis
Maxim_Apis utilities for api client utilities for interacting with maxim services.
ConnectionPool
Manages HTTP session pooling for efficient network requests.
This class provides a reusable session with retry logic for handling transient network errors.
__init__
Initialize a new session with retry configuration.
get_session
Context manager that yields the session and ensures it’s closed after use.
Yields:
requests.Session
- The HTTP session object
MaximAPI
Client for interacting with the Maxim API.
This class provides methods for all available Maxim API endpoints, handling authentication, request formatting, and error handling.
__init__
Initialize a new Maxim API client.
Arguments:
Name | Description |
---|---|
base_url | The base URL for the Maxim API |
api_key | The API key for authentication |
get_prompt
Get a prompt by ID.
Arguments:
Name | Description |
---|---|
id | The prompt ID |
Returns:
Name | Description |
---|---|
[VersionAndRulesWithPromptId](/sdk/python/references/models/prompt) | The prompt details |
Raises:
Exception
- If the request fails
get_prompts
Get all prompts.
Returns:
Name | Description |
---|---|
List[[VersionAndRulesWithPromptId](/sdk/python/references/models/prompt)] | List of all prompts |
Raises:
Exception
- If the request fails
getPromptChain
Get a prompt chain by ID.
Arguments:
Name | Description |
---|---|
id | The prompt chain ID |
Returns:
Name | Description |
---|---|
[VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain) | The prompt chain details |
Raises:
Exception
- If the request fails
get_prompt_chains
Get all prompt chains.
Returns:
Name | Description |
---|---|
List[[VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain)] | List of all prompt chains |
Raises:
Exception
- If the request fails
run_prompt
Run a custom prompt with the specified model and messages.
Arguments:
Name | Description |
---|---|
model | The model to use |
messages | List of chat messages |
tools | Optional list of tools to use |
**kwargs | Additional parameters to pass to the API |
Returns:
Name | Description |
---|---|
[PromptResponse](/sdk/python/references/models/prompt) | The response from the model |
Raises:
Exception
- If the request fails
run_prompt_version
Run a specific prompt version with the given input.
Arguments:
Name | Description |
---|---|
prompt_version_id | The ID of the prompt version to run |
input | The input text for the prompt |
image_urls | Optional list of image URLs to include |
variables | Optional dictionary of variables to use |
Returns:
Name | Description |
---|---|
Optional[[PromptResponse](/sdk/python/references/models/prompt)] | The response from the prompt |
Raises:
Exception
- If the request fails
run_prompt_chain_version
Run a specific prompt chain version with the given input.
Arguments:
Name | Description |
---|---|
prompt_chain_version_id | The ID of the prompt chain version to run |
input | The input text for the prompt chain |
variables | Optional dictionary of variables to use |
Returns:
Name | Description |
---|---|
Optional[[AgentResponse](/sdk/python/references/models/prompt_chain)] | The response from the prompt chain |
Raises:
Exception
- If the request fails
get_folder
Get a folder by ID.
Arguments:
Name | Description |
---|---|
id | The folder ID |
Returns:
Name | Description |
---|---|
[Folder](/sdk/python/references/models/folder) | The folder details |
Raises:
Exception
- If the request fails
get_folders
Get all folders.
Returns:
Name | Description |
---|---|
List[[Folder](/sdk/python/references/models/folder)] | List of all folders |
Raises:
Exception
- If the request fails
add_dataset_entries
Add entries to a dataset.
Arguments:
Name | Description |
---|---|
dataset_id | The ID of the dataset |
dataset_entries | List of dataset entries to add |
Returns:
dict[str, Any]: Response from the API
Raises:
Exception
- If the request fails
get_dataset_total_rows
Get the total number of rows in a dataset.
Arguments:
Name | Description |
---|---|
dataset_id | The ID of the dataset |
Returns:
Name | Description |
---|---|
int | The total number of rows |
Raises:
Exception
- If the request fails
get_dataset_row
Get a specific row from a dataset.
Arguments:
Name | Description |
---|---|
dataset_id | The ID of the dataset |
row_index | The index of the row to retrieve |
Returns:
Name | Description |
---|---|
Optional[[DatasetRow](/sdk/python/references/models/dataset)] | The dataset row, or None if not found |
Raises:
Exception
- If the request fails
get_dataset_structure
Get the structure of a dataset.
Arguments:
Name | Description |
---|---|
dataset_id | The ID of the dataset |
Returns:
Dict[str, str]: The dataset structure
Raises:
Exception
- If the request fails
does_log_repository_exist
Check if a log repository exists.
Arguments:
Name | Description |
---|---|
logger_id | The ID of the logger |
Returns:
Name | Description |
---|---|
bool | True if the repository exists, False otherwise |
push_logs
Push logs to a repository.
Arguments:
Name | Description |
---|---|
repository_id | The ID of the repository |
logs | The logs to push |
Raises:
Exception
- If the request fails
fetch_platform_evaluator
Fetch a platform evaluator by name.
Arguments:
Name | Description |
---|---|
name | The name of the evaluator |
in_workspace_id | The workspace ID |
Returns:
Name | Description |
---|---|
[Evaluator](/sdk/python/references/models/evaluator) | The evaluator details |
Raises:
Exception
- If the request fails
create_test_run
Create a new test run.
Arguments:
Name | Description |
---|---|
name | The name of the test run |
workspace_id | The workspace ID |
workflow_id | Optional workflow ID |
prompt_version_id | Optional prompt version ID |
prompt_chain_version_id | Optional prompt chain version ID |
run_type | The type of run |
evaluator_config | List of evaluators to use |
requires_local_run | Whether the test run requires local execution |
human_evaluation_config | Optional human evaluation configuration |
Returns:
Name | Description |
---|---|
[TestRun](/sdk/python/references/models/test_run) | The created test run |
Raises:
Exception
- If the request fails
attach_dataset_to_test_run
Attach a dataset to a test run.
Arguments:
Name | Description |
---|---|
test_run_id | The ID of the test run |
dataset_id | The ID of the dataset |
Raises:
Exception
- If the request fails
push_test_run_entry
Push an entry to a test run.
Arguments:
Name | Description |
---|---|
test_run | The test run |
entry | The test run entry to push |
run_config | Optional run configuration |
Raises:
Exception
- If the request fails
mark_test_run_processed
Mark a test run as processed.
Arguments:
Name | Description |
---|---|
test_run_id | The ID of the test run |
Raises:
Exception
- If the request fails
mark_test_run_failed
Mark a test run as failed.
Arguments:
Name | Description |
---|---|
test_run_id | The ID of the test run |
Raises:
Exception
- If the request fails
get_test_run_status
Get the status of a test run.
Arguments:
Name | Description |
---|---|
test_run_id | The ID of the test run |
Returns:
Name | Description |
---|---|
[TestRunStatus](/sdk/python/references/models/test_run) | The status of the test run |
Raises:
Exception
- If the request fails
get_test_run_final_result
Get the final result of a test run.
Arguments:
Name | Description |
---|---|
test_run_id | The ID of the test run |
Returns:
Name | Description |
---|---|
[TestRunResult](/sdk/python/references/models/test_run) | The final result of the test run |
Raises:
Exception
- If the request fails
get_upload_url
Get a signed URL for uploading a file.
Arguments:
Name | Description |
---|---|
key | The key (filename) for the upload |
mime_type | The MIME type of the file |
size | The size of the file in bytes |
Returns:
Name | Description |
---|---|
[SignedURLResponse](/sdk/python/references/models/attachment) | A dictionary containing the signed URL for upload |
Raises:
Exception
- If the request fails
upload_to_signed_url
Upload data to a signed URL using multipart form data with retry logic.
Arguments:
Name | Description |
---|---|
url | The signed URL to upload to |
data | The binary data to upload |
mime_type | The MIME type of the data |
Returns:
Name | Description |
---|---|
bool | True if upload was successful, False otherwise |