Using the Python SDK

The Athina Python SDK provides a simple interface to update cells in your datasets:

from athina_client.dataset import Dataset

# Define the cells you want to update
cells_to_update = [
    {"row_no": 1, "column_name": "query", "value": "Updated query text"},
    {"row_no": 2, "column_name": "response", "value": "New model response"}
]

# Update the cells in the dataset
try:
    result = Dataset.update_cells("your-dataset-id", cells_to_update)
    print(f"Successfully updated cells: {result}")
except Exception as e:
    print(f"Error updating cells: {e}")

Parameters

  • dataset_id (str): The ID of the dataset to update cells in.
  • cells (List[Dict]): A list of cells to update, where each cell is a dictionary containing:
    • row_no (int): The row number (1-based indexing) of the cell to update.
    • column_name (str): The name of the column containing the cell to update.
    • value (Any): The new value for the specified cell.

Return Value

The method returns a dictionary with the API response, typically containing a success message.

Error Handling

If the API call fails, a CustomException is raised with details about the error.

Direct API Calls

You can also update cells by making a direct API call:

curl --location --request PUT 'http://api.athina.ai/api/v1/dataset_v2/<DATASET_ID>/cells' \
--header 'athina-api-key: <ATHINA_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "cells": [
        {
            "row_no": 1,
            "column_name": "query",
            "value": "Hello World"
        },
        {
            "row_no": 3,
            "column_name": "response",
            "value": "Greetings from Athina!"
        }
    ]
}'

Request Format

  • Method: PUT
  • URL: http://api.athina.ai/api/v1/dataset_v2/<DATASET_ID>/cells
  • Headers:
    • athina-api-key: Your Athina API key
    • Content-Type: application/json
  • Body:
    {
        "cells": [
            {
                "row_no": <row_number>,
                "column_name": "<column_name>",
                "value": <new_value>
            },
            ...
        ]
    }
    

Response Format

If the updates are successful, you will receive a response similar to:

{
    "status": "success",
    "data": {
        "message": "Cells updated successfully"
    }
}