plexus.dashboard.api.models.item module

class plexus.dashboard.api.models.item.Item(id: str, evaluationId: str, createdAt: datetime.datetime, updatedAt: datetime.datetime, accountId: str, isEvaluation: bool, createdByType: str | None = None, text: str | None = None, metadata: Dict | None = None, identifiers: Dict | None = None, externalId: str | None = None, description: str | None = None, scoreId: str | None = None, attachedFiles: list | None = None, client: ForwardRef('_BaseAPIClient') | None = None)

Bases: BaseModel

__init__(id: str, evaluationId: str, createdAt: datetime, updatedAt: datetime, accountId: str, isEvaluation: bool, createdByType: str | None = None, text: str | None = None, metadata: Dict | None = None, identifiers: Dict | None = None, externalId: str | None = None, description: str | None = None, scoreId: str | None = None, attachedFiles: list | None = None, client: _BaseAPIClient | None = None)
accountId: str
attachedFiles: list | None = None
classmethod create(client: _BaseAPIClient, evaluationId: str, text: str | None = None, metadata: Dict | None = None, createdByType: str | None = None, deterministic_id: str | None = None, **kwargs) Item
createdAt: datetime
createdByType: str | None = None
description: str | None = None
evaluationId: str
externalId: str | None = None
classmethod fields() str

Return the GraphQL fields to query for this model

classmethod find_by_identifier(client: _BaseAPIClient, account_id: str, identifier_key: str, identifier_value: str, debug: bool = False) Item | None

Find an Item using a specific identifier (reportId, formId, sessionId, etc.).

This method provides a general-purpose way to find Items by any identifier type, not limited to cache-specific use cases.

Args:

client: API client for database operations account_id: Account ID to scope the search identifier_key: The type of identifier (e.g., ‘reportId’, ‘formId’, ‘sessionId’) identifier_value: The value to search for debug: Enable debug logging

Returns:

Item object if found, None otherwise

Example:

# Find item by report ID item = Item.find_by_identifier(client, account_id, ‘reportId’, ‘277307013’)

# Find item by form ID item = Item.find_by_identifier(client, account_id, ‘formId’, ‘12345’)

classmethod from_dict(data: Dict[str, Any], client: _BaseAPIClient) Item

Create an instance from a dictionary of data

classmethod get_by_id(item_id: str, client: _BaseAPIClient) Item | None

Get a single item by its ID.

Args:

item_id: The ID of the item to retrieve client: The API client to use

Returns:

Item object if found, None otherwise

identifiers: Dict | None = None
isEvaluation: bool
classmethod list(client: _BaseAPIClient, filter: Dict[str, Any] | None = None, sort: Dict[str, str] | None = None, limit: int | None = None, next_token: str | None = None) List[Item]

List items with optional filtering and sorting.

Args:

client: The API client to use filter: Filter conditions (e.g., {‘accountId’: {‘eq’: ‘account123’}}) sort: Sort configuration (e.g., {‘createdAt’: ‘DESC’}) limit: Maximum number of items to return next_token: Pagination token

Returns:

List of Item objects

metadata: Dict | None = None
scoreId: str | None = None
text: str | None = None
update(**kwargs) Item
updatedAt: datetime
classmethod upsert_by_identifiers(client: _BaseAPIClient, account_id: str, identifiers: Dict[str, Any], external_id: str | None = None, description: str | None = None, text: str | None = None, metadata: Dict | None = None, evaluation_id: str | None = None, is_evaluation: bool = False, score_id: str | None = None, debug: bool = False) Tuple[str, bool, str | None]

Upsert an Item using identifier-based lookup to prevent duplicates.

This method provides the core functionality for preventing duplicate Items by using the Identifier table’s GSI for efficient lookups.

Args:

client: PlexusDashboardClient instance account_id: The Plexus account ID identifiers: Dict containing identifier values like {‘formId’: ‘12345’, ‘reportId’: ‘67890’} external_id: Optional external ID for the item description: Optional item description text: Optional text content metadata: Optional metadata dict evaluation_id: Optional evaluation ID (defaults to ‘prediction-default’ for non-evaluation items) is_evaluation: Whether this is an evaluation item debug: Enable debug logging

Returns:

Tuple of (item_id, was_created, error_msg) - item_id: The ID of the created/updated Item, or None if failed - was_created: True if item was created, False if updated - error_msg: Error message if operation failed, None if successful

Example:

identifiers = {‘formId’: ‘12345’, ‘reportId’: ‘67890’} item_id, was_created, error = Item.upsert_by_identifiers(

client=client, account_id=’account-123’, identifiers=identifiers, external_id=’report-67890’, description=’Call transcript’, text=’Full transcript text…’

)